version_serializers 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 490fcc43a11bfb18466b513d939f2e01381ed192
4
- data.tar.gz: 9bfb65e62ce824b62609e47ff62734eca8850c1c
3
+ metadata.gz: 61222ce01c6bd93dbecfdd0ec23bdf0a9e098401
4
+ data.tar.gz: 5a3c86865658cf77430f7dbe6e0e3113d528c445
5
5
  SHA512:
6
- metadata.gz: 93bca0c557591028a452eb7b115b2379e40836c10d93e63f0583df691ffa2e57672466bd0332bc9aa3e600fb74b03ded6bedb9fb8f9a4215efb49876394ea301
7
- data.tar.gz: bb36276f7ff85803173ba47919d66c9b773aaa84f37bdca1425602e47a58ec63b4a5c45a86aeb2d39d7000dca7852bd80d8d5436df2c62abf15e945a69ea84ca
6
+ metadata.gz: ae65bd717ce34c546d8c6d1f737869320bfdbe2744f87e6b4de078e3acc310ca06e8c6aa9c08bb767489ac4077e30daf1edc6a3fed6392a15b62b6b2baac4eba
7
+ data.tar.gz: a25e05d17465dd1bf0da3467459d4b0292d30e82d5294f9aac319ca3f95d45fe2bcadd897f5b6bf5c247c90c1fd3fcb979fc00922e45fc4fa28086c1ab730936
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg
2
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in version_serializer.gemspec
4
4
  gemspec
5
5
 
6
+ gem "byebug"
6
7
 
7
8
  gem "rails", github: "rails/rails"
8
9
  gem "arel", github: "rails/arel"
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: git://github.com/rack/rack.git
3
- revision: 545532b01d332325c913808b7c2047a9256ed551
3
+ revision: 146c754df01ae768119f2066421b10efd0f0db4f
4
4
  specs:
5
5
  rack (2.0.0.alpha)
6
6
  json
@@ -13,71 +13,67 @@ GIT
13
13
 
14
14
  GIT
15
15
  remote: git://github.com/rails/rails.git
16
- revision: f5ab4055b909e7b325304c5a7e414c28bbe441b7
16
+ revision: 473f63734a55d2a91083a619ce1395dfe32aec8d
17
17
  specs:
18
- rails (5.0.0.beta1)
19
- actioncable (= 5.0.0.beta1)
20
- actionmailer (= 5.0.0.beta1)
21
- actionpack (= 5.0.0.beta1)
22
- actionview (= 5.0.0.beta1)
23
- activejob (= 5.0.0.beta1)
24
- activemodel (= 5.0.0.beta1)
25
- activerecord (= 5.0.0.beta1)
26
- activesupport (= 5.0.0.beta1)
18
+ rails (5.0.0.beta2)
19
+ actioncable (= 5.0.0.beta2)
20
+ actionmailer (= 5.0.0.beta2)
21
+ actionpack (= 5.0.0.beta2)
22
+ actionview (= 5.0.0.beta2)
23
+ activejob (= 5.0.0.beta2)
24
+ activemodel (= 5.0.0.beta2)
25
+ activerecord (= 5.0.0.beta2)
26
+ activesupport (= 5.0.0.beta2)
27
27
  bundler (>= 1.3.0, < 2.0)
28
- railties (= 5.0.0.beta1)
28
+ railties (= 5.0.0.beta2)
29
29
  sprockets-rails (>= 2.0.0)
30
30
 
31
31
  GIT
32
32
  remote: https://github.com/rails/rails.git
33
- revision: f5ab4055b909e7b325304c5a7e414c28bbe441b7
33
+ revision: 473f63734a55d2a91083a619ce1395dfe32aec8d
34
34
  specs:
35
- actioncable (5.0.0.beta1)
36
- actionpack (= 5.0.0.beta1)
37
- celluloid (~> 0.17.2)
38
- coffee-rails (~> 4.1.0)
39
- em-hiredis (~> 0.3.0)
40
- faye-websocket (~> 0.10.0)
41
- redis (~> 3.0)
35
+ actioncable (5.0.0.beta2)
36
+ actionpack (= 5.0.0.beta2)
37
+ nio4r (~> 1.2)
42
38
  websocket-driver (~> 0.6.1)
43
- actionmailer (5.0.0.beta1)
44
- actionpack (= 5.0.0.beta1)
45
- actionview (= 5.0.0.beta1)
46
- activejob (= 5.0.0.beta1)
39
+ actionmailer (5.0.0.beta2)
40
+ actionpack (= 5.0.0.beta2)
41
+ actionview (= 5.0.0.beta2)
42
+ activejob (= 5.0.0.beta2)
47
43
  mail (~> 2.5, >= 2.5.4)
48
44
  rails-dom-testing (~> 1.0, >= 1.0.5)
