Skip to content

Commit

Permalink
chore(pkg): release v1.5.0
Browse files Browse the repository at this point in the history
define eveResource as provider for maximum configuration flexibility.
  • Loading branch information
bret.ikehara committed Feb 16, 2016
1 parent 915794a commit 902a23c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-eve-resource",
"version": "1.4.1",
"version": "1.5.0",
"homepage": "https://github.com/dailymotion/angular-eve-resource",
"authors": [
"Rahul Doshi <[email protected]>",
Expand Down
90 changes: 50 additions & 40 deletions dist/angular-eve-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,67 @@ angular.module('com.dailymotion.ngEveResource')
});

angular.module('com.dailymotion.ngEveResource')
.value('eveCfg', {
'dateformat': 'YYYY-MM-DDTHH:mm:ss[Z]'
})
.factory('eveResource', function ($window, $resource, eveCfg) {
return function(url, paramDefaults, actions, options, toJsonReplacer) {
var Resource,
toJSON;

if (!angular.isFunction(toJsonReplacer)) {
if (angular.isFunction(options)) {
toJsonReplacer = options;
options = {};
} else {
toJsonReplacer = function(key, value) {
return value;
};
}
.provider('eveResource', function () {
var cfg = {
'dateformat': 'YYYY-MM-DDTHH:mm:ss[Z]'
};

this.init = function (config) {
angular.merge(cfg, config);
};

this.$get = ['$window', '$resource', function ($window, $resource) {
function format (time, fmt) {
return $window.moment && $window.moment.utc ? $window.moment.utc(time).format(fmt || cfg.dateformat) : time;
}

Resource = $resource(url, paramDefaults, actions, options);
function formatUpdated (fmt) {
return format(this._updated, fmt);
}

toJSON = Resource.prototype.toJSON;
function formatCreated (fmt) {
return format(this._created, fmt);
}

Resource.prototype.toJSON = function() {
var data = toJSON.call(this);
return function (url, paramDefaults, actions, options, toJsonReplacer) {
var Resource,
toJSON;

if (!angular.isFunction(toJsonReplacer)) {
if (angular.isFunction(options)) {
toJsonReplacer = options;
options = {};
} else {
toJsonReplacer = function(key, value) {
return value;
};
}
}

angular.forEach(data, function(value, key) {
data[key] = key.charAt(0) === '_' ? undefined : toJsonReplacer(key, value);
});
Resource = $resource(url, paramDefaults, actions, options);

return data;
};
toJSON = Resource.prototype.toJSON;

Resource.prototype.exists = function() {
return !!this._id;
};
Resource.prototype.toJSON = function() {
var data = toJSON.call(this);

function format (time, fmt) {
return $window.moment && $window.moment.utc ? $window.moment.utc(time).format(fmt || eveCfg.dateformat) : time;
}
angular.forEach(data, function(value, key) {
data[key] = key.charAt(0) === '_' ? undefined : toJsonReplacer(key, value);
});

Resource.prototype.formatUpdated = function (fmt) {
return format(this._updated, fmt);
};
return data;
};

Resource.prototype.formatCreated = function (fmt) {
return format(this._created, fmt);
};
Resource.prototype.exists = function() {
return !!this._id;
};

return Resource;
};
Resource.prototype.formatUpdated = formatUpdated;
Resource.prototype.formatCreated = formatCreated;

return Resource;
};
}];
});

}(this.angular, this, this.document));
2 changes: 1 addition & 1 deletion dist/angular-eve-resource.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/angular-eve-resource.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-eve-resource",
"version": "1.4.1",
"version": "1.5.0",
"description": "AngularJS Resource Adapter for Python Eve REST API Framework",
"main": "dist/angular-eve-resource.js",
"scripts": {
Expand Down

0 comments on commit 902a23c

Please sign in to comment.