active_model_serializers 0.8.3 → 0.10.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rubocop.yml +82 -0
- data/.rubocop_todo.yml +315 -0
- data/.simplecov +99 -0
- data/.travis.yml +26 -20
- data/CHANGELOG.md +14 -67
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +45 -1
- data/{MIT-LICENSE.txt → LICENSE.txt} +3 -2
- data/README.md +186 -488
- data/Rakefile +33 -12
- data/active_model_serializers.gemspec +49 -23
- data/appveyor.yml +25 -0
- data/docs/README.md +29 -0
- data/docs/general/adapters.md +110 -0
- data/docs/general/configuration_options.md +11 -0
- data/docs/general/getting_started.md +73 -0
- data/docs/howto/add_pagination_links.md +112 -0
- data/docs/howto/add_root_key.md +51 -0
- data/docs/howto/outside_controller_use.md +42 -0
- data/lib/action_controller/serialization.rb +31 -31
- data/lib/active_model/serializable_resource.rb +70 -0
- data/lib/active_model/serializer/adapter/flatten_json.rb +12 -0
- data/lib/active_model/serializer/adapter/fragment_cache.rb +75 -0
- data/lib/active_model/serializer/adapter/json/fragment_cache.rb +5 -0
- data/lib/active_model/serializer/adapter/json.rb +47 -0
- data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +13 -0
- data/lib/active_model/serializer/adapter/json_api/pagination_links.rb +50 -0
- data/lib/active_model/serializer/adapter/json_api.rb +158 -0
- data/lib/active_model/serializer/adapter/null.rb +5 -0
- data/lib/active_model/serializer/adapter.rb +159 -0
- data/lib/active_model/serializer/array_serializer.rb +40 -0
- data/lib/active_model/serializer/association.rb +20 -0
- data/lib/active_model/serializer/associations.rb +83 -219
- data/lib/active_model/serializer/belongs_to_reflection.rb +10 -0
- data/lib/active_model/serializer/collection_reflection.rb +7 -0
- data/lib/active_model/serializer/configuration.rb +14 -0
- data/lib/active_model/serializer/fieldset.rb +40 -0
- data/lib/active_model/serializer/has_many_reflection.rb +10 -0
- data/lib/active_model/serializer/has_one_reflection.rb +10 -0
- data/lib/active_model/serializer/lint.rb +129 -0
- data/lib/active_model/serializer/railtie.rb +15 -0
- data/lib/active_model/serializer/reflection.rb +74 -0
- data/lib/active_model/serializer/singular_reflection.rb +7 -0
- data/lib/active_model/serializer/utils.rb +35 -0
- data/lib/active_model/{serializers → serializer}/version.rb +1 -1
- data/lib/active_model/serializer.rb +121 -465
- data/lib/active_model_serializers.rb +26 -88
- data/lib/generators/serializer/USAGE +0 -3
- data/lib/generators/serializer/resource_override.rb +12 -0
- data/lib/generators/serializer/serializer_generator.rb +8 -13
- data/lib/generators/serializer/templates/serializer.rb.erb +8 -0
- data/lib/tasks/rubocop.rake +0 -0
- data/test/action_controller/adapter_selector_test.rb +53 -0
- data/test/action_controller/explicit_serializer_test.rb +134 -0
- data/test/action_controller/json_api/linked_test.rb +179 -0
- data/test/action_controller/json_api/pagination_test.rb +116 -0
- data/test/{serialization_scope_name_test.rb → action_controller/serialization_scope_name_test.rb} +15 -15
- data/test/action_controller/serialization_test.rb +420 -0
- data/test/active_record_test.rb +9 -0
- data/test/adapter/fragment_cache_test.rb +37 -0
- data/test/adapter/json/belongs_to_test.rb +47 -0
- data/test/adapter/json/collection_test.rb +82 -0
- data/test/adapter/json/has_many_test.rb +47 -0
- data/test/adapter/json_api/belongs_to_test.rb +157 -0
- data/test/adapter/json_api/collection_test.rb +95 -0
- data/test/adapter/json_api/has_many_embed_ids_test.rb +45 -0
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +98 -0
- data/test/adapter/json_api/has_many_test.rb +145 -0
- data/test/adapter/json_api/has_one_test.rb +81 -0
- data/test/adapter/json_api/json_api_test.rb +37 -0
- data/test/adapter/json_api/linked_test.rb +283 -0
- data/test/adapter/json_api/pagination_links_test.rb +115 -0
- data/test/adapter/json_api/resource_type_config_test.rb +59 -0
- data/test/adapter/json_test.rb +47 -0
- data/test/adapter/null_test.rb +25 -0
- data/test/adapter_test.rb +42 -0
- data/test/array_serializer_test.rb +99 -73
- data/test/capture_warnings.rb +65 -0
- data/test/fixtures/active_record.rb +56 -0
- data/test/fixtures/poro.rb +261 -0
- data/test/generators/scaffold_controller_generator_test.rb +23 -0
- data/test/generators/serializer_generator_test.rb +56 -0
- data/test/lint_test.rb +37 -0
- data/test/logger_test.rb +18 -0
- data/test/poro_test.rb +9 -0
- data/test/serializable_resource_test.rb +27 -0
- data/test/serializers/adapter_for_test.rb +170 -0
- data/test/serializers/association_macros_test.rb +36 -0
- data/test/serializers/associations_test.rb +150 -0
- data/test/serializers/attribute_test.rb +62 -0
- data/test/serializers/attributes_test.rb +57 -0
- data/test/serializers/cache_test.rb +165 -0
- data/test/serializers/configuration_test.rb +15 -0
- data/test/serializers/fieldset_test.rb +25 -0
- data/test/serializers/meta_test.rb +121 -0
- data/test/serializers/options_test.rb +21 -0
- data/test/serializers/root_test.rb +21 -0
- data/test/serializers/serializer_for_test.rb +65 -0
- data/test/support/rails_app.rb +21 -0
- data/test/support/serialization_testing.rb +13 -0
- data/test/support/simplecov.rb +6 -0
- data/test/support/stream_capture.rb +50 -0
- data/test/support/test_case.rb +5 -0
- data/test/test_helper.rb +48 -24
- data/test/utils/include_args_to_hash_test.rb +79 -0
- metadata +219 -47
- data/DESIGN.textile +0 -586
- data/Gemfile.edge +0 -9
- data/bench/perf.rb +0 -43
- data/cruft.md +0 -19
- data/lib/active_model/array_serializer.rb +0 -104
- data/lib/active_record/serializer_override.rb +0 -16
- data/lib/generators/resource_override.rb +0 -13
- data/lib/generators/serializer/templates/serializer.rb +0 -19
- data/test/association_test.rb +0 -592
- data/test/caching_test.rb +0 -96
- data/test/generators_test.rb +0 -85
- data/test/no_serialization_scope_test.rb +0 -34
- data/test/serialization_test.rb +0 -392
- data/test/serializer_support_test.rb +0 -51
- data/test/serializer_test.rb +0 -1465
- data/test/test_fakes.rb +0 -217
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f97fe4e6870c3e3338fb3415b762d451f07f2b9d
|
4
|
+
data.tar.gz: a911ae55792f5fa60ddd9f198b21f3d9960d3647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 639b8b33bd971772668ead59b6e38b7f0e2aa5f36c4c680876a9241aeaa51b77e70efdfc5d8af84f9bd3bf9b5646848a8b1ad30c3e0927a98ca14fe9106410f7
|
7
|
+
data.tar.gz: 9b61116bd804ea07f9294792e73d8736b3f06b5919739c304689bf0cf9d9ef7974467eb1fef4929a5ceb6ca9629d95067761428a6f8fa86cebb870bb4d1b3d05
|
data/.gitignore
CHANGED
@@ -4,15 +4,20 @@
|
|
4
4
|
.config
|
5
5
|
.yardoc
|
6
6
|
Gemfile.lock
|
7
|
+
Gemfile.local
|
7
8
|
InstalledFiles
|
8
9
|
_yardoc
|
9
10
|
coverage
|
10
11
|
doc/
|
11
12
|
lib/bundler/man
|
12
13
|
pkg
|
14
|
+
Vagrantfile
|
15
|
+
.vagrant
|
13
16
|
rdoc
|
14
17
|
spec/reports
|
15
18
|
test/tmp
|
16
19
|
test/version_tmp
|
17
20
|
tmp
|
18
21
|
*.swp
|
22
|
+
.ruby-version
|
23
|
+
.ruby-gemset
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- config/initializers/forbidden_yaml.rb
|
6
|
+
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
|
7
|
+
RunRailsCops: true
|
8
|
+
DisplayCopNames: true
|
9
|
+
DisplayStyleGuide: true
|
10
|
+
|
11
|
+
Style/IndentationConsistency:
|
12
|
+
Exclude:
|
13
|
+
- lib/active_model/serializer/adapter/flatten_json.rb
|
14
|
+
- lib/active_model/serializer/adapter/fragment_cache.rb
|
15
|
+
- lib/active_model/serializer/adapter/json.rb
|
16
|
+
- lib/active_model/serializer/adapter/json/fragment_cache.rb
|
17
|
+
- lib/active_model/serializer/adapter/json_api.rb
|
18
|
+
- lib/active_model/serializer/adapter/json_api/fragment_cache.rb
|
19
|
+
- lib/active_model/serializer/adapter/json_api/pagination_links.rb
|
20
|
+
- lib/active_model/serializer/adapter/null.rb
|
21
|
+
|
22
|
+
Style/IndentationWidth:
|
23
|
+
Exclude:
|
24
|
+
- lib/active_model/serializer/adapter/flatten_json.rb
|
25
|
+
- lib/active_model/serializer/adapter/fragment_cache.rb
|
26
|
+
- lib/active_model/serializer/adapter/json.rb
|
27
|
+
- lib/active_model/serializer/adapter/json/fragment_cache.rb
|
28
|
+
- lib/active_model/serializer/adapter/json_api.rb
|
29
|
+
- lib/active_model/serializer/adapter/json_api/fragment_cache.rb
|
30
|
+
- lib/active_model/serializer/adapter/json_api/pagination_links.rb
|
31
|
+
- lib/active_model/serializer/adapter/null.rb
|
32
|
+
|
33
|
+
Style/AccessModifierIndentation:
|
34
|
+
Exclude:
|
35
|
+
- lib/active_model/serializer/adapter/flatten_json.rb
|
36
|
+
- lib/active_model/serializer/adapter/fragment_cache.rb
|
37
|
+
- lib/active_model/serializer/adapter/json.rb
|
38
|
+
- lib/active_model/serializer/adapter/json/fragment_cache.rb
|
39
|
+
- lib/active_model/serializer/adapter/json_api.rb
|
40
|
+
- lib/active_model/serializer/adapter/json_api/fragment_cache.rb
|
41
|
+
- lib/active_model/serializer/adapter/json_api/pagination_links.rb
|
42
|
+
- lib/active_model/serializer/adapter/null.rb
|
43
|
+
|
44
|
+
Lint/NestedMethodDefinition:
|
45
|
+
Enabled: false
|
46
|
+
Exclude:
|
47
|
+
- test/action_controller/serialization_test.rb
|
48
|
+
|
49
|
+
Style/StringLiterals:
|
50
|
+
EnforcedStyle: single_quotes
|
51
|
+
|
52
|
+
Metrics/AbcSize:
|
53
|
+
Max: 35 # TODO: Lower to 15
|
54
|
+
|
55
|
+
Metrics/ClassLength:
|
56
|
+
Max: 261 # TODO: Lower to 100
|
57
|
+
Exclude:
|
58
|
+
- test/**/*.rb
|
59
|
+
|
60
|
+
Metrics/CyclomaticComplexity:
|
61
|
+
Max: 7 # TODO: Lower to 6
|
62
|
+
|
63
|
+
Metrics/LineLength:
|
64
|
+
Max: 251 # TODO: Lower to 80
|
65
|
+
|
66
|
+
Metrics/MethodLength:
|
67
|
+
Max: 106 # TODO: Lower to 10
|
68
|
+
|
69
|
+
Metrics/PerceivedComplexity:
|
70
|
+
Max: 9 # TODO: Lower to 7
|
71
|
+
|
72
|
+
Style/AlignParameters:
|
73
|
+
EnforcedStyle: with_fixed_indentation
|
74
|
+
|
75
|
+
Style/ClassAndModuleChildren:
|
76
|
+
EnforcedStyle: compact
|
77
|
+
|
78
|
+
Style/Documentation:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/MultilineOperationIndentation:
|
82
|
+
EnforcedStyle: indented
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,315 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-08-31 04:23:33 -0500 using RuboCop version 0.33.0.
|
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: 1
|
10
|
+
# Configuration parameters: AllowSafeAssignment.
|
11
|
+
Lint/AssignmentInCondition:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/active_model/serializer/adapter/json_api.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
Lint/EmptyEnsure:
|
17
|
+
Exclude:
|
18
|
+
- 'test/serializers/adapter_for_test.rb'
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
Lint/HandleExceptions:
|
22
|
+
Exclude:
|
23
|
+
- 'Rakefile'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
Lint/UnusedBlockArgument:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/active_model/serializer/adapter/json_api/fragment_cache.rb'
|
30
|
+
|
31
|
+
# Offense count: 9
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
Lint/UnusedMethodArgument:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/active_model/serializer/adapter.rb'
|
36
|
+
- 'lib/active_model/serializer/adapter/null.rb'
|
37
|
+
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
38
|
+
- 'test/fixtures/poro.rb'
|
39
|
+
- 'test/lint_test.rb'
|
40
|
+
|
41
|
+
# Offense count: 1
|
42
|
+
Lint/UselessAccessModifier:
|
43
|
+
Exclude:
|
44
|
+
- 'lib/active_model/serializable_resource.rb'
|
45
|
+
|
46
|
+
# Offense count: 3
|
47
|
+
Lint/UselessAssignment:
|
48
|
+
Exclude:
|
49
|
+
- 'bench/perf.rb'
|
50
|
+
- 'lib/active_model/serializer/adapter/json_api/fragment_cache.rb'
|
51
|
+
- 'test/test_helper.rb'
|
52
|
+
|
53
|
+
# Offense count: 1
|
54
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
55
|
+
Rails/Date:
|
56
|
+
Exclude:
|
57
|
+
- 'test/fixtures/poro.rb'
|
58
|
+
|
59
|
+
# Offense count: 8
|
60
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
61
|
+
Rails/TimeZone:
|
62
|
+
Exclude:
|
63
|
+
- 'test/action_controller/serialization_test.rb'
|
64
|
+
- 'test/fixtures/poro.rb'
|
65
|
+
- 'test/serializers/cache_test.rb'
|
66
|
+
|
67
|
+
# Offense count: 16
|
68
|
+
# Cop supports --auto-correct.
|
69
|
+
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
|
70
|
+
Style/AlignHash:
|
71
|
+
Exclude:
|
72
|
+
- 'test/action_controller/json_api/pagination_test.rb'
|
73
|
+
|
74
|
+
# Offense count: 1
|
75
|
+
# Cop supports --auto-correct.
|
76
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
77
|
+
Style/AndOr:
|
78
|
+
Exclude:
|
79
|
+
- 'lib/active_model/serializer/lint.rb'
|
80
|
+
|
81
|
+
# Offense count: 6
|
82
|
+
# Cop supports --auto-correct.
|
83
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
84
|
+
Style/BlockDelimiters:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
# Offense count: 46
|
88
|
+
# Cop supports --auto-correct.
|
89
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
90
|
+
Style/BracesAroundHashParameters:
|
91
|
+
Exclude:
|
92
|
+
- 'test/action_controller/adapter_selector_test.rb'
|
93
|
+
- 'test/action_controller/json_api/pagination_test.rb'
|
94
|
+
- 'test/action_controller/serialization_test.rb'
|
95
|
+
- 'test/adapter/json_api/linked_test.rb'
|
96
|
+
- 'test/adapter/json_api/pagination_links_test.rb'
|
97
|
+
- 'test/adapter/null_test.rb'
|
98
|
+
- 'test/adapter_test.rb'
|
99
|
+
- 'test/array_serializer_test.rb'
|
100
|
+
- 'test/serializable_resource_test.rb'
|
101
|
+
- 'test/serializers/associations_test.rb'
|
102
|
+
- 'test/serializers/attribute_test.rb'
|
103
|
+
- 'test/serializers/attributes_test.rb'
|
104
|
+
- 'test/serializers/fieldset_test.rb'
|
105
|
+
- 'test/serializers/root_test.rb'
|
106
|
+
- 'test/serializers/urls_test.rb'
|
107
|
+
|
108
|
+
# Offense count: 167
|
109
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
110
|
+
Style/ClassAndModuleChildren:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
# Offense count: 5
|
114
|
+
# Cop supports --auto-correct.
|
115
|
+
Style/CommentIndentation:
|
116
|
+
Exclude:
|
117
|
+
- 'active_model_serializers.gemspec'
|
118
|
+
|
119
|
+
# Offense count: 1
|
120
|
+
Style/DoubleNegation:
|
121
|
+
Exclude:
|
122
|
+
- 'lib/active_model/serializable_resource.rb'
|
123
|
+
|
124
|
+
# Offense count: 1
|
125
|
+
Style/EachWithObject:
|
126
|
+
Exclude:
|
127
|
+
- 'lib/active_model/serializer/fieldset.rb'
|
128
|
+
|
129
|
+
# Offense count: 3
|
130
|
+
# Configuration parameters: MinBodyLength.
|
131
|
+
Style/GuardClause:
|
132
|
+
Exclude:
|
133
|
+
- 'lib/active_model/serializer.rb'
|
134
|
+
- 'lib/active_model/serializer/adapter/json_api.rb'
|
135
|
+
- 'test/capture_warnings.rb'
|
136
|
+
|
137
|
+
# Offense count: 12
|
138
|
+
# Cop supports --auto-correct.
|
139
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
140
|
+
Style/HashSyntax:
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
# Offense count: 9
|
144
|
+
# Cop supports --auto-correct.
|
145
|
+
Style/IndentArray:
|
146
|
+
Exclude:
|
147
|
+
- 'test/adapter/json/has_many_test.rb'
|
148
|
+
- 'test/adapter/json_api/json_api_test.rb'
|
149
|
+
- 'test/adapter/json_api/pagination_links_test.rb'
|
150
|
+
- 'test/adapter/json_test.rb'
|
151
|
+
|
152
|
+
# Offense count: 8
|
153
|
+
# Cop supports --auto-correct.
|
154
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
155
|
+
Style/IndentHash:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
# Offense count: 1
|
159
|
+
# Cop supports --auto-correct.
|
160
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
161
|
+
Style/IndentationConsistency:
|
162
|
+
Exclude:
|
163
|
+
- 'test/action_controller/serialization_scope_name_test.rb'
|
164
|
+
|
165
|
+
# Offense count: 2
|
166
|
+
# Cop supports --auto-correct.
|
167
|
+
# Configuration parameters: Width.
|
168
|
+
Style/IndentationWidth:
|
169
|
+
Exclude:
|
170
|
+
- 'lib/active_model/serializable_resource.rb'
|
171
|
+
- 'lib/active_model/serializer/fieldset.rb'
|
172
|
+
|
173
|
+
# Offense count: 1
|
174
|
+
# Cop supports --auto-correct.
|
175
|
+
Style/Lambda:
|
176
|
+
Exclude:
|
177
|
+
- 'lib/active_model/serializer.rb'
|
178
|
+
|
179
|
+
# Offense count: 2
|
180
|
+
# Cop supports --auto-correct.
|
181
|
+
Style/MethodCallParentheses:
|
182
|
+
Exclude:
|
183
|
+
- 'lib/active_model/serializer/adapter/json.rb'
|
184
|
+
- 'lib/active_model/serializer/adapter/json_api.rb'
|
185
|
+
|
186
|
+
# Offense count: 1
|
187
|
+
# Cop supports --auto-correct.
|
188
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
189
|
+
Style/MethodDefParentheses:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# Offense count: 3
|
193
|
+
# Cop supports --auto-correct.
|
194
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
195
|
+
Style/MultilineOperationIndentation:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
# Offense count: 1
|
199
|
+
# Cop supports --auto-correct.
|
200
|
+
Style/NegatedIf:
|
201
|
+
Exclude:
|
202
|
+
- 'lib/action_controller/serialization.rb'
|
203
|
+
|
204
|
+
# Offense count: 1
|
205
|
+
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
206
|
+
Style/Next:
|
207
|
+
Exclude:
|
208
|
+
- 'lib/active_model/serializer/adapter/json_api.rb'
|
209
|
+
|
210
|
+
# Offense count: 1
|
211
|
+
# Cop supports --auto-correct.
|
212
|
+
Style/NumericLiterals:
|
213
|
+
MinDigits: 7
|
214
|
+
|
215
|
+
# Offense count: 2
|
216
|
+
# Cop supports --auto-correct.
|
217
|
+
# Configuration parameters: PreferredDelimiters.
|
218
|
+
Style/PercentLiteralDelimiters:
|
219
|
+
Exclude:
|
220
|
+
- 'active_model_serializers.gemspec'
|
221
|
+
|
222
|
+
# Offense count: 2
|
223
|
+
# Cop supports --auto-correct.
|
224
|
+
Style/PerlBackrefs:
|
225
|
+
Exclude:
|
226
|
+
- 'test/fixtures/poro.rb'
|
227
|
+
- 'test/serializers/associations_test.rb'
|
228
|
+
|
229
|
+
# Offense count: 6
|
230
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
|
231
|
+
Style/PredicateName:
|
232
|
+
Exclude:
|
233
|
+
- 'lib/active_model/serializer/adapter.rb'
|
234
|
+
- 'lib/active_model/serializer/adapter/json_api.rb'
|
235
|
+
- 'lib/active_model/serializer/associations.rb'
|
236
|
+
- 'test/action_controller/json_api/linked_test.rb'
|
237
|
+
|
238
|
+
# Offense count: 7
|
239
|
+
# Cop supports --auto-correct.
|
240
|
+
Style/RedundantSelf:
|
241
|
+
Exclude:
|
242
|
+
- 'lib/active_model/serializer.rb'
|
243
|
+
- 'lib/active_model/serializer/associations.rb'
|
244
|
+
- 'test/fixtures/poro.rb'
|
245
|
+
|
246
|
+
# Offense count: 1
|
247
|
+
# Cop supports --auto-correct.
|
248
|
+
# Configuration parameters: AllowAsExpressionSeparator.
|
249
|
+
Style/Semicolon:
|
250
|
+
Exclude:
|
251
|
+
- 'lib/active_model/serializer/fieldset.rb'
|
252
|
+
|
253
|
+
# Offense count: 6
|
254
|
+
# Cop supports --auto-correct.
|
255
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
256
|
+
Style/SignalException:
|
257
|
+
Exclude:
|
258
|
+
- 'lib/active_model/serializer.rb'
|
259
|
+
- 'lib/active_model/serializer/adapter.rb'
|
260
|
+
- 'lib/active_model/serializer/fieldset.rb'
|
261
|
+
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
262
|
+
|
263
|
+
# Offense count: 1
|
264
|
+
# Cop supports --auto-correct.
|
265
|
+
# Configuration parameters: AllowIfMethodIsEmpty.
|
266
|
+
Style/SingleLineMethods:
|
267
|
+
Exclude:
|
268
|
+
- 'test/serializers/serializer_for_test.rb'
|
269
|
+
|
270
|
+
# Offense count: 2
|
271
|
+
# Cop supports --auto-correct.
|
272
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
273
|
+
Style/StringLiteralsInInterpolation:
|
274
|
+
Enabled: false
|
275
|
+
|
276
|
+
# Offense count: 1
|
277
|
+
Style/StructInheritance:
|
278
|
+
Exclude:
|
279
|
+
- 'bench/perf.rb'
|
280
|
+
|
281
|
+
# Offense count: 1
|
282
|
+
# Cop supports --auto-correct.
|
283
|
+
# Configuration parameters: IgnoredMethods.
|
284
|
+
Style/SymbolProc:
|
285
|
+
Exclude:
|
286
|
+
- 'lib/generators/serializer/serializer_generator.rb'
|
287
|
+
|
288
|
+
# Offense count: 8
|
289
|
+
# Cop supports --auto-correct.
|
290
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
291
|
+
Style/TrailingBlankLines:
|
292
|
+
Exclude:
|
293
|
+
- 'lib/active_model/serializer/pass_through_serializer.rb'
|
294
|
+
- 'lib/generators/serializer/serializer_generator.rb'
|
295
|
+
- 'test/adapter/fragment_cache_test.rb'
|
296
|
+
- 'test/adapter/json_api/json_api_test.rb'
|
297
|
+
- 'test/adapter/null_test.rb'
|
298
|
+
- 'test/serializers/cache_test.rb'
|
299
|
+
- 'test/serializers/fieldset_test.rb'
|
300
|
+
- 'test/support/stream_capture.rb'
|
301
|
+
|
302
|
+
# Offense count: 6
|
303
|
+
# Cop supports --auto-correct.
|
304
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
305
|
+
Style/TrailingComma:
|
306
|
+
Exclude:
|
307
|
+
- 'test/action_controller/adapter_selector_test.rb'
|
308
|
+
- 'test/action_controller/serialization_test.rb'
|
309
|
+
- 'test/adapter/json_api/belongs_to_test.rb'
|
310
|
+
- 'test/adapter/json_api/linked_test.rb'
|
311
|
+
|
312
|
+
# Offense count: 1
|
313
|
+
Style/UnlessElse:
|
314
|
+
Exclude:
|
315
|
+
- 'lib/active_model/serializer.rb'
|
data/.simplecov
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config
|
2
|
+
# see https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb
|
3
|
+
# vim: set ft=ruby
|
4
|
+
|
5
|
+
## DEFINE VARIABLES
|
6
|
+
@minimum_coverage = ENV.fetch('COVERAGE_MINIMUM') {
|
7
|
+
case (defined?(RUBY_ENGINE) && RUBY_ENGINE) || "ruby"
|
8
|
+
when 'jruby', 'rbx'
|
9
|
+
96.0
|
10
|
+
else
|
11
|
+
98.1
|
12
|
+
end
|
13
|
+
}.to_f.round(2)
|
14
|
+
# rubocop:disable Style/DoubleNegation
|
15
|
+
ENV['FULL_BUILD'] ||= ENV['CI']
|
16
|
+
@running_ci = !!(ENV['FULL_BUILD'] =~ /\Atrue\z/i)
|
17
|
+
@generate_report = @running_ci || !!(ENV['COVERAGE'] =~ /\Atrue\z/i)
|
18
|
+
@output = STDOUT
|
19
|
+
# rubocop:enable Style/DoubleNegation
|
20
|
+
|
21
|
+
## CONFIGURE SIMPLECOV
|
22
|
+
SimpleCov.pid = $$ # In case there's any forking
|
23
|
+
|
24
|
+
SimpleCov.profiles.define 'app' do
|
25
|
+
coverage_dir 'coverage'
|
26
|
+
load_profile 'test_frameworks'
|
27
|
+
|
28
|
+
add_group 'Libraries', 'lib'
|
29
|
+
|
30
|
+
add_group 'Long files' do |src_file|
|
31
|
+
src_file.lines.count > 100
|
32
|
+
end
|
33
|
+
class MaxLinesFilter < SimpleCov::Filter
|
34
|
+
def matches?(source_file)
|
35
|
+
source_file.lines.count < filter_argument
|
36
|
+
end
|
37
|
+
end
|
38
|
+
add_group 'Short files', MaxLinesFilter.new(5)
|
39
|
+
|
40
|
+
# Exclude these paths from analysis
|
41
|
+
add_filter '/config/'
|
42
|
+
add_filter '/db/'
|
43
|
+
add_filter 'tasks'
|
44
|
+
end
|
45
|
+
|
46
|
+
## START TRACKING COVERAGE (before activating SimpleCov)
|
47
|
+
require 'coverage'
|
48
|
+
Coverage.start
|
49
|
+
|
50
|
+
## ADD SOME CUSTOM REPORTING AT EXIT
|
51
|
+
SimpleCov.at_exit do
|
52
|
+
header = "#{'*' * 20} SimpleCov Results #{'*' * 20}"
|
53
|
+
@output.puts
|
54
|
+
@output.puts header
|
55
|
+
@output.puts SimpleCov.result.format!
|
56
|
+
percent = Float(SimpleCov.result.covered_percent)
|
57
|
+
if percent < @minimum_coverage
|
58
|
+
@output.puts "Spec coverage was not high enough: "\
|
59
|
+
"#{percent.round(2)} is < #{@minimum_coverage}%\n"
|
60
|
+
exit 1 if @generate_report
|
61
|
+
else
|
62
|
+
@output.puts "Nice job! Spec coverage (#{percent.round(2)}) "\
|
63
|
+
"is still at or above #{@minimum_coverage}%\n"
|
64
|
+
end
|
65
|
+
@output.puts
|
66
|
+
@output.puts '*' * header.size
|
67
|
+
end
|
68
|
+
|
69
|
+
## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start'
|
70
|
+
## to defer running until test/test_helper.rb is loaded.
|
71
|
+
# rubocop:disable Style/MultilineBlockChain
|
72
|
+
AppCoverage = Class.new do
|
73
|
+
def initialize(&block)
|
74
|
+
@block = block
|
75
|
+
end
|
76
|
+
|
77
|
+
def start
|
78
|
+
@block.call
|
79
|
+
end
|
80
|
+
end.new do
|
81
|
+
SimpleCov.start 'app'
|
82
|
+
if @generate_report
|
83
|
+
if @running_ci
|
84
|
+
require 'codeclimate-test-reporter'
|
85
|
+
@output.puts '[COVERAGE] Running with SimpleCov Simple Formatter and CodeClimate Test Reporter'
|
86
|
+
formatters = [
|
87
|
+
SimpleCov::Formatter::SimpleFormatter,
|
88
|
+
CodeClimate::TestReporter::Formatter
|
89
|
+
]
|
90
|
+
else
|
91
|
+
@output.puts '[COVERAGE] Running with SimpleCov HTML Formatter'
|
92
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
93
|
+
end
|
94
|
+
else
|
95
|
+
formatters = []
|
96
|
+
end
|
97
|
+
SimpleCov.formatters = formatters
|
98
|
+
end
|
99
|
+
# rubocop:enable Style/MultilineBlockChain
|
data/.travis.yml
CHANGED
@@ -1,28 +1,34 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
5
|
+
cache:
|
6
|
+
bundler: true
|
7
|
+
|
2
8
|
rvm:
|
3
|
-
- 1.8.7
|
4
|
-
- 1.9.2
|
5
9
|
- 1.9.3
|
6
10
|
- 2.0.0
|
7
|
-
-
|
8
|
-
-
|
11
|
+
- 2.1
|
12
|
+
- 2.2
|
9
13
|
- jruby-19mode
|
10
14
|
- rbx-2
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
- ruby-head
|
16
|
+
|
17
|
+
install:
|
18
|
+
- bundle install --retry=3
|
19
|
+
|
20
|
+
script:
|
21
|
+
- bundle exec rake
|
22
|
+
- bundle exec rake rubocop
|
23
|
+
|
24
|
+
env:
|
25
|
+
- "RAILS_VERSION=4.0"
|
26
|
+
- "RAILS_VERSION=4.1"
|
27
|
+
- "RAILS_VERSION=4.2"
|
28
|
+
- "RAILS_VERSION=master"
|
29
|
+
|
14
30
|
matrix:
|
15
31
|
allow_failures:
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
- gemfile: Gemfile.edge
|
20
|
-
rvm: 1.8.7
|
21
|
-
- gemfile: Gemfile.edge
|
22
|
-
rvm: 1.9.2
|
23
|
-
- gemfile: Gemfile.edge
|
24
|
-
rvm: ree
|
25
|
-
- gemfile: Gemfile.edge
|
26
|
-
rvm: jruby-18mode
|
27
|
-
- gemfile: Gemfile.edge
|
28
|
-
rvm: rbx-18mode
|
32
|
+
- rvm: ruby-head
|
33
|
+
- env: "RAILS_VERSION=master"
|
34
|
+
fast_finish: true
|
data/CHANGELOG.md
CHANGED
@@ -1,67 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
*
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*
|
10
|
-
|
11
|
-
*
|
12
|
-
|
13
|
-
*
|
14
|
-
|
15
|
-
many users do, so we've left it optional.
|
16
|
-
|
17
|
-
* Fixed a bug where ActionController wouldn't always have MimeResponds.
|
18
|
-
|
19
|
-
* An optinal caching feature allows you to cache JSON & hashes that AMS uses.
|
20
|
-
Adding 'cached true' to your Serializers will turn on this cache.
|
21
|
-
|
22
|
-
* URL helpers used inside of Engines now work properly.
|
23
|
-
|
24
|
-
* Serializers now can filter attributes with `only` and `except`:
|
25
|
-
|
26
|
-
```
|
27
|
-
UserSerializer.new(user, only: [:first_name, :last_name])
|
28
|
-
UserSerializer.new(user, except: :first_name)
|
29
|
-
```
|
30
|
-
|
31
|
-
* Basic Mongoid support. We now include our mixins in the right place.
|
32
|
-
|
33
|
-
* On Ruby 1.8, we now generate an `id` method that properly serializes `id`
|
34
|
-
columns. See issue #127 for more.
|
35
|
-
|
36
|
-
* Add an alias for `scope` method to be the name of the context. By default
|
37
|
-
this is `current_user`. The name is automatically set when using
|
38
|
-
`serialization_scope` in the controller.
|
39
|
-
|
40
|
-
* Pass through serialization options (such as `:include`) when a model
|
41
|
-
has no serializer defined.
|
42
|
-
|
43
|
-
# VERSION 0.7.0
|
44
|
-
|
45
|
-
* ```embed_key``` option to allow embedding by attributes other than IDs
|
46
|
-
* Fix rendering nil with custom serializer
|
47
|
-
* Fix global ```self.root = false```
|
48
|
-
* Add support for specifying the serializer for an association as a String
|
49
|
-
* Able to specify keys on the attributes method
|
50
|
-
* Serializer Reloading via ActiveSupport::DescendantsTracker
|
51
|
-
* Reduce double map to once; Fixes datamapper eager loading.
|
52
|
-
|
53
|
-
# VERSION 0.6.0
|
54
|
-
|
55
|
-
* Serialize sets properly
|
56
|
-
* Add root option to ArraySerializer
|
57
|
-
* Support polymorphic associations
|
58
|
-
* Support :each_serializer in ArraySerializer
|
59
|
-
* Add `scope` method to easily access the scope in the serializer
|
60
|
-
* Fix regression with Rails 3.2.6; add Rails 4 support
|
61
|
-
* Allow serialization_scope to be disabled with serialization_scope nil
|
62
|
-
* Array serializer should support pure ruby objects besides serializers
|
63
|
-
|
64
|
-
# VERSION 0.5.0 (May 16, 2012)
|
65
|
-
|
66
|
-
* First tagged version
|
67
|
-
* Changes generators to always generate an ApplicationSerializer
|
1
|
+
### 0.10.0
|
2
|
+
|
3
|
+
* adds adapters pattern
|
4
|
+
* adds support for `meta` and `meta_key` [@kurko]
|
5
|
+
* adds method to override association [@kurko]
|
6
|
+
* adds `has_one` attribute for backwards compatibility [@ggordon]
|
7
|
+
* adds JSON API support 1.0 [@benedikt]
|
8
|
+
* adds fragment cache support [@joaomdmoura]
|
9
|
+
* adds cache support to attributes and associations [@joaomdmoura]
|
10
|
+
* uses model name to determine the type [@lsylvester]
|
11
|
+
* remove root key option and split JSON adapter [@joaomdmoura]
|
12
|
+
* adds FlattenJSON as default adapter [@joaomdmoura]
|
13
|
+
* adds support for `pagination links` at top level of JsonApi adapter [@bacarini]
|
14
|
+
* adds extended format for `include` option to JSONAPI adapter [@beauby]
|