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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48ad2bb0975d935d8c7862edb654645f26e7ee91
4
- data.tar.gz: 965783d651b2f3bb9b1d37b8cab6b18064c091e5
3
+ metadata.gz: cdc1349a7313a5c5943bc05b5f7b72a2fe1bc28f
4
+ data.tar.gz: 97b039efc5cce31f0898445031b42610c1c90e51
5
5
  SHA512:
6
- metadata.gz: a12cd6e72db3ad699934ff7ff5dade4f8d76514d76aef01d707949da51f7caf8628a104ccaadec3275737714beed588d91884fef81544da6e6893ec670f14d02
7
- data.tar.gz: d3e38c875f4467d587d0b8e68329daccad67a3e368c62c84278431325a1cdeadbc8cf1dce4be1ff1720501f57d5451950c353c9a818f37bdb22680aee8043f4b
6
+ metadata.gz: c02075a26dfa428f67afc9830431b91128bfb4a51815458663f9dde9432fa422a7983aa122e3009d8cbb1fdd29f62f356868ec9203a472b8e9a2a4e929acaec8
7
+ data.tar.gz: 62a085bc190feccd5e0f146e3ac77d3c15d60e55cbe226f75a0a0b9c0d7f322f17ac8536ead300a3f77fdfbcdfceaee2c619bdcd72442cbca43517e3e1ec584a
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.3.1
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ - 2.3.1
5
4
  script: bundle exec rake test
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
@@ -1,2 +1,7 @@
1
1
  require "restpack_gem"
2
2
  RestPack::Gem::Tasks.load_tasks
3
+
4
+ desc "Run some performance tests"
5
+ task :perf do
6
+ require_relative 'performance/perf.rb'
7
+ end
@@ -1,10 +1,10 @@
1
1
  require 'kaminari'
2
2
 
3
- require 'restpack_serializer/version'
4
- require 'restpack_serializer/configuration'
5
- require 'restpack_serializer/serializable'
6
- require 'restpack_serializer/factory'
7
- require 'restpack_serializer/result'
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
 
@@ -48,7 +48,7 @@ module RestPack
48
48
  end
49
49
 
50
50
  add_custom_attributes(data)
51
- add_links(model, data)
51
+ add_links(model, data) unless self.class.associations.empty?
52
52
 
53
53
  Symbolizer.recursive_symbolize(data)
54
54
  end
@@ -45,6 +45,7 @@ module RestPack::Serializer::SideLoading
45
45
  end
46
46
 
47
47
  def associations
48
+ return [] unless @can_includes
48
49
  can_includes.map do |include|
49
50
  association = association_from_include(include)
50
51
  association if supported_association?(association.macro)
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Serializer
3
- VERSION = '0.5.9'
3
+ VERSION = '0.5.10'
4
4
  end
5
5
  end
@@ -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
@@ -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', '~> 10.0.3'
26
- gem.add_development_dependency 'guard-rspec', '~> 2.5.4'
27
- gem.add_development_dependency 'growl', '~> 1.0.3'
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.0.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.0.5'
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(9)
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.9
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: 2015-02-09 00:00:00.000000000 Z
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: 10.0.3
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: 10.0.3
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: 2.5.4
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: 2.5.4
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.2.0
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.2.0
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.0.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.0.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.0.5
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.0.5
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.0.14
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