49
- actionpack (5.0.0.beta1)
50
- actionview (= 5.0.0.beta1)
51
- activesupport (= 5.0.0.beta1)
45
+ actionpack (5.0.0.beta2)
46
+ actionview (= 5.0.0.beta2)
47
+ activesupport (= 5.0.0.beta2)
52
48
  rack (~> 2.x)
53
49
  rack-test (~> 0.6.3)
54
50
  rails-dom-testing (~> 1.0, >= 1.0.5)
55
51
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
56
- actionview (5.0.0.beta1)
57
- activesupport (= 5.0.0.beta1)
52
+ actionview (5.0.0.beta2)
53
+ activesupport (= 5.0.0.beta2)
58
54
  builder (~> 3.1)
59
55
  erubis (~> 2.7.0)
60
56
  rails-dom-testing (~> 1.0, >= 1.0.5)
61
57
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
62
- activejob (5.0.0.beta1)
63
- activesupport (= 5.0.0.beta1)
58
+ activejob (5.0.0.beta2)
59
+ activesupport (= 5.0.0.beta2)
64
60
  globalid (>= 0.3.6)
65
- activemodel (5.0.0.beta1)
66
- activesupport (= 5.0.0.beta1)
67
- activerecord (5.0.0.beta1)
68
- activemodel (= 5.0.0.beta1)
69
- activesupport (= 5.0.0.beta1)
61
+ activemodel (5.0.0.beta2)
62
+ activesupport (= 5.0.0.beta2)
63
+ activerecord (5.0.0.beta2)
64
+ activemodel (= 5.0.0.beta2)
65
+ activesupport (= 5.0.0.beta2)
70
66
  arel (~> 7.0)
71
- activesupport (5.0.0.beta1)
67
+ activesupport (5.0.0.beta2)
72
68
  concurrent-ruby (~> 1.0)
73
69
  i18n (~> 0.7)
74
70
  json (~> 1.7, >= 1.7.7)
75
71
  method_source
76
72
  minitest (~> 5.1)
77
73
  tzinfo (~> 1.1)
78
- railties (5.0.0.beta1)
79
- actionpack (= 5.0.0.beta1)
80
- activesupport (= 5.0.0.beta1)
74
+ railties (5.0.0.beta2)
75
+ actionpack (= 5.0.0.beta2)
76
+ activesupport (= 5.0.0.beta2)
81
77
  method_source
82
78
  rake (>= 0.8.7)
83
79
  thor (>= 0.18.1, < 2.0)
@@ -85,56 +81,23 @@ GIT
85
81
  PATH
86
82
  remote: .
87
83
  specs:
88
- version_serializers (0.1.4)
84
+ version_serializers (0.1.5)
89
85
  active_model_serializers (>= 0.10.0.rc2)
90
86
 
91
87
  GEM
92
88
  remote: https://rubygems.org/
93
89
  specs:
94
- active_model_serializers (0.10.0.rc3)
90
+ active_model_serializers (0.10.0.rc4)
95
91
  actionpack (>= 4.0)
96
92
  activemodel (>= 4.0)
97
93
  railties (>= 4.0)
98
94
  builder (3.2.2)
99
- celluloid (0.17.2)
100
- celluloid-essentials
101
- celluloid-extras
102
- celluloid-fsm
103
- celluloid-pool
104
- celluloid-supervision
105
- timers (>= 4.1.1)
106
- celluloid-essentials (0.20.5)
107
- timers (>= 4.1.1)
108
- celluloid-extras (0.20.5)
109
- timers (>= 4.1.1)
110
- celluloid-fsm (0.20.5)
111
- timers (>= 4.1.1)
112
- celluloid-pool (0.20.5)
113
- timers (>= 4.1.1)
114
- celluloid-supervision (0.20.5)
115
- timers (>= 4.1.1)
116
- coffee-rails (4.1.1)
117
- coffee-script (>= 2.2.0)
118
- railties (>= 4.0.0, < 5.1.x)
119
- coffee-script (2.4.1)
120
- coffee-script-source
121
- execjs
122
- coffee-script-source (1.10.0)
95
+ byebug (8.2.2)
123
96
  concurrent-ruby (1.0.0)
124
97
  diff-lcs (1.2.5)
125
- em-hiredis (0.3.0)
126
- eventmachine (~> 1.0)
127
- hiredis (~> 0.5.0)
128
98
  erubis (2.7.0)
129
- eventmachine (1.0.9)
130
- execjs (2.6.0)
131
- faye-websocket (0.10.2)
132
- eventmachine (>= 0.12.0)
133
- websocket-driver (>= 0.5.1)
134
99
  globalid (0.3.6)
135
100
  activesupport (>= 4.1.0)
136
- hiredis (0.5.2)
137
- hitimes (1.2.3)
138
101
  i18n (0.7.0)
139
102
  json (1.8.3)
140
103
  loofah (2.0.3)
@@ -144,8 +107,9 @@ GEM
144
107
  method_source (0.8.2)
145
108
  mime-types (2.99)
146
109
  mini_portile2 (2.0.0)
147
- minitest (5.8.3)
148
- nokogiri (1.6.7.1)
110
+ minitest (5.8.4)
111
+ nio4r (1.2.1)
112
+ nokogiri (1.6.7.2)
149
113
  mini_portile2 (~> 2.0.0.rc2)
150
114
  rack-test (0.6.3)
151
115
  rack (>= 1.0)
@@ -155,15 +119,14 @@ GEM
155
119
  activesupport (>= 4.2.0.beta, < 5.0)
156
120
  nokogiri (~> 1.6.0)
157
121
  rails-deprecated_sanitizer (>= 1.0.1)
158
- rails-html-sanitizer (1.0.2)
122
+ rails-html-sanitizer (1.0.3)
159
123
  loofah (~> 2.0)
160
124
  rake (10.5.0)
161
- redis (3.2.2)
162
125
  rspec (3.4.0)
163
126
  rspec-core (~> 3.4.0)
164
127
  rspec-expectations (~> 3.4.0)
165
128
  rspec-mocks (~> 3.4.0)
166
- rspec-core (3.4.1)
129
+ rspec-core (3.4.2)
167
130
  rspec-support (~> 3.4.0)
168
131
  rspec-expectations (3.4.0)
169
132
  diff-lcs (>= 1.2.0, < 2.0)
@@ -175,14 +138,12 @@ GEM
175
138
  sprockets (3.5.2)
176
139
  concurrent-ruby (~> 1.0)
177
140
  rack (> 1, < 3)
178
- sprockets-rails (3.0.0)
141
+ sprockets-rails (3.0.1)
179
142
  actionpack (>= 4.0)
180
143
  activesupport (>= 4.0)
181
144
  sprockets (>= 3.0.0)
182
145
  thor (0.19.1)
183
146
  thread_safe (0.3.5)
184
- timers (4.1.1)
185
- hitimes
186
147
  tzinfo (1.2.2)
187
148
  thread_safe (~> 0.1)
188
149
  websocket-driver (0.6.3)
@@ -200,6 +161,7 @@ DEPENDENCIES
200
161
  activesupport!
201
162
  arel!
202
163
  bundler (~> 1.11)
164
+ byebug
203
165
  rack!
204
166
  rails!
205
167
  railties!
@@ -1,7 +1,7 @@
1
1
  module VersionSerializer::ControllerAdditions
2
2
 
3
3
  def serialized_render(resource, opts = {})
4
- render VersionSerializer::Versioner.get_rendering_opts(resource, request_version, opts)
4
+ render VersionSerializer::Versioner.get_rendering_opts(resource, request_version).merge(opts)
5
5
  end
6
6
 
7
7
  def get_serializer_for(class_name)
@@ -1,3 +1,3 @@
1
1
  module VersionSerializer
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -7,22 +7,32 @@ module VersionSerializer
7
7
  send(:new, version, "#{name}_serializer".classify).get
8
8
  end
9
9
 
10
- def self.get_rendering_opts(resource, version, opts)
10
+ def self.get_rendering_opts(resource, version)
11
11
  resource_class_name = resource.class.to_s
12
12
  serializer_key = :serializer
13
- if resource.is_a?(ActiveRecord::Relation)
14
- resource_class_name = resource_class_name.split("::").tap(&:pop).join("::")
13
+ if resource.is_a? Enumerable
15
14
  serializer_key = :each_serializer
15
+ if resource.is_a? ActiveRecord::Relation
16
+ resource_class_name = resource_class_name.split("::").tap(&:pop).join("::")
17
+ else
18
+ return { json: resource } if resource.empty?
19
+ resource_class_name = resource.first.class.to_s
20
+ end
16
21
  end
17
22
  serializer_class = get_serializer(resource_class_name, version)
18
- opts.merge!(json: resource, serializer_key => serializer_class)
23
+ { json: resource, serializer_key => serializer_class }
19
24
  end
20
25
 
21
26
  def get
22
27
  "V#{request_version}::#{class_name}".constantize
23
28
  rescue NameError
24
29
  previous_version = request_version.to_i - 1
25
- previous_version == 0 ? raise(NameError) : self.class.new(previous_version, class_name).get
30
+
31
+ if previous_version == 0
32
+ raise NameError
33
+ else
34
+ self.class.new(previous_version, class_name).get
35
+ end
26
36
  end
27
37
 
28
38
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version_serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben D'Angelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".rspec"
77
78
  - CODE_OF_CONDUCT.md
78
79
  - Gemfile
79
80
  - Gemfile.lock