angularjs-rails-resource 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/EXAMPLES.md +1 -0
- data/README.md +7 -6
- data/bower.json +1 -1
- data/lib/angularjs-rails-resource/version.rb +1 -1
- data/package.json +1 -1
- data/test/unit/angularjs/rails/interceptorsSpec.js +21 -0
- data/vendor/assets/javascripts/angularjs/rails/resource/resource.js +0 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45894ff519ef50bed5feda97630ad148e15bfe3a
|
4
|
+
data.tar.gz: 9b757277985bf87c0b5d67ad8daade45965ed9a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3807f841e481d2125c3a7dbaa7202604ec2691d8c7244d127311bcf2fa8b40c498d46bd74fea8a63a5f4c42865eb22ad83f717afe2c66b4ba51a81b34e0794f4
|
7
|
+
data.tar.gz: db60cbf3f22a5552a5e60b4f7c769cfb6094e05fd646ccfb27c6a10456a0043e7b99b1a35029d64e3b4905cd6abf0ab82dc2f5ae42dbcdfdc800309404f54b30
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/EXAMPLES.md
CHANGED
@@ -117,6 +117,7 @@ The following example exposes a <code>getAuthor</code> instance method that woul
|
|
117
117
|
resource.prototype.getAuthor = function () {
|
118
118
|
return Author.get(this.authorId);
|
119
119
|
};
|
120
|
+
return resource;
|
120
121
|
}]);
|
121
122
|
angular.module('book.controllers').controller('BookShelfCtrl', ['$scope', 'Book', function ($scope, Book) {
|
122
123
|
$scope.getAuthorDetails = function (book) {
|
data/README.md
CHANGED
@@ -125,13 +125,14 @@ Resource.configure(config);
|
|
125
125
|
```javascript
|
126
126
|
angular.module('book.controllers').controller('BookShelfCtrl', ['$scope', 'Book', function ($scope, Book) {
|
127
127
|
$scope.searching = true;
|
128
|
+
$scope.books = [];
|
129
|
+
|
128
130
|
// Find all books matching the title
|
129
|
-
|
130
|
-
|
131
|
-
});
|
132
|
-
$scope.books.then(function (results) {
|
131
|
+
Book.query({ title: title }).then(function (results) {
|
132
|
+
$scope.books = results;
|
133
133
|
$scope.searching = false;
|
134
134
|
}, function (error) {
|
135
|
+
// do something about the error
|
135
136
|
$scope.searching = false;
|
136
137
|
});
|
137
138
|
|
@@ -246,10 +247,10 @@ The URL can be specified as one of three ways:
|
|
246
247
|
|
247
248
|
2. basic string - A string without any expression variables will be treated as a base URL and assumed that instance requests should append id to the end.
|
248
249
|
|
249
|
-
3. AngularJS expression - An expression url is evaluated at run time based on the given context for non-instance methods or the instance itself. For example, given the url expression:
|
250
|
+
3. AngularJS expression - An expression url is evaluated at run time based on the given context for non-instance methods or the instance itself. For example, given the url expression: `/stores/{{storeId}}/items/{{id}}`
|
250
251
|
|
251
252
|
```javascript
|
252
|
-
Item.query({category: 'Software'}, {storeId: 123}) // would generate a GET to /stores/
|
253
|
+
Item.query({category: 'Software'}, {storeId: 123}) // would generate a GET to /stores/123/items?category=Software
|
253
254
|
Item.get({storeId: 123, id: 1}) // would generate a GET to /stores/123/items/1
|
254
255
|
|
255
256
|
new Item({store: 123}).create() // would generate a POST to /stores/123/items
|
data/bower.json
CHANGED
data/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "angularjs-rails-resource",
|
3
3
|
"description" : "A resource factory inspired by $resource from AngularJS",
|
4
|
-
"version": "1.2.
|
4
|
+
"version": "1.2.1",
|
5
5
|
"main" : "dist/angularjs-rails-resource.min.js",
|
6
6
|
"homepage" : "https://github.com/FineLinePrototyping/angularjs-rails-resource.git",
|
7
7
|
"author" : "",
|
@@ -212,6 +212,27 @@ describe('interceptors', function () {
|
|
212
212
|
});
|
213
213
|
});
|
214
214
|
|
215
|
+
describe('beforeResponse', function() {
|
216
|
+
it('should run interceptor only once', function() {
|
217
|
+
var Resource, interceptorCalledCount = 0;
|
218
|
+
|
219
|
+
$httpBackend.expectGET('/test/123').respond(200, {id: 123, abc_def: 'xyz'});
|
220
|
+
|
221
|
+
Resource = factory(config);
|
222
|
+
Resource.addInterceptor({
|
223
|
+
'beforeResponse': function (response, constructor, context) {
|
224
|
+
interceptorCalledCount++;
|
225
|
+
return response;
|
226
|
+
}
|
227
|
+
});
|
228
|
+
|
229
|
+
Resource.get(123)
|
230
|
+
$httpBackend.flush();
|
231
|
+
|
232
|
+
expect(interceptorCalledCount).toEqual(1);
|
233
|
+
});
|
234
|
+
});
|
235
|
+
|
215
236
|
describe('response', function () {
|
216
237
|
it('should be able to reference interceptor using name', function () {
|
217
238
|
var promise, result, Resource, testConfig = {};
|
@@ -574,8 +574,6 @@
|
|
574
574
|
|
575
575
|
}
|
576
576
|
|
577
|
-
promise = this.runInterceptorPhase('beforeResponse', context, promise);
|
578
|
-
|
579
577
|
promise = this.runInterceptorPhase('beforeResponse', context, promise).then(function (response) {
|
580
578
|
// store off the data so we don't lose access to it after deserializing and unwrapping
|
581
579
|
response.originalData = response.data;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angularjs-rails-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Odom
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A small AngularJS add-on for integrating with Rails via JSON more easily.
|
15
15
|
email:
|
@@ -19,8 +19,8 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
-
|
23
|
-
-
|
22
|
+
- .gitignore
|
23
|
+
- .travis.yml
|
24
24
|
- CHANGELOG.md
|
25
25
|
- EXAMPLES.md
|
26
26
|
- Gemfile
|
@@ -71,17 +71,17 @@ require_paths:
|
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.1.9
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: AngularJS add-on resource add-on for integrating with Rails
|