collection_json_rails 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -8
- data/collection_json_rails.gemspec +1 -1
- data/lib/collection_json_rails/generators/serializer/serializer_generator.rb +0 -6
- data/lib/collection_json_rails/generators/serializer/templates/serializer.rb +3 -1
- data/lib/collection_json_rails/serializer/serializer.rb +2 -2
- data/lib/collection_json_rails/version.rb +1 -1
- data/test/generators/serializer_generator_test.rb +2 -1
- data/test/generators/tmp/app/serializers/user_serializer.rb +5 -1
- data/test/support/test_app.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb31df11f32736f6cce5ce2c68ee088019c46874
|
4
|
+
data.tar.gz: 64cf9c3799b87bea2b839557828d9d7d6cc85959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 287d083888414a8d1266cba5296179133d92de928c4819c0239efa9c4084c2c35427bdfbd18d60f93f4610ffafbe9704f63136875a324bcb31c2d909426f178d
|
7
|
+
data.tar.gz: 2b91d9015f5b61ad63ce93f4780ab911989efad09e5739d2fb6ffe9a8083eb5523bd3ea7ca03a9f53897f36e37f72c2f953e4ba15feaaba9e752c3e28e6e3b9f
|
data/README.md
CHANGED
@@ -30,7 +30,8 @@ You just need to create serializers for your models. Here's an example:
|
|
30
30
|
```ruby
|
31
31
|
class PostSerializer < CollectionJson::Serializer
|
32
32
|
items do
|
33
|
-
|
33
|
+
attribute :title
|
34
|
+
attribute :body
|
34
35
|
end
|
35
36
|
|
36
37
|
template :title, :body
|
@@ -84,7 +85,8 @@ class PostsController < ApplicationController
|
|
84
85
|
|
85
86
|
class PostSerializer < CollectionJson::Serializer
|
86
87
|
items do
|
87
|
-
|
88
|
+
attribute :title
|
89
|
+
attribute :body
|
88
90
|
end
|
89
91
|
end
|
90
92
|
```
|
@@ -96,7 +98,7 @@ Getting routes in your serializers is easy as shit. Simply pass the method name
|
|
96
98
|
```ruby
|
97
99
|
class PostSerializer < CollectionJson::Serializer
|
98
100
|
href :posts_url
|
99
|
-
|
101
|
+
link dashboard: { href: :dashboard_url }
|
100
102
|
|
101
103
|
items do
|
102
104
|
href :post_url
|
@@ -105,8 +107,5 @@ class PostSerializer < CollectionJson::Serializer
|
|
105
107
|
|
106
108
|
## Contributing
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
111
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
112
|
-
5. Create a new Pull Request
|
110
|
+
Please, all Pull Requests should point to `dev` branch.
|
111
|
+
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_runtime_dependency "collection_json_serializer", "~> 0.
|
22
|
+
spec.add_runtime_dependency "collection_json_serializer", "~> 0.4"
|
23
23
|
|
24
24
|
spec.add_dependency "actionpack", "~> 4.0"
|
25
25
|
spec.add_dependency "railties", "~> 4.0"
|
@@ -2,12 +2,12 @@ class CollectionJson::Serializer
|
|
2
2
|
include CollectionJson::Rails::Support
|
3
3
|
|
4
4
|
def href
|
5
|
-
method = self.class.
|
5
|
+
method = self.class._href.first
|
6
6
|
route(method)
|
7
7
|
end
|
8
8
|
|
9
9
|
def links
|
10
|
-
self.class.
|
10
|
+
self.class._links.map {|link| rewrite_href_of(link) }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -18,7 +18,8 @@ class SerializerGeneratorTest < Rails::Generators::TestCase
|
|
18
18
|
|
19
19
|
assert_file "app/serializers/user_serializer.rb" do |serializer|
|
20
20
|
assert_match /items do/, serializer
|
21
|
-
assert_match /
|
21
|
+
assert_match /attribute :first_name/, serializer
|
22
|
+
assert_match /attribute :email/, serializer
|
22
23
|
assert_match /end/, serializer
|
23
24
|
end
|
24
25
|
end
|
data/test/support/test_app.rb
CHANGED
@@ -27,8 +27,8 @@ class PostSerializer < CollectionJson::Serializer
|
|
27
27
|
end
|
28
28
|
|
29
29
|
href :posts_url
|
30
|
-
|
31
|
-
|
30
|
+
link posts: { href: :posts_url }
|
31
|
+
link external: { href: "http://example.com" }
|
32
32
|
end
|
33
33
|
|
34
34
|
class PostsController < ActionController::Base
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collection_json_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carles Jove i Buxeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: collection_json_serializer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|