Skip to content

Commit 8733afc

Browse files
committed
Merge pull request #28 from avoscloud/feature/v0.4.4
Feature/v0.4.4
2 parents 3019b74 + 572dd90 commit 8733afc

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

lib/av.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* AVOSCloud JavaScript SDK
3-
* Version: 0.4.3
3+
* Version: 0.4.4
44
* Built: Mon Jun 03 2013 13:45:00
55
* http://avoscloud.com
66
*
@@ -13,7 +13,7 @@
1313
*/
1414
(function(root) {
1515
root.AV = root.AV || {};
16-
root.AV.VERSION = "js0.4.3";
16+
root.AV.VERSION = "js0.4.4";
1717
}(this));
1818
// Underscore.js 1.4.4
1919
// http://underscorejs.org
@@ -4113,7 +4113,7 @@
41134113
} else if (typeof(File) !== "undefined" && data instanceof File) {
41144114
this._source = readAsync(data, type);
41154115
} else if(AV._isNode && Buffer.isBuffer(data)) {
4116-
this._source = AV.Promise.as(data.toString('base64'));
4116+
this._source = AV.Promise.as(data.toString('base64'), guessedType);
41174117
this._metaData.size = data.length;
41184118
} else if (_.isString(data)) {
41194119
throw "Creating a AV.File from a String is not yet supported.";
@@ -4268,7 +4268,8 @@
42684268
mime_type: type,
42694269
metaData: self._metaData,
42704270
};
4271-
self._metaData.mime_type = type;
4271+
if(type && self._metaData.mime_type == null)
4272+
self._metaData.mime_type = type;
42724273
self._qiniu_key = key;
42734274
self._base64 = base64;
42744275
return AV._request("qiniu", null, null, 'POST', data);
@@ -5578,6 +5579,24 @@
55785579

55795580
AV.Object._extend = AV._extend;
55805581

5582+
/**
5583+
* Creates a new model with defined attributes,
5584+
* It's the same with
5585+
* <pre>
5586+
* new AV.Object(attributes, options);
5587+
* </pre>
5588+
* @param {Object} attributes The initial set of data to store in the object.
5589+
* @param {Object} options A set of Backbone-like options for creating the
5590+
* object. The only option currently supported is "collection".
5591+
* @return {AV.Object}
5592+
* @since v0.4.4
5593+
* @see AV.Object
5594+
* @see AV.Object.extend
5595+
*/
5596+
AV.Object.new = function(attributes, options){
5597+
return new AV.Object(attributes, options);
5598+
};
5599+
55815600
/**
55825601
* Creates a new subclass of AV.Object for the given AV class name.
55835602
*
@@ -5643,6 +5662,9 @@
56435662
var newArguments = [className].concat(AV._.toArray(arguments));
56445663
return AV.Object.extend.apply(NewClassObject, newArguments);
56455664
};
5665+
NewClassObject.new = function(attributes, options){
5666+
return new NewClassObject(attributes, options);
5667+
};
56465668
AV.Object._classMap[className] = NewClassObject;
56475669
return NewClassObject;
56485670
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "avoscloud-sdk",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"main": "./lib/av.js",
55
"description": "AVOSCloud JavaScript SDK.",
66
"repository": {

tests/file.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ describe("files", function() {
99
file.save().then(function(){
1010
console.log(file.url());
1111
console.log(file.id);
12-
expect(file.size()).to.be(30);
1312
expect(file.ownerId()).to.be.ok();
1413
expect(file.id).to.be.ok();
1514
expect(file.metaData('format')).to.be('txt file');

tests/object.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var GameScoreCollection = AV.Collection.extend({
77

88
describe('Objects', function(){
99
var objId;
10-
var gameScore = new GameScore();
10+
var gameScore = GameScore.new();
1111
describe('#Saving Objects', function(){
1212
it('should crate a Object', function(done){
1313
//gameScore.set("newcol","sss")
@@ -148,7 +148,7 @@ describe('Objects', function(){
148148

149149
// Create the post
150150

151-
myPost = new Post();
151+
myPost = Post.new();
152152
myPost.set("title", "post1");
153153
myPost.set("author", "author1");
154154
myPost.set("content", "Where should we go for lunch?");

0 commit comments

Comments
 (0)