Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
arenoir committed Apr 21, 2015
2 parents 0ad054c + 219b331 commit 4eaded8
Show file tree
Hide file tree
Showing 40 changed files with 689 additions and 166 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tmp/
tests/source/
dist/
.idea
*.iml

.DS_Store
.project
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The latest passing build from the "master" branch is available on
Similarly, the latest passing build from the "beta" branch can be found
on [http://emberjs.com/builds/#/beta](http://emberjs.com/builds/#/beta)

Or build ember-data.js yourself. Clone the repository and run `npm run dist`
Or build ember-data.js yourself. Clone the repository and run `npm run build:production`
after [setup](#setup). You'll find ember-data.js in the `dist` directory.

#### Internet Explorer 8
Expand All @@ -53,7 +53,7 @@ controllers in your app.
First thing's first: tell Ember Data about the models in your
application. For example, imagine we're writing a blog reader app.
Here's what your model definition would look like if you're using
globals (that is, not something like Ember App Kit or ember-cli):
globals (that is, not something like or ember-cli):

```js
var attr = DS.attr;
Expand All @@ -75,7 +75,7 @@ App.Comment = DS.Model.extend({
});
```

If you're using ES6 modules (via Ember App Kit or ember-cli), your
If you're using ES6 modules (via ember-cli), your
models would look like this:

```js
Expand Down Expand Up @@ -167,7 +167,7 @@ post [The Road to Ember Data

1. Ensure that [Node.js](http://nodejs.org/) is installed.
2. Run `npm install` to ensure the required dependencies are installed.
3. Run `npm run dist` to build Ember Data. The builds will be placed in the `dist/` directory.
3. Run `npm run build:production` to build Ember Data. The builds will be placed in the `dist/` directory.

# Contribution

Expand Down
6 changes: 1 addition & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
"name": "ember-data",
"private": true,
"dependencies": {
"ember": "~1.10.0"
"ember": "~1.11.1"
},
"devDependencies": {
"qunit": "~1.17.0",
"jquery": "~1.10.x",
"handlebars": ">= 2.0.0 < 3.0.0",
"loader.js": "~1.0.0",
"es5-shim": "~4.0.3"
},
"resolutions": {
"handlebars": ">= 2.0.0 < 3.0.0"
}
}
7 changes: 7 additions & 0 deletions config/package-manager-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
"main": "./ember-data.js",
"dependencies": {
"ember": ">= 1.8.1 < 2.0.0"
},
"jspm": {
"main": "ember-data",
"shim": {
"ember-data": { "deps": ["ember"], "exports": "DS" },
"ember-data.prod": { "deps": ["ember"], "exports": "DS" }
}
}
}
70 changes: 42 additions & 28 deletions config/s3ProjectConfig.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
module.exports = function(revision, tag, date){
function fileMap(revision,tag,date) {
return {
'ember-data.js': fileObject('ember-data.js', 'text/javascript', revision, tag, date),
'ember-data.js.map': fileObject('ember-data.js.map', 'application/json', revision, tag, date),
'ember-data.min.js': fileObject('ember-data.min.js', 'text/javascript', revision, tag, date),
'ember-data.prod.js': fileObject('ember-data.prod.js', 'text/javascript', revision, tag, date)
}
}
'ember-data.js': fileObject('ember-data', '.js', 'text/javascript', revision, tag, date),
'ember-data.js.map': fileObject('ember-data.js', '.map', 'application/json', revision, tag, date),
'ember-data.min.js': fileObject('ember-data.min', '.js', 'text/javascript', revision, tag, date),
'ember-data.prod.js': fileObject('ember-data.prod', '.js', 'text/javascript', revision, tag, date),
'docs/data.json': fileObject('ember-data-docs', '.json', 'application/json', revision, tag, date)
};
};

function fileObject(fileName, contentType, currentRevision, tag, date) {
var filePath = '/' + fileName;
return {
function fileObject(baseName, extension, contentType, currentRevision, tag, date){
var fullName = '/' + baseName + extension;
var obj = {
contentType: contentType,
destinations: {
canary: [
'canary' + filePath,
'canary/daily/' + date + filePath,
'canary/shas/' + currentRevision + filePath
],
stable: [
'stable' + filePath,
'stable/daily/' + date + filePath,
'stable/shas/' + currentRevision + filePath
],
beta: [
'beta' + filePath,
'beta/daily/' + date + filePath,
'beta/shas/' + currentRevision + filePath
]
}
}
destinations: {
canary: [
'latest' + fullName,
'canary' + fullName,
'canary/daily/' + date + fullName,
'canary/shas/' + currentRevision + fullName
],
release: [
'stable' + fullName,
'release' + fullName,
'release/daily/' + date + fullName,
'release/shas/' + currentRevision + fullName
],
beta: [
'beta' + fullName,
'beta/daily/' + date + fullName,
'beta/shas/' + currentRevision + fullName
],
wildcard: []
}
};

if (tag) {
for (var key in obj.destinations) {
obj.destinations[key].push('tags/' + tag + fullName);
}
}

return obj;
}

module.exports = fileMap;
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,10 @@ module.exports.prototype = {
check: function(file, errors) {
var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace;
var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace;
var tokens = file.getTokens();

file.iterateNodesByType(['FunctionDeclaration'], function(node) {
var nodeBeforeRoundBrace = node;
// named function
if (node.id) {
nodeBeforeRoundBrace = node.id;
}

var functionTokenPos = file.getTokenPosByRangeStart(nodeBeforeRoundBrace.range[0]);
var functionToken = tokens[functionTokenPos];

var nextTokenPos = file.getTokenPosByRangeStart(functionToken.range[1]);
var nextToken = tokens[nextTokenPos];
var functionToken = file.getFirstNodeToken(node.id || node);
var nextToken = file.getNextToken(functionToken);

if (beforeOpeningRoundBrace) {
if (nextToken) {
Expand All @@ -56,8 +46,8 @@ module.exports.prototype = {
}
}

var tokenBeforeBodyPos = file.getTokenPosByRangeStart(node.body.range[0] - 1);
var tokenBeforeBody = tokens[tokenBeforeBodyPos];
// errors if no token is found unless `includeComments` is passed
var tokenBeforeBody = file.getPrevToken(node.body, { includeComments: true });

if (beforeOpeningCurlyBrace) {
if (tokenBeforeBody) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"ejs": "^1.0.0",
"ember-cli": "^0.1.15",
"ember-inflector": "^1.5.0",
"ember-publisher": "0.0.6",
"ember-publisher": "0.0.7",
"es6-module-transpiler": "^0.9.5",
"es6-module-transpiler-amd-formatter": "^0.2.4",
"es6-module-transpiler-package-resolver": "^1.0.1",
"git-repo-version": "0.0.2",
"jscs": "^1.11.0",
"jscs": "^1.12.0",
"testem": "^0.6.19",
"yuidocjs": "~0.3.46"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ var ActiveModelSerializer = RESTSerializer.extend({
type.eachRelationship(function(key, relationship) {
var payloadKey, payload;
if (relationship.options.polymorphic) {
payloadKey = this.keyForAttribute(key);
payloadKey = this.keyForAttribute(key, "deserialize");
payload = hash[payloadKey];
if (payload && payload.type) {
payload.type = this.typeForRoot(payload.type);
Expand All @@ -273,7 +273,7 @@ var ActiveModelSerializer = RESTSerializer.extend({
});
}
} else {
payloadKey = this.keyForRelationship(key, relationship.kind);
payloadKey = this.keyForRelationship(key, relationship.kind, "deserialize");
if (!hash.hasOwnProperty(payloadKey)) { return; }
payload = hash[payloadKey];
}
Expand Down
130 changes: 122 additions & 8 deletions packages/ember-data/lib/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,145 @@ export default Ember.Mixin.create({
@method buildURL
@param {String} type
@param {String|Array} id single id or array of ids
@param {String|Array|Object} id single id or array of ids or query
@param {DS.Snapshot|Array} snapshot single snapshot or array of snapshots
@param {String} requestType
@return {String} url
*/
buildURL: function(type, id, snapshot, requestType) {
switch (requestType) {
case 'find':
return this.urlForFind(id, type, snapshot);
case 'findAll':
return this.urlForFindAll(type);
case 'findQuery':
return this.urlForFindQuery(id, type);
case 'findMany':
return this.urlForFindMany(id, type, snapshot);
case 'findHasMany':
return this.urlForFindHasMany(id, type);
case 'findBelongsTo':
return this.urlForFindBelongsTo(id, type);
case 'createRecord':
return this.urlForCreateRecord(type, snapshot);
case 'deleteRecord':
return this.urlForDeleteRecord(id, type, snapshot);
default:
return this._buildURL(type, id);
}
},

/**
@method _buildURL
@private
@param {String} type
@param {String} id
@return {String} url
*/
_buildURL: function(type, id) {
var url = [];
var host = get(this, 'host');
var prefix = this.urlPrefix();
var path;

if (type) { url.push(this.pathForType(type)); }

//We might get passed in an array of ids from findMany
//in which case we don't want to modify the url, as the
//ids will be passed in through a query param
if (id && !Ember.isArray(id)) { url.push(encodeURIComponent(id)); }
if (type) {
path = this.pathForType(type);
if (path) { url.push(path); }
}

if (id) { url.push(encodeURIComponent(id)); }
if (prefix) { url.unshift(prefix); }

url = url.join('/');
if (!host && url) { url = '/' + url; }
if (!host && url && url.charAt(0) !== '/') {
url = '/' + url;
}

return url;
},

/**
* @method urlForFind
* @param {String} id
* @param {String} type
* @param {DS.Snapshot} snapshot
* @return {String} url
*/
urlForFind: function(id, type, snapshot) {
return this._buildURL(type, id);
},

/**
* @method urlForFindAll
* @param {String} type
* @return {String} url
*/
urlForFindAll: function(type) {
return this._buildURL(type);
},

/**
* @method urlForFindQuery
* @param {Object} query
* @param {String} type
* @return {String} url
*/
urlForFindQuery: function(query, type) {
return this._buildURL(type);
},

/**
* @method urlForFindMany
* @param {Array} ids
* @param {String} type
* @param {Array} snapshots
* @return {String} url
*/
urlForFindMany: function(ids, type, snapshots) {
return this._buildURL(type);
},

/**
* @method urlForFindHasMany
* @param {String} id
* @param {String} type
* @return {String} url
*/
urlForFindHasMany: function(id, type) {
return this._buildURL(type, id);
},

/**
* @method urlForFindBelongTo
* @param {String} id
* @param {String} type
* @return {String} url
*/
urlForFindBelongsTo: function(id, type) {
return this._buildURL(type, id);
},

/**
* @method urlForCreateRecord
* @param {String} type
* @param {DS.Snapshot} snapshot
* @return {String} url
*/
urlForCreateRecord: function(type, snapshot) {
return this._buildURL(type);
},

/**
* @method urlForDeleteRecord
* @param {String} id
* @param {String} type
* @param {DS.Snapshot} snapshot
* @return {String} url
*/
urlForDeleteRecord: function(id, type, snapshot) {
return this._buildURL(type, id);
},

/**
@method urlPrefix
@private
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export default Adapter.extend(BuildURLMixin, {
@return {Promise} promise
*/
findQuery: function(store, type, query) {
var url = this.buildURL(type.typeKey, null, null, 'findQuery');
var url = this.buildURL(type.typeKey, query, null, 'findQuery');

if (this.sortQueryParams) {
query = this.sortQueryParams(query);
Expand Down
Loading

0 comments on commit 4eaded8

Please sign in to comment.