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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b9a0ef79365cfef15b52ed9e26cbd29c22bd01e
4
- data.tar.gz: cc72ff0b9a2da4a313e07da85d0806e8d67cbcf6
3
+ metadata.gz: eb31df11f32736f6cce5ce2c68ee088019c46874
4
+ data.tar.gz: 64cf9c3799b87bea2b839557828d9d7d6cc85959
5
5
  SHA512:
6
- metadata.gz: 3a65e5746f40197a9f62410b230bf52f1a2c4aaca5ec6d21c8639601f2d5fb10113aa1e9faac7ae4bec5058eb7d33880269a2a1cf9f96adeb54b4de5e85aca0c
7
- data.tar.gz: 6b52b1fb434f03f5e185c6c94260f3aedf752fc76113a4dcd0906dc19783bcec7cf67b9836c804642dc2f159b0c052fe0e54e8c480a62ea79ba5ab02bcf3b73e
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
- attributes :title, :body
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
- attributes :title, :body
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
- links dashboard: { href: :dashboard_url }
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
- 1. Fork it ( https://github.com/[my-github-username]/collection_json_rails/fork )
109
- 2. Create your feature branch (`git checkout -b my-new-feature`)
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.3.5"
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"
@@ -13,12 +13,6 @@ module Rails
13
13
  File.join("app/serializers", class_path,
14
14
  "#{file_name}_serializer.rb")
15
15
  end
16
-
17
- private
18
-
19
- def item_attributes
20
- attributes.map { |a| ":#{a.name}" }
21
- end
22
16
  end
23
17
  end
24
18
  end
@@ -1,7 +1,9 @@
1
1
  class <%= class_name %>Serializer < CollectionJson::Serializer
2
2
  <% if attributes.any? -%>
3
3
  items do
4
- attributes <%= item_attributes.join(', ') %>
4
+ <% attributes.each do |attr| %>
5
+ attribute <%= ":#{attr.name}" %>
6
+ <% end %>
5
7
  end
6
8
  <% end -%>
7
9
  end
@@ -2,12 +2,12 @@ class CollectionJson::Serializer
2
2
  include CollectionJson::Rails::Support
3
3
 
4
4
  def href
5
- method = self.class.href.first
5
+ method = self.class._href.first
6
6
  route(method)
7
7
  end
8
8
 
9
9
  def links
10
- self.class.links.map {|link| rewrite_href_of(link) }
10
+ self.class._links.map {|link| rewrite_href_of(link) }
11
11
  end
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  module CollectionJson
2
2
  module Rails
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -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 /attributes :first_name, :email/, serializer
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
@@ -1,6 +1,10 @@
1
1
  class UserSerializer < CollectionJson::Serializer
2
2
  items do
3
- attributes :first_name, :email
3
+
4
+ attribute :first_name
5
+
6
+ attribute :email
7
+
4
8
  end
5
9
  end
6
10
 
@@ -27,8 +27,8 @@ class PostSerializer < CollectionJson::Serializer
27
27
  end
28
28
 
29
29
  href :posts_url
30
- links posts: { href: :posts_url }
31
- links external: { href: "http://example.com" }
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.3.1
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-07 00:00:00.000000000 Z
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.3.5
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.3.5
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement