restpack_serializer 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -2
- data/README.md +4 -0
- data/Rakefile +5 -0
- data/lib/restpack_serializer.rb +5 -5
- data/lib/restpack_serializer/serializable.rb +1 -1
- data/lib/restpack_serializer/serializable/side_loading.rb +1 -0
- data/lib/restpack_serializer/version.rb +1 -1
- data/performance/perf.rb +22 -0
- data/restpack_serializer.gemspec +5 -6
- data/spec/serializable/attributes_spec.rb +5 -4
- metadata +14 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdc1349a7313a5c5943bc05b5f7b72a2fe1bc28f
|
4
|
+
data.tar.gz: 97b039efc5cce31f0898445031b42610c1c90e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02075a26dfa428f67afc9830431b91128bfb4a51815458663f9dde9432fa422a7983aa122e3009d8cbb1fdd29f62f356868ec9203a472b8e9a2a4e929acaec8
|
7
|
+
data.tar.gz: 62a085bc190feccd5e0f146e3ac77d3c15d60e55cbe226f75a0a0b9c0d7f322f17ac8536ead300a3f77fdfbcdfceaee2c619bdcd72442cbca43517e3e1ec584a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,10 @@ restpack_serializer allows you to quickly provide a set of RESTful endpoints for
|
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
+
**NOTE: This gem needs maintainers**: https://github.com/RestPack/restpack_serializer/issues/128
|
13
|
+
|
14
|
+
---
|
15
|
+
|
12
16
|
* [An overview of RestPack](http://www.slideshare.net/gavinjoyce/taming-monolithic-monsters)
|
13
17
|
* [JSON API](http://jsonapi.org/)
|
14
18
|
|
data/Rakefile
CHANGED
data/lib/restpack_serializer.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'kaminari'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
require_relative 'restpack_serializer/version'
|
4
|
+
require_relative 'restpack_serializer/configuration'
|
5
|
+
require_relative 'restpack_serializer/serializable'
|
6
|
+
require_relative 'restpack_serializer/factory'
|
7
|
+
require_relative 'restpack_serializer/result'
|
8
8
|
|
9
9
|
Kaminari::Hooks.init
|
10
10
|
|
data/performance/perf.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require_relative '../lib/restpack_serializer'
|
3
|
+
|
4
|
+
class SimpleSerializer
|
5
|
+
include RestPack::Serializer
|
6
|
+
attributes :id, :title
|
7
|
+
end
|
8
|
+
|
9
|
+
iterations = 180_000 #180_000 ~> 1 second
|
10
|
+
Benchmark.bm(22) do |bm|
|
11
|
+
bm.report('simple serializer') do
|
12
|
+
|
13
|
+
model = {
|
14
|
+
id: 123,
|
15
|
+
title: 'This is the title'
|
16
|
+
}
|
17
|
+
|
18
|
+
iterations.times do
|
19
|
+
SimpleSerializer.as_json(model)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/restpack_serializer.gemspec
CHANGED
@@ -22,13 +22,12 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_dependency 'kaminari', '~> 0.16.1'
|
23
23
|
|
24
24
|
gem.add_development_dependency 'restpack_gem', '~> 0.0.9'
|
25
|
-
gem.add_development_dependency 'rake', '~>
|
26
|
-
gem.add_development_dependency 'guard-rspec', '~>
|
27
|
-
gem.add_development_dependency '
|
28
|
-
gem.add_development_dependency 'factory_girl', '~> 4.2.0'
|
25
|
+
gem.add_development_dependency 'rake', '~> 11.1.2'
|
26
|
+
gem.add_development_dependency 'guard-rspec', '~> 4.6.4'
|
27
|
+
gem.add_development_dependency 'factory_girl', '~> 4.7.0'
|
29
28
|
gem.add_development_dependency 'sqlite3', '~> 1.3.7'
|
30
|
-
gem.add_development_dependency 'database_cleaner', '~> 1.
|
29
|
+
gem.add_development_dependency 'database_cleaner', '~> 1.5.3'
|
31
30
|
gem.add_development_dependency 'rspec'
|
32
31
|
gem.add_development_dependency 'bump'
|
33
|
-
gem.add_development_dependency 'protected_attributes', '~> 1.
|
32
|
+
gem.add_development_dependency 'protected_attributes', '~> 1.1.3'
|
34
33
|
end
|
@@ -4,7 +4,7 @@ describe RestPack::Serializer::Attributes do
|
|
4
4
|
class CustomSerializer
|
5
5
|
include RestPack::Serializer
|
6
6
|
attributes :a, :b, :c
|
7
|
-
attributes :d, :e
|
7
|
+
attributes :d, :e, :f?
|
8
8
|
optional :sometimes, :maybe
|
9
9
|
attribute :old_attribute, :key => :new_key
|
10
10
|
transform [:gonzaga], lambda { |name, model| model.send(name).downcase }
|
@@ -13,11 +13,11 @@ describe RestPack::Serializer::Attributes do
|
|
13
13
|
subject(:attributes) { CustomSerializer.serializable_attributes }
|
14
14
|
|
15
15
|
it "correctly models specified attributes" do
|
16
|
-
expect(attributes.length).to be(
|
16
|
+
expect(attributes.length).to be(10)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "correctly maps normal attributes" do
|
20
|
-
[:a, :b, :c, :d, :e].each do |attr|
|
20
|
+
[:a, :b, :c, :d, :e, :f?].each do |attr|
|
21
21
|
expect(attributes[attr]).to eq(attr)
|
22
22
|
end
|
23
23
|
end
|
@@ -57,7 +57,7 @@ describe RestPack::Serializer::Attributes do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "model as a hash" do
|
60
|
-
let(:model) { { a: 'A', 'b' => 'B', c: false } }
|
60
|
+
let(:model) { { a: 'A', 'b' => 'B', c: false, :f? => 2 } }
|
61
61
|
|
62
62
|
subject(:as_json) { CustomSerializer.as_json(model, include_gonzaga?: false) }
|
63
63
|
|
@@ -65,6 +65,7 @@ describe RestPack::Serializer::Attributes do
|
|
65
65
|
expect(as_json[:a]).to eq('A')
|
66
66
|
expect(as_json[:b]).to eq('B')
|
67
67
|
expect(as_json[:c]).to eq(false)
|
68
|
+
expect(as_json[:f?]).to eq(2)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -84,56 +84,42 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: 11.1.2
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
94
|
+
version: 11.1.2
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: guard-rspec
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 4.6.4
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: growl
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: 1.0.3
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - "~>"
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 1.0.3
|
108
|
+
version: 4.6.4
|
123
109
|
- !ruby/object:Gem::Dependency
|
124
110
|
name: factory_girl
|
125
111
|
requirement: !ruby/object:Gem::Requirement
|
126
112
|
requirements:
|
127
113
|
- - "~>"
|
128
114
|
- !ruby/object:Gem::Version
|
129
|
-
version: 4.
|
115
|
+
version: 4.7.0
|
130
116
|
type: :development
|
131
117
|
prerelease: false
|
132
118
|
version_requirements: !ruby/object:Gem::Requirement
|
133
119
|
requirements:
|
134
120
|
- - "~>"
|
135
121
|
- !ruby/object:Gem::Version
|
136
|
-
version: 4.
|
122
|
+
version: 4.7.0
|
137
123
|
- !ruby/object:Gem::Dependency
|
138
124
|
name: sqlite3
|
139
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,14 +140,14 @@ dependencies:
|
|
154
140
|
requirements:
|
155
141
|
- - "~>"
|
156
142
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
143
|
+
version: 1.5.3
|
158
144
|
type: :development
|
159
145
|
prerelease: false
|
160
146
|
version_requirements: !ruby/object:Gem::Requirement
|
161
147
|
requirements:
|
162
148
|
- - "~>"
|
163
149
|
- !ruby/object:Gem::Version
|
164
|
-
version: 1.
|
150
|
+
version: 1.5.3
|
165
151
|
- !ruby/object:Gem::Dependency
|
166
152
|
name: rspec
|
167
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,14 +182,14 @@ dependencies:
|
|
196
182
|
requirements:
|
197
183
|
- - "~>"
|
198
184
|
- !ruby/object:Gem::Version
|
199
|
-
version: 1.
|
185
|
+
version: 1.1.3
|
200
186
|
type: :development
|
201
187
|
prerelease: false
|
202
188
|
version_requirements: !ruby/object:Gem::Requirement
|
203
189
|
requirements:
|
204
190
|
- - "~>"
|
205
191
|
- !ruby/object:Gem::Version
|
206
|
-
version: 1.
|
192
|
+
version: 1.1.3
|
207
193
|
description: Model serialization, paging, side-loading and filtering
|
208
194
|
email:
|
209
195
|
- gavinjoyce@gmail.com
|
@@ -236,6 +222,7 @@ files:
|
|
236
222
|
- lib/restpack_serializer/serializable/sortable.rb
|
237
223
|
- lib/restpack_serializer/serializable/symbolizer.rb
|
238
224
|
- lib/restpack_serializer/version.rb
|
225
|
+
- performance/perf.rb
|
239
226
|
- restpack_serializer.gemspec
|
240
227
|
- spec/factory/factory_spec.rb
|
241
228
|
- spec/fixtures/db.rb
|
@@ -275,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
262
|
version: '0'
|
276
263
|
requirements: []
|
277
264
|
rubyforge_project:
|
278
|
-
rubygems_version: 2.
|
265
|
+
rubygems_version: 2.5.1
|
279
266
|
signing_key:
|
280
267
|
specification_version: 4
|
281
268
|
summary: Model serialization, paging, side-loading and filtering
|