active_model_serializers 0.10.0 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -4
- data/.travis.yml +9 -1
- data/CHANGELOG.md +81 -2
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -2
- data/README.md +24 -24
- data/Rakefile +3 -3
- data/active_model_serializers.gemspec +20 -24
- data/docs/ARCHITECTURE.md +6 -7
- data/docs/README.md +2 -0
- data/docs/general/adapters.md +4 -2
- data/docs/general/caching.md +7 -1
- data/docs/general/configuration_options.md +70 -1
- data/docs/general/deserialization.md +1 -1
- data/docs/general/fields.md +31 -0
- data/docs/general/rendering.md +42 -3
- data/docs/general/serializers.md +97 -8
- data/docs/howto/add_pagination_links.md +4 -5
- data/docs/howto/add_relationship_links.md +137 -0
- data/docs/howto/add_root_key.md +4 -0
- data/docs/howto/grape_integration.md +42 -0
- data/docs/howto/outside_controller_use.md +9 -2
- data/docs/howto/passing_arbitrary_options.md +2 -2
- data/docs/howto/test.md +2 -0
- data/docs/howto/upgrade_from_0_8_to_0_10.md +265 -0
- data/docs/integrations/ember-and-json-api.md +64 -32
- data/docs/jsonapi/schema.md +1 -1
- data/lib/action_controller/serialization.rb +13 -3
- data/lib/active_model/serializer/adapter/base.rb +2 -0
- data/lib/active_model/serializer/array_serializer.rb +8 -5
- data/lib/active_model/serializer/association.rb +19 -4
- data/lib/active_model/serializer/belongs_to_reflection.rb +0 -3
- data/lib/active_model/serializer/collection_serializer.rb +35 -12
- data/lib/active_model/serializer/{associations.rb → concerns/associations.rb} +13 -11
- data/lib/active_model/serializer/{attributes.rb → concerns/attributes.rb} +0 -0
- data/lib/active_model/serializer/{caching.rb → concerns/caching.rb} +72 -113
- data/lib/active_model/serializer/{configuration.rb → concerns/configuration.rb} +25 -1
- data/lib/active_model/serializer/{links.rb → concerns/links.rb} +0 -0
- data/lib/active_model/serializer/{meta.rb → concerns/meta.rb} +0 -0
- data/lib/active_model/serializer/{type.rb → concerns/type.rb} +0 -0
- data/lib/active_model/serializer/error_serializer.rb +11 -7
- data/lib/active_model/serializer/errors_serializer.rb +25 -20
- data/lib/active_model/serializer/has_many_reflection.rb +0 -3
- data/lib/active_model/serializer/has_one_reflection.rb +0 -3
- data/lib/active_model/serializer/lint.rb +134 -130
- data/lib/active_model/serializer/reflection.rb +37 -21
- data/lib/active_model/serializer/version.rb +1 -1
- data/lib/active_model/serializer.rb +76 -37
- data/lib/active_model_serializers/adapter/attributes.rb +3 -66
- data/lib/active_model_serializers/adapter/base.rb +38 -38
- data/lib/active_model_serializers/adapter/json_api/link.rb +1 -1
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +8 -1
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +30 -19
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +23 -9
- data/lib/active_model_serializers/adapter/json_api.rb +44 -43
- data/lib/active_model_serializers/adapter.rb +6 -0
- data/lib/active_model_serializers/deprecate.rb +1 -2
- data/lib/active_model_serializers/deserialization.rb +2 -0
- data/lib/active_model_serializers/key_transform.rb +4 -0
- data/lib/active_model_serializers/lookup_chain.rb +80 -0
- data/lib/active_model_serializers/model.rb +4 -2
- data/lib/active_model_serializers/railtie.rb +3 -1
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +44 -31
- data/lib/active_model_serializers/serializable_resource.rb +6 -5
- data/lib/active_model_serializers/serialization_context.rb +10 -3
- data/lib/active_model_serializers.rb +7 -0
- data/lib/generators/rails/serializer_generator.rb +4 -4
- data/lib/grape/active_model_serializers.rb +7 -5
- data/lib/grape/formatters/active_model_serializers.rb +19 -2
- data/lib/grape/helpers/active_model_serializers.rb +1 -0
- data/test/action_controller/adapter_selector_test.rb +4 -4
- data/test/action_controller/explicit_serializer_test.rb +5 -4
- data/test/action_controller/json/include_test.rb +106 -27
- data/test/action_controller/json_api/errors_test.rb +6 -7
- data/test/action_controller/json_api/fields_test.rb +57 -0
- data/test/action_controller/json_api/linked_test.rb +29 -24
- data/test/action_controller/json_api/pagination_test.rb +19 -19
- data/test/action_controller/json_api/transform_test.rb +3 -3
- data/test/action_controller/lookup_proc_test.rb +49 -0
- data/test/action_controller/namespace_lookup_test.rb +226 -0
- data/test/action_controller/serialization_test.rb +10 -7
- data/test/active_model_serializers/json_pointer_test.rb +15 -13
- data/test/active_model_serializers/key_transform_test.rb +286 -252
- data/test/active_model_serializers/model_test.rb +17 -4
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +143 -0
- data/test/active_model_serializers/serialization_context_test_isolated.rb +23 -10
- data/test/adapter/attributes_test.rb +43 -0
- data/test/adapter/json/collection_test.rb +14 -0
- data/test/adapter/json/transform_test.rb +15 -15
- data/test/adapter/json_api/collection_test.rb +4 -3
- data/test/adapter/json_api/errors_test.rb +17 -19
- data/test/adapter/json_api/fields_test.rb +4 -3
- data/test/adapter/json_api/has_many_test.rb +39 -18
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +166 -0
- data/test/adapter/json_api/json_api_test.rb +5 -7
- data/test/adapter/json_api/linked_test.rb +33 -12
- data/test/adapter/json_api/links_test.rb +4 -2
- data/test/adapter/json_api/pagination_links_test.rb +35 -8
- data/test/adapter/json_api/relationship_test.rb +309 -73
- data/test/adapter/json_api/resource_identifier_test.rb +27 -2
- data/test/adapter/json_api/resource_meta_test.rb +3 -3
- data/test/adapter/json_api/transform_test.rb +255 -253
- data/test/adapter/json_api/type_test.rb +1 -1
- data/test/adapter/json_test.rb +8 -7
- data/test/adapter/null_test.rb +1 -2
- data/test/adapter/polymorphic_test.rb +5 -5
- data/test/adapter_test.rb +1 -1
- data/test/benchmark/app.rb +1 -1
- data/test/benchmark/benchmarking_support.rb +1 -1
- data/test/benchmark/bm_active_record.rb +81 -0
- data/test/benchmark/bm_adapter.rb +38 -0
- data/test/benchmark/bm_caching.rb +16 -16
- data/test/benchmark/bm_lookup_chain.rb +83 -0
- data/test/benchmark/bm_transform.rb +16 -5
- data/test/benchmark/controllers.rb +16 -17
- data/test/benchmark/fixtures.rb +72 -72
- data/test/cache_test.rb +143 -49
- data/test/collection_serializer_test.rb +3 -3
- data/test/fixtures/poro.rb +52 -48
- data/test/generators/serializer_generator_test.rb +22 -5
- data/test/grape_test.rb +152 -56
- data/test/lint_test.rb +1 -1
- data/test/logger_test.rb +13 -11
- data/test/serializable_resource_test.rb +18 -22
- data/test/serializers/association_macros_test.rb +3 -2
- data/test/serializers/associations_test.rb +107 -32
- data/test/serializers/attribute_test.rb +2 -2
- data/test/serializers/attributes_test.rb +1 -1
- data/test/serializers/fieldset_test.rb +1 -1
- data/test/serializers/meta_test.rb +12 -6
- data/test/serializers/root_test.rb +1 -1
- data/test/serializers/serializer_for_test.rb +6 -4
- data/test/serializers/serializer_for_with_namespace_test.rb +87 -0
- data/test/support/isolated_unit.rb +5 -2
- data/test/support/rails5_shims.rb +8 -2
- data/test/support/rails_app.rb +0 -9
- data/test/support/serialization_testing.rb +23 -5
- data/test/test_helper.rb +1 -0
- metadata +85 -34
- data/.rubocop_todo.yml +0 -167
- data/lib/active_model/serializer/include_tree.rb +0 -111
- data/test/adapter/json_api/relationships_test.rb +0 -199
- data/test/include_tree/from_include_args_test.rb +0 -26
- data/test/include_tree/from_string_test.rb +0 -94
- data/test/include_tree/include_args_to_hash_test.rb +0 -64
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_serializers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Klabnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,56 +16,94 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4.
|
29
|
+
version: '4.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: actionpack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '4.
|
39
|
+
version: '4.1'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version: '4.
|
49
|
+
version: '4.1'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: railties
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
57
|
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
|
-
version: '4.
|
48
|
-
|
59
|
+
version: '4.1'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '6'
|
63
|
+
type: :development
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
51
66
|
requirements:
|
52
67
|
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
|
-
version: '4.
|
69
|
+
version: '4.1'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '6'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: jsonapi
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.1.1.beta2
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.1.1.beta2
|
55
87
|
- !ruby/object:Gem::Dependency
|
56
88
|
name: activerecord
|
57
89
|
requirement: !ruby/object:Gem::Requirement
|
58
90
|
requirements:
|
59
91
|
- - ">="
|
60
92
|
- !ruby/object:Gem::Version
|
61
|
-
version: '4.
|
93
|
+
version: '4.1'
|
94
|
+
- - "<"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '6'
|
62
97
|
type: :development
|
63
98
|
prerelease: false
|
64
99
|
version_requirements: !ruby/object:Gem::Requirement
|
65
100
|
requirements:
|
66
101
|
- - ">="
|
67
102
|
- !ruby/object:Gem::Version
|
68
|
-
version: '4.
|
103
|
+
version: '4.1'
|
104
|
+
- - "<"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '6'
|
69
107
|
- !ruby/object:Gem::Dependency
|
70
108
|
name: kaminari
|
71
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,10 +246,10 @@ files:
|
|
208
246
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
209
247
|
- ".gitignore"
|
210
248
|
- ".rubocop.yml"
|
211
|
-
- ".rubocop_todo.yml"
|
212
249
|
- ".simplecov"
|
213
250
|
- ".travis.yml"
|
214
251
|
- CHANGELOG.md
|
252
|
+
- CODE_OF_CONDUCT.md
|
215
253
|
- CONTRIBUTING.md
|
216
254
|
- Gemfile
|
217
255
|
- MIT-LICENSE
|
@@ -229,6 +267,7 @@ files:
|
|
229
267
|
- docs/general/caching.md
|
230
268
|
- docs/general/configuration_options.md
|
231
269
|
- docs/general/deserialization.md
|
270
|
+
- docs/general/fields.md
|
232
271
|
- docs/general/getting_started.md
|
233
272
|
- docs/general/instrumentation.md
|
234
273
|
- docs/general/key_transforms.md
|
@@ -237,11 +276,14 @@ files:
|
|
237
276
|
- docs/general/serializers.md
|
238
277
|
- docs/how-open-source-maintained.jpg
|
239
278
|
- docs/howto/add_pagination_links.md
|
279
|
+
- docs/howto/add_relationship_links.md
|
240
280
|
- docs/howto/add_root_key.md
|
281
|
+
- docs/howto/grape_integration.md
|
241
282
|
- docs/howto/outside_controller_use.md
|
242
283
|
- docs/howto/passing_arbitrary_options.md
|
243
284
|
- docs/howto/serialize_poro.md
|
244
285
|
- docs/howto/test.md
|
286
|
+
- docs/howto/upgrade_from_0_8_to_0_10.md
|
245
287
|
- docs/integrations/ember-and-json-api.md
|
246
288
|
- docs/integrations/grape.md
|
247
289
|
- docs/jsonapi/errors.md
|
@@ -260,28 +302,27 @@ files:
|
|
260
302
|
- lib/active_model/serializer/adapter/null.rb
|
261
303
|
- lib/active_model/serializer/array_serializer.rb
|
262
304
|
- lib/active_model/serializer/association.rb
|
263
|
-
- lib/active_model/serializer/associations.rb
|
264
305
|
- lib/active_model/serializer/attribute.rb
|
265
|
-
- lib/active_model/serializer/attributes.rb
|
266
306
|
- lib/active_model/serializer/belongs_to_reflection.rb
|
267
|
-
- lib/active_model/serializer/caching.rb
|
268
307
|
- lib/active_model/serializer/collection_reflection.rb
|
269
308
|
- lib/active_model/serializer/collection_serializer.rb
|
270
|
-
- lib/active_model/serializer/
|
309
|
+
- lib/active_model/serializer/concerns/associations.rb
|
310
|
+
- lib/active_model/serializer/concerns/attributes.rb
|
311
|
+
- lib/active_model/serializer/concerns/caching.rb
|
312
|
+
- lib/active_model/serializer/concerns/configuration.rb
|
313
|
+
- lib/active_model/serializer/concerns/links.rb
|
314
|
+
- lib/active_model/serializer/concerns/meta.rb
|
315
|
+
- lib/active_model/serializer/concerns/type.rb
|
271
316
|
- lib/active_model/serializer/error_serializer.rb
|
272
317
|
- lib/active_model/serializer/errors_serializer.rb
|
273
318
|
- lib/active_model/serializer/field.rb
|
274
319
|
- lib/active_model/serializer/fieldset.rb
|
275
320
|
- lib/active_model/serializer/has_many_reflection.rb
|
276
321
|
- lib/active_model/serializer/has_one_reflection.rb
|
277
|
-
- lib/active_model/serializer/include_tree.rb
|
278
|
-
- lib/active_model/serializer/links.rb
|
279
322
|
- lib/active_model/serializer/lint.rb
|
280
|
-
- lib/active_model/serializer/meta.rb
|
281
323
|
- lib/active_model/serializer/null.rb
|
282
324
|
- lib/active_model/serializer/reflection.rb
|
283
325
|
- lib/active_model/serializer/singular_reflection.rb
|
284
|
-
- lib/active_model/serializer/type.rb
|
285
326
|
- lib/active_model/serializer/version.rb
|
286
327
|
- lib/active_model_serializers.rb
|
287
328
|
- lib/active_model_serializers/adapter.rb
|
@@ -304,6 +345,7 @@ files:
|
|
304
345
|
- lib/active_model_serializers/json_pointer.rb
|
305
346
|
- lib/active_model_serializers/key_transform.rb
|
306
347
|
- lib/active_model_serializers/logging.rb
|
348
|
+
- lib/active_model_serializers/lookup_chain.rb
|
307
349
|
- lib/active_model_serializers/model.rb
|
308
350
|
- lib/active_model_serializers/railtie.rb
|
309
351
|
- lib/active_model_serializers/register_jsonapi_renderer.rb
|
@@ -324,9 +366,12 @@ files:
|
|
324
366
|
- test/action_controller/json/include_test.rb
|
325
367
|
- test/action_controller/json_api/deserialization_test.rb
|
326
368
|
- test/action_controller/json_api/errors_test.rb
|
369
|
+
- test/action_controller/json_api/fields_test.rb
|
327
370
|
- test/action_controller/json_api/linked_test.rb
|
328
371
|
- test/action_controller/json_api/pagination_test.rb
|
329
372
|
- test/action_controller/json_api/transform_test.rb
|
373
|
+
- test/action_controller/lookup_proc_test.rb
|
374
|
+
- test/action_controller/namespace_lookup_test.rb
|
330
375
|
- test/action_controller/serialization_scope_name_test.rb
|
331
376
|
- test/action_controller/serialization_test.rb
|
332
377
|
- test/active_model_serializers/adapter_for_test.rb
|
@@ -335,10 +380,12 @@ files:
|
|
335
380
|
- test/active_model_serializers/logging_test.rb
|
336
381
|
- test/active_model_serializers/model_test.rb
|
337
382
|
- test/active_model_serializers/railtie_test_isolated.rb
|
383
|
+
- test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb
|
338
384
|
- test/active_model_serializers/serialization_context_test_isolated.rb
|
339
385
|
- test/active_model_serializers/test/schema_test.rb
|
340
386
|
- test/active_model_serializers/test/serializer_test.rb
|
341
387
|
- test/active_record_test.rb
|
388
|
+
- test/adapter/attributes_test.rb
|
342
389
|
- test/adapter/deprecation_test.rb
|
343
390
|
- test/adapter/json/belongs_to_test.rb
|
344
391
|
- test/adapter/json/collection_test.rb
|
@@ -352,13 +399,13 @@ files:
|
|
352
399
|
- test/adapter/json_api/has_many_explicit_serializer_test.rb
|
353
400
|
- test/adapter/json_api/has_many_test.rb
|
354
401
|
- test/adapter/json_api/has_one_test.rb
|
402
|
+
- test/adapter/json_api/include_data_if_sideloaded_test.rb
|
355
403
|
- test/adapter/json_api/json_api_test.rb
|
356
404
|
- test/adapter/json_api/linked_test.rb
|
357
405
|
- test/adapter/json_api/links_test.rb
|
358
406
|
- test/adapter/json_api/pagination_links_test.rb
|
359
407
|
- test/adapter/json_api/parse_test.rb
|
360
408
|
- test/adapter/json_api/relationship_test.rb
|
361
|
-
- test/adapter/json_api/relationships_test.rb
|
362
409
|
- test/adapter/json_api/resource_identifier_test.rb
|
363
410
|
- test/adapter/json_api/resource_meta_test.rb
|
364
411
|
- test/adapter/json_api/toplevel_jsonapi_test.rb
|
@@ -371,7 +418,10 @@ files:
|
|
371
418
|
- test/array_serializer_test.rb
|
372
419
|
- test/benchmark/app.rb
|
373
420
|
- test/benchmark/benchmarking_support.rb
|
421
|
+
- test/benchmark/bm_active_record.rb
|
422
|
+
- test/benchmark/bm_adapter.rb
|
374
423
|
- test/benchmark/bm_caching.rb
|
424
|
+
- test/benchmark/bm_lookup_chain.rb
|
375
425
|
- test/benchmark/bm_transform.rb
|
376
426
|
- test/benchmark/config.ru
|
377
427
|
- test/benchmark/controllers.rb
|
@@ -383,9 +433,6 @@ files:
|
|
383
433
|
- test/generators/scaffold_controller_generator_test.rb
|
384
434
|
- test/generators/serializer_generator_test.rb
|
385
435
|
- test/grape_test.rb
|
386
|
-
- test/include_tree/from_include_args_test.rb
|
387
|
-
- test/include_tree/from_string_test.rb
|
388
|
-
- test/include_tree/include_args_to_hash_test.rb
|
389
436
|
- test/lint_test.rb
|
390
437
|
- test/logger_test.rb
|
391
438
|
- test/poro_test.rb
|
@@ -403,6 +450,7 @@ files:
|
|
403
450
|
- test/serializers/root_test.rb
|
404
451
|
- test/serializers/serialization_test.rb
|
405
452
|
- test/serializers/serializer_for_test.rb
|
453
|
+
- test/serializers/serializer_for_with_namespace_test.rb
|
406
454
|
- test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json
|
407
455
|
- test/support/isolated_unit.rb
|
408
456
|
- test/support/rails5_shims.rb
|
@@ -419,10 +467,7 @@ homepage: https://github.com/rails-api/active_model_serializers
|
|
419
467
|
licenses:
|
420
468
|
- MIT
|
421
469
|
metadata: {}
|
422
|
-
post_install_message:
|
423
|
-
NOTE: The default key case for the JsonApi adapter has changed to dashed.
|
424
|
-
See https://github.com/rails-api/active_model_serializers/blob/master/docs/general/key_transforms.md
|
425
|
-
for more information on configuring this behavior.
|
470
|
+
post_install_message:
|
426
471
|
rdoc_options: []
|
427
472
|
require_paths:
|
428
473
|
- lib
|
@@ -430,7 +475,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
430
475
|
requirements:
|
431
476
|
- - ">="
|
432
477
|
- !ruby/object:Gem::Version
|
433
|
-
version: 2.
|
478
|
+
version: '2.1'
|
434
479
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
435
480
|
requirements:
|
436
481
|
- - ">="
|
@@ -438,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
438
483
|
version: '0'
|
439
484
|
requirements: []
|
440
485
|
rubyforge_project:
|
441
|
-
rubygems_version: 2.4.
|
486
|
+
rubygems_version: 2.4.8
|
442
487
|
signing_key:
|
443
488
|
specification_version: 4
|
444
489
|
summary: Conventions-based JSON generation for Rails.
|
@@ -448,9 +493,12 @@ test_files:
|
|
448
493
|
- test/action_controller/json/include_test.rb
|
449
494
|
- test/action_controller/json_api/deserialization_test.rb
|
450
495
|
- test/action_controller/json_api/errors_test.rb
|
496
|
+
- test/action_controller/json_api/fields_test.rb
|
451
497
|
- test/action_controller/json_api/linked_test.rb
|
452
498
|
- test/action_controller/json_api/pagination_test.rb
|
453
499
|
- test/action_controller/json_api/transform_test.rb
|
500
|
+
- test/action_controller/lookup_proc_test.rb
|
501
|
+
- test/action_controller/namespace_lookup_test.rb
|
454
502
|
- test/action_controller/serialization_scope_name_test.rb
|
455
503
|
- test/action_controller/serialization_test.rb
|
456
504
|
- test/active_model_serializers/adapter_for_test.rb
|
@@ -459,10 +507,12 @@ test_files:
|
|
459
507
|
- test/active_model_serializers/logging_test.rb
|
460
508
|
- test/active_model_serializers/model_test.rb
|
461
509
|
- test/active_model_serializers/railtie_test_isolated.rb
|
510
|
+
- test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb
|
462
511
|
- test/active_model_serializers/serialization_context_test_isolated.rb
|
463
512
|
- test/active_model_serializers/test/schema_test.rb
|
464
513
|
- test/active_model_serializers/test/serializer_test.rb
|
465
514
|
- test/active_record_test.rb
|
515
|
+
- test/adapter/attributes_test.rb
|
466
516
|
- test/adapter/deprecation_test.rb
|
467
517
|
- test/adapter/json/belongs_to_test.rb
|
468
518
|
- test/adapter/json/collection_test.rb
|
@@ -476,13 +526,13 @@ test_files:
|
|
476
526
|
- test/adapter/json_api/has_many_explicit_serializer_test.rb
|
477
527
|
- test/adapter/json_api/has_many_test.rb
|
478
528
|
- test/adapter/json_api/has_one_test.rb
|
529
|
+
- test/adapter/json_api/include_data_if_sideloaded_test.rb
|
479
530
|
- test/adapter/json_api/json_api_test.rb
|
480
531
|
- test/adapter/json_api/linked_test.rb
|
481
532
|
- test/adapter/json_api/links_test.rb
|
482
533
|
- test/adapter/json_api/pagination_links_test.rb
|
483
534
|
- test/adapter/json_api/parse_test.rb
|
484
535
|
- test/adapter/json_api/relationship_test.rb
|
485
|
-
- test/adapter/json_api/relationships_test.rb
|
486
536
|
- test/adapter/json_api/resource_identifier_test.rb
|
487
537
|
- test/adapter/json_api/resource_meta_test.rb
|
488
538
|
- test/adapter/json_api/toplevel_jsonapi_test.rb
|
@@ -495,7 +545,10 @@ test_files:
|
|
495
545
|
- test/array_serializer_test.rb
|
496
546
|
- test/benchmark/app.rb
|
497
547
|
- test/benchmark/benchmarking_support.rb
|
548
|
+
- test/benchmark/bm_active_record.rb
|
549
|
+
- test/benchmark/bm_adapter.rb
|
498
550
|
- test/benchmark/bm_caching.rb
|
551
|
+
- test/benchmark/bm_lookup_chain.rb
|
499
552
|
- test/benchmark/bm_transform.rb
|
500
553
|
- test/benchmark/config.ru
|
501
554
|
- test/benchmark/controllers.rb
|
@@ -507,9 +560,6 @@ test_files:
|
|
507
560
|
- test/generators/scaffold_controller_generator_test.rb
|
508
561
|
- test/generators/serializer_generator_test.rb
|
509
562
|
- test/grape_test.rb
|
510
|
-
- test/include_tree/from_include_args_test.rb
|
511
|
-
- test/include_tree/from_string_test.rb
|
512
|
-
- test/include_tree/include_args_to_hash_test.rb
|
513
563
|
- test/lint_test.rb
|
514
564
|
- test/logger_test.rb
|
515
565
|
- test/poro_test.rb
|
@@ -527,6 +577,7 @@ test_files:
|
|
527
577
|
- test/serializers/root_test.rb
|
528
578
|
- test/serializers/serialization_test.rb
|
529
579
|
- test/serializers/serializer_for_test.rb
|
580
|
+
- test/serializers/serializer_for_with_namespace_test.rb
|
530
581
|
- test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json
|
531
582
|
- test/support/isolated_unit.rb
|
532
583
|
- test/support/rails5_shims.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-03-08 22:29:52 +0100 using RuboCop version 0.37.2.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 2
|
10
|
-
Lint/HandleExceptions:
|
11
|
-
Exclude:
|
12
|
-
- 'Rakefile'
|
13
|
-
|
14
|
-
# Offense count: 2
|
15
|
-
# Cop supports --auto-correct.
|
16
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
17
|
-
Lint/UnusedMethodArgument:
|
18
|
-
Exclude:
|
19
|
-
- 'test/lint_test.rb'
|
20
|
-
|
21
|
-
# Offense count: 4
|
22
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
23
|
-
# SupportedStyles: strict, flexible
|
24
|
-
Rails/TimeZone:
|
25
|
-
Exclude:
|
26
|
-
- 'test/action_controller/serialization_test.rb'
|
27
|
-
- 'test/serializers/cache_test.rb'
|
28
|
-
|
29
|
-
# Offense count: 16
|
30
|
-
# Cop supports --auto-correct.
|
31
|
-
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
|
32
|
-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
33
|
-
Style/AlignHash:
|
34
|
-
Exclude:
|
35
|
-
- 'test/action_controller/json_api/pagination_test.rb'
|
36
|
-
|
37
|
-
# Offense count: 27
|
38
|
-
# Cop supports --auto-correct.
|
39
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
40
|
-
# SupportedStyles: braces, no_braces, context_dependent
|
41
|
-
Style/BracesAroundHashParameters:
|
42
|
-
Exclude:
|
43
|
-
- 'test/action_controller/adapter_selector_test.rb'
|
44
|
-
- 'test/action_controller/json_api/pagination_test.rb'
|
45
|
-
- 'test/adapter/json_api/linked_test.rb'
|
46
|
-
- 'test/adapter/json_api/pagination_links_test.rb'
|
47
|
-
- 'test/adapter/null_test.rb'
|
48
|
-
- 'test/adapter_test.rb'
|
49
|
-
- 'test/collection_serializer_test.rb'
|
50
|
-
- 'test/serializable_resource_test.rb'
|
51
|
-
- 'test/serializers/associations_test.rb'
|
52
|
-
- 'test/serializers/attributes_test.rb'
|
53
|
-
- 'test/serializers/root_test.rb'
|
54
|
-
|
55
|
-
# Offense count: 271
|
56
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
57
|
-
# SupportedStyles: nested, compact
|
58
|
-
Style/ClassAndModuleChildren:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
# Offense count: 6
|
62
|
-
# Cop supports --auto-correct.
|
63
|
-
Style/CommentIndentation:
|
64
|
-
Exclude:
|
65
|
-
- 'active_model_serializers.gemspec'
|
66
|
-
|
67
|
-
# Offense count: 1
|
68
|
-
Style/DoubleNegation:
|
69
|
-
Exclude:
|
70
|
-
- 'lib/active_model/serializable_resource.rb'
|
71
|
-
|
72
|
-
# Offense count: 1
|
73
|
-
# Configuration parameters: MinBodyLength.
|
74
|
-
Style/GuardClause:
|
75
|
-
Exclude:
|
76
|
-
- 'lib/active_model/serializer.rb'
|
77
|
-
|
78
|
-
# Offense count: 58
|
79
|
-
# Cop supports --auto-correct.
|
80
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
81
|
-
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
|
82
|
-
Style/HashSyntax:
|
83
|
-
Enabled: false
|
84
|
-
|
85
|
-
# Offense count: 4
|
86
|
-
# Cop supports --auto-correct.
|
87
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
88
|
-
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
|
89
|
-
Style/IndentArray:
|
90
|
-
Enabled: false
|
91
|
-
|
92
|
-
# Offense count: 10
|
93
|
-
# Cop supports --auto-correct.
|
94
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
95
|
-
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
96
|
-
Style/IndentHash:
|
97
|
-
Enabled: false
|
98
|
-
|
99
|
-
# Offense count: 1
|
100
|
-
# Cop supports --auto-correct.
|
101
|
-
Style/Lambda:
|
102
|
-
Exclude:
|
103
|
-
- 'lib/active_model/serializer.rb'
|
104
|
-
|
105
|
-
# Offense count: 1
|
106
|
-
# Cop supports --auto-correct.
|
107
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
108
|
-
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
|
109
|
-
Style/MethodDefParentheses:
|
110
|
-
Enabled: false
|
111
|
-
|
112
|
-
# Offense count: 1
|
113
|
-
# Cop supports --auto-correct.
|
114
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
115
|
-
# SupportedStyles: aligned, indented
|
116
|
-
Style/MultilineOperationIndentation:
|
117
|
-
Enabled: false
|
118
|
-
|
119
|
-
# Offense count: 1
|
120
|
-
# Cop supports --auto-correct.
|
121
|
-
Style/NegatedIf:
|
122
|
-
Exclude:
|
123
|
-
- 'lib/action_controller/serialization.rb'
|
124
|
-
|
125
|
-
# Offense count: 1
|
126
|
-
# Cop supports --auto-correct.
|
127
|
-
Style/PerlBackrefs:
|
128
|
-
Exclude:
|
129
|
-
- 'test/fixtures/poro.rb'
|
130
|
-
|
131
|
-
# Offense count: 3
|
132
|
-
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
133
|
-
# NamePrefix: is_, has_, have_
|
134
|
-
# NamePrefixBlacklist: is_, has_, have_
|
135
|
-
# NameWhitelist: is_a?
|
136
|
-
Style/PredicateName:
|
137
|
-
Exclude:
|
138
|
-
- 'lib/active_model/serializer/associations.rb'
|
139
|
-
- 'test/action_controller/json_api/linked_test.rb'
|
140
|
-
|
141
|
-
# Offense count: 1
|
142
|
-
# Cop supports --auto-correct.
|
143
|
-
Style/RedundantSelf:
|
144
|
-
Exclude:
|
145
|
-
- 'test/fixtures/poro.rb'
|
146
|
-
|
147
|
-
# Offense count: 1
|
148
|
-
# Cop supports --auto-correct.
|
149
|
-
# Configuration parameters: AllowIfMethodIsEmpty.
|
150
|
-
Style/SingleLineMethods:
|
151
|
-
Exclude:
|
152
|
-
- 'test/serializers/serializer_for_test.rb'
|
153
|
-
|
154
|
-
# Offense count: 4
|
155
|
-
# Cop supports --auto-correct.
|
156
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
157
|
-
# SupportedStyles: single_quotes, double_quotes
|
158
|
-
Style/StringLiteralsInInterpolation:
|
159
|
-
Enabled: false
|
160
|
-
|
161
|
-
# Offense count: 1
|
162
|
-
# Cop supports --auto-correct.
|
163
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
164
|
-
# SupportedStyles: final_newline, final_blank_line
|
165
|
-
Style/TrailingBlankLines:
|
166
|
-
Exclude:
|
167
|
-
- 'test/adapter/null_test.rb'
|
@@ -1,111 +0,0 @@
|
|
1
|
-
module ActiveModel
|
2
|
-
class Serializer
|
3
|
-
# TODO: description of this class, and overview of how it's used
|
4
|
-
class IncludeTree
|
5
|
-
module Parsing
|
6
|
-
module_function
|
7
|
-
|
8
|
-
# Translates a comma separated list of dot separated paths (JSON API format) into a Hash.
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# `'posts.author, posts.comments.upvotes, posts.comments.author'`
|
12
|
-
#
|
13
|
-
# would become
|
14
|
-
#
|
15
|
-
# `{ posts: { author: {}, comments: { author: {}, upvotes: {} } } }`.
|
16
|
-
#
|
17
|
-
# @param [String] included
|
18
|
-
# @return [Hash] a Hash representing the same tree structure
|
19
|
-
def include_string_to_hash(included)
|
20
|
-
# TODO: Needs comment walking through the process of what all this is doing.
|
21
|
-
included.delete(' ').split(',').reduce({}) do |hash, path|
|
22
|
-
include_tree = path.split('.').reverse_each.reduce({}) { |a, e| { e.to_sym => a } }
|
23
|
-
hash.deep_merge!(include_tree)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Translates the arguments passed to the include option into a Hash. The format can be either
|
28
|
-
# a String (see #include_string_to_hash), an Array of Symbols and Hashes, or a mix of both.
|
29
|
-
#
|
30
|
-
# @example
|
31
|
-
# `posts: [:author, comments: [:author, :upvotes]]`
|
32
|
-
#
|
33
|
-
# would become
|
34
|
-
#
|
35
|
-
# `{ posts: { author: {}, comments: { author: {}, upvotes: {} } } }`.
|
36
|
-
#
|
37
|
-
# @example
|
38
|
-
# `[:author, :comments => [:author]]`
|
39
|
-
#
|
40
|
-
# would become
|
41
|
-
#
|
42
|
-
# `{:author => {}, :comments => { author: {} } }`
|
43
|
-
#
|
44
|
-
# @param [Symbol, Hash, Array, String] included
|
45
|
-
# @return [Hash] a Hash representing the same tree structure
|
46
|
-
def include_args_to_hash(included)
|
47
|
-
case included
|
48
|
-
when Symbol
|
49
|
-
{ included => {} }
|
50
|
-
when Hash
|
51
|
-
included.each_with_object({}) do |(key, value), hash|
|
52
|
-
hash[key] = include_args_to_hash(value)
|
53
|
-
end
|
54
|
-
when Array
|
55
|
-
included.reduce({}) { |a, e| a.deep_merge!(include_args_to_hash(e)) }
|
56
|
-
when String
|
57
|
-
include_string_to_hash(included)
|
58
|
-
else
|
59
|
-
{}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Builds an IncludeTree from a comma separated list of dot separated paths (JSON API format).
|
65
|
-
# @example `'posts.author, posts.comments.upvotes, posts.comments.author'`
|
66
|
-
#
|
67
|
-
# @param [String] included
|
68
|
-
# @return [IncludeTree]
|
69
|
-
#
|
70
|
-
def self.from_string(included)
|
71
|
-
new(Parsing.include_string_to_hash(included))
|
72
|
-
end
|
73
|
-
|
74
|
-
# Translates the arguments passed to the include option into an IncludeTree.
|
75
|
-
# The format can be either a String (see #from_string), an Array of Symbols and Hashes, or a mix of both.
|
76
|
-
# @example `posts: [:author, comments: [:author, :upvotes]]`
|
77
|
-
#
|
78
|
-
# @param [Symbol, Hash, Array, String] included
|
79
|
-
# @return [IncludeTree]
|
80
|
-
#
|
81
|
-
def self.from_include_args(included)
|
82
|
-
return included if included.is_a?(IncludeTree)
|
83
|
-
|
84
|
-
new(Parsing.include_args_to_hash(included))
|
85
|
-
end
|
86
|
-
|
87
|
-
# @param [Hash] hash
|
88
|
-
def initialize(hash = {})
|
89
|
-
@hash = hash
|
90
|
-
end
|
91
|
-
|
92
|
-
def key?(key)
|
93
|
-
@hash.key?(key) || @hash.key?(:*) || @hash.key?(:**)
|
94
|
-
end
|
95
|
-
|
96
|
-
def [](key)
|
97
|
-
# TODO(beauby): Adopt a lazy caching strategy for generating subtrees.
|
98
|
-
case
|
99
|
-
when @hash.key?(key)
|
100
|
-
self.class.new(@hash[key])
|
101
|
-
when @hash.key?(:*)
|
102
|
-
self.class.new(@hash[:*])
|
103
|
-
when @hash.key?(:**)
|
104
|
-
self.class.new(:** => {})
|
105
|
-
else
|
106
|
-
nil
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|