cheap_ams 0.10.5 → 0.10.6

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +49 -0
  3. data/.rubocop_todo.yml +315 -0
  4. data/.simplecov +99 -0
  5. data/.travis.yml +8 -0
  6. data/Gemfile +10 -1
  7. data/README.md +4 -16
  8. data/Rakefile +29 -2
  9. data/cheap_ams.gemspec +3 -2
  10. data/docs/README.md +1 -0
  11. data/docs/general/configuration_options.md +11 -0
  12. data/lib/action_controller/serialization.rb +2 -2
  13. data/lib/active_model/serializable_resource.rb +0 -2
  14. data/lib/active_model/serializer/adapter/fragment_cache.rb +3 -4
  15. data/lib/active_model/serializer/adapter/json/fragment_cache.rb +0 -2
  16. data/lib/active_model/serializer/adapter/json.rb +0 -1
  17. data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +2 -4
  18. data/lib/active_model/serializer/adapter/json_api.rb +87 -93
  19. data/lib/active_model/serializer/adapter.rb +4 -4
  20. data/lib/active_model/serializer/array_serializer.rb +11 -12
  21. data/lib/active_model/serializer/association.rb +0 -1
  22. data/lib/active_model/serializer/fieldset.rb +2 -4
  23. data/lib/active_model/serializer/lint.rb +2 -4
  24. data/lib/active_model/serializer/version.rb +1 -1
  25. data/lib/active_model/serializer.rb +0 -25
  26. data/lib/active_model_serializers.rb +0 -1
  27. data/lib/generators/serializer/serializer_generator.rb +7 -7
  28. data/lib/generators/serializer/templates/{serializer.rb → serializer.rb.erb} +0 -0
  29. data/lib/tasks/rubocop.rake +0 -0
  30. data/test/action_controller/adapter_selector_test.rb +3 -3
  31. data/test/action_controller/explicit_serializer_test.rb +9 -9
  32. data/test/action_controller/json_api/linked_test.rb +28 -28
  33. data/test/action_controller/json_api/pagination_test.rb +24 -24
  34. data/test/action_controller/serialization_test.rb +73 -79
  35. data/test/adapter/fragment_cache_test.rb +2 -2
  36. data/test/adapter/json/belongs_to_test.rb +4 -4
  37. data/test/adapter/json/collection_test.rb +15 -15
  38. data/test/adapter/json/has_many_test.rb +5 -5
  39. data/test/adapter/json_api/belongs_to_test.rb +37 -37
  40. data/test/adapter/json_api/collection_test.rb +22 -23
  41. data/test/adapter/json_api/has_many_embed_ids_test.rb +2 -2
  42. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +4 -4
  43. data/test/adapter/json_api/has_many_test.rb +25 -25
  44. data/test/adapter/json_api/has_one_test.rb +10 -10
  45. data/test/adapter/json_api/json_api_test.rb +6 -7
  46. data/test/adapter/json_api/linked_test.rb +69 -69
  47. data/test/adapter/json_api/pagination_links_test.rb +8 -8
  48. data/test/adapter/json_api/resource_type_config_test.rb +14 -14
  49. data/test/adapter/json_test.rb +7 -7
  50. data/test/adapter_test.rb +2 -2
  51. data/test/array_serializer_test.rb +11 -7
  52. data/test/capture_warnings.rb +8 -7
  53. data/test/fixtures/active_record.rb +0 -1
  54. data/test/fixtures/poro.rb +7 -12
  55. data/test/generators/scaffold_controller_generator_test.rb +1 -2
  56. data/test/generators/serializer_generator_test.rb +10 -10
  57. data/test/lint_test.rb +0 -7
  58. data/test/serializers/adapter_for_test.rb +0 -1
  59. data/test/serializers/associations_test.rb +4 -4
  60. data/test/serializers/attribute_test.rb +7 -7
  61. data/test/serializers/attributes_test.rb +8 -14
  62. data/test/serializers/cache_test.rb +8 -7
  63. data/test/serializers/fieldset_test.rb +3 -4
  64. data/test/serializers/meta_test.rb +23 -23
  65. data/test/serializers/root_test.rb +1 -3
  66. data/test/serializers/serializer_for_test.rb +1 -1
  67. data/test/support/serialization_testing.rb +13 -0
  68. data/test/support/simplecov.rb +6 -0
  69. data/test/support/stream_capture.rb +2 -2
  70. data/test/test_helper.rb +14 -2
  71. metadata +13 -6
  72. data/test/serializers/urls_test.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5643a60ddfc5ccd9d47234e8fe013a28cdbd084
4
- data.tar.gz: 45d1854982df42bd7cf35be0853bf41e0c37a30d
3
+ metadata.gz: bacc6451ac77d1740a76023d37025b72e83dc758
4
+ data.tar.gz: 4c34c52e8871b663c994862f13eb1d6dfd459f51
5
5
  SHA512:
6
- metadata.gz: 4d8160cb879e7b600352563761855e507edc435b3343948ce4e47645c5ed1d7ef7b68d622596e35178bddbe572bdd206bb77d3b6dd0edcbf9e4833e2caa9bc46
7
- data.tar.gz: 99aeb8386164dd14723662669e2d52c157e67c0b20020df43a85bd31eedbb526a7f323f65237a502e2d9c1a59783a00124706529be3aa49093b4436855b0b7ef
6
+ metadata.gz: 21b1ac7c84fc65eb0122bcd001797e78bd6bf1ca7e6a5f851ff464a9b2472024ddff2ac6fb9ec623d2f064f719e07bb5a8cfab8d2d5e91b3a235b4a5991d1539
7
+ data.tar.gz: 5a9abdae7b843688e75db24c2b1428b9a927a83758237b8f8499e7640faf8ed86982bfb07630a911dd2fae06d3f6d83ab7de0bdff8cf4f4886e7395f9076ec02
data/.rubocop.yml ADDED
@@ -0,0 +1,49 @@
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
+ Lint/NestedMethodDefinition:
12
+ Enabled: false
13
+ Exclude:
14
+ - test/action_controller/serialization_test.rb
15
+
16
+ Style/StringLiterals:
17
+ EnforcedStyle: single_quotes
18
+
19
+ Metrics/AbcSize:
20
+ Max: 35 # TODO: Lower to 15
21
+
22
+ Metrics/ClassLength:
23
+ Max: 261 # TODO: Lower to 100
24
+ Exclude:
25
+ - test/**/*.rb
26
+
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 7 # TODO: Lower to 6
29
+
30
+ Metrics/LineLength:
31
+ Max: 251 # TODO: Lower to 80
32
+
33
+ Metrics/MethodLength:
34
+ Max: 106 # TODO: Lower to 10
35
+
36
+ Metrics/PerceivedComplexity:
37
+ Max: 9 # TODO: Lower to 7
38
+
39
+ Style/AlignParameters:
40
+ EnforcedStyle: with_fixed_indentation
41
+
42
+ Style/ClassAndModuleChildren:
43
+ EnforcedStyle: compact
44
+
45
+ Style/Documentation:
46
+ Enabled: false
47
+
48
+ Style/MultilineOperationIndentation:
49
+ 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.3
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
@@ -2,6 +2,9 @@ language: ruby
2
2
 
3
3
  sudo: false
4
4
 
5
+ cache:
6
+ bundler: true
7
+
5
8
  rvm:
6
9
  - 1.9.3
7
10
  - 2.0.0
@@ -14,6 +17,10 @@ rvm:
14
17
  install:
15
18
  - bundle install --retry=3
16
19
 
20
+ script:
21
+ - bundle exec rake
22
+ - bundle exec rake rubocop
23
+
17
24
  env:
18
25
  - "RAILS_VERSION=4.0"
19
26
  - "RAILS_VERSION=4.1"
@@ -24,3 +31,4 @@ matrix:
24
31
  allow_failures:
25
32
  - rvm: ruby-head
26
33
  - env: "RAILS_VERSION=master"
34
+ fast_finish: true
data/Gemfile CHANGED
@@ -27,9 +27,18 @@ end
27
27
 
28
28
  group :test do
29
29
  gem 'activerecord'
30
- gem 'sqlite3', platform: :ruby
30
+ gem 'sqlite3', platform: [:ruby, :mingw, :x64_mingw, :mswin]
31
31
  gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
32
+ gem 'codeclimate-test-reporter', require: false
33
+ end
34
+
35
+ group :test, :development do
36
+ gem 'simplecov', '~> 0.10', require: false
32
37
  end
33
38
 
34
39
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
35
40
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
41
+
42
+ group :development, :test do
43
+ gem 'rubocop', '~> 0.34.0', require: false
44
+ end
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # ActiveModel::Serializer
2
2
 
3
- [![Build Status](https://travis-ci.org/rails-api/active_model_serializers.svg)](https://travis-ci.org/rails-api/active_model_serializers)
3
+ [![Build Status](https://travis-ci.org/rails-api/active_model_serializers.svg)](https://travis-ci.org/rails-api/active_model_serializers)
4
+ <a href="https://codeclimate.com/github/rails-api/active_model_serializers"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/gpa.svg" /></a>
5
+ <a href="https://codeclimate.com/github/rails-api/active_model_serializers/coverage"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/coverage.svg" /></a>
4
6
 
5
- _Windows Build Status -_ ![Build Status](https://ci.appveyor.com/api/projects/status/1dly7uj4l69bchmu)
7
+ _Windows Build Status -_ [![Build status](https://ci.appveyor.com/api/projects/status/x6xdjydutm54gvyt/branch/master?svg=true)](https://ci.appveyor.com/project/joaomdmoura/active-model-serializers/branch/master)
6
8
 
7
9
  ActiveModel::Serializer brings convention over configuration to your JSON generation.
8
10
 
@@ -34,8 +36,6 @@ class PostSerializer < ActiveModel::Serializer
34
36
  attributes :title, :body
35
37
 
36
38
  has_many :comments
37
-
38
- url :post
39
39
  end
40
40
  ```
41
41
 
@@ -46,8 +46,6 @@ class CommentSerializer < ActiveModel::Serializer
46
46
  attributes :name, :body
47
47
 
48
48
  belongs_to :post
49
-
50
- url [:post, :comment]
51
49
  end
52
50
  ```
53
51
 
@@ -237,8 +235,6 @@ class PostSerializer < ActiveModel::Serializer
237
235
 
238
236
  has_many :comments
239
237
  has_one :author
240
-
241
- url :post
242
238
  end
243
239
  ```
244
240
 
@@ -249,8 +245,6 @@ class CommentSerializer < ActiveModel::Serializer
249
245
  attributes :name, :body
250
246
 
251
247
  belongs_to :post_id
252
-
253
- url [:post, :comment]
254
248
  end
255
249
  ```
256
250
 
@@ -272,8 +266,6 @@ And you can change the JSON key that the serializer should use for a particular
272
266
  has_many :comments, key: :reviews
273
267
  ```
274
268
 
275
- The `url` declaration describes which named routes to use while generating URLs
276
- for your JSON. Not every adapter will require URLs.
277
269
  ## Pagination
278
270
 
279
271
  Pagination links will be included in your response automatically as long as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate) and if you are using a ```JSON-API``` adapter.
@@ -305,8 +297,6 @@ class PostSerializer < ActiveModel::Serializer
305
297
  attributes :title, :body
306
298
 
307
299
  has_many :comments
308
-
309
- url :post
310
300
  end
311
301
  ```
312
302
 
@@ -330,8 +320,6 @@ class PostSerializer < ActiveModel::Serializer
330
320
  attributes :title, :body
331
321
 
332
322
  has_many :comments
333
-
334
- url :post
335
323
  end
336
324
  ```
337
325
 
data/Rakefile CHANGED
@@ -1,9 +1,36 @@
1
- require "bundler/gem_tasks"
1
+ begin
2
+ require 'simplecov'
3
+ rescue LoadError
4
+ end
5
+
6
+ require 'bundler/gem_tasks'
7
+
8
+ begin
9
+ require 'rubocop'
10
+ require 'rubocop/rake_task'
11
+ rescue LoadError
12
+ else
13
+ Rake::Task[:rubocop].clear if Rake::Task.task_defined?(:rubocop)
14
+ if !defined?(::Rubinius)
15
+ Rake::Task[:rubocop].clear if Rake::Task.task_defined?(:rubocop)
16
+ desc 'Execute rubocop'
17
+ RuboCop::RakeTask.new(:rubocop) do |task|
18
+ task.options = ['--rails', '--display-cop-names', '--display-style-guide']
19
+ task.fail_on_error = true
20
+ end
21
+ else
22
+ desc 'No-op rubocop to avoid rbx segfault'
23
+ task :rubocop do
24
+ puts 'Skipping rubocop on rbx due to segfault'
25
+ puts 'https://github.com/rubinius/rubinius/issues/3499'
26
+ end
27
+ end
28
+ end
2
29
 
3
30
  require 'rake/testtask'
4
31
 
5
32
  Rake::TestTask.new do |t|
6
- t.libs << "test"
33
+ t.libs << 'test'
7
34
  t.test_files = FileList['test/**/*_test.rb']
8
35
  t.ruby_opts = ['-r./test/test_helper.rb']
9
36
  t.verbose = true
data/cheap_ams.gemspec CHANGED
@@ -9,8 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.platform = Gem::Platform::RUBY
10
10
  spec.authors = ['Steve Klabnik']
11
11
  spec.email = ['steve@steveklabnik.com']
12
- spec.summary = %q{Conventions-based JSON generation for Rails.}
13
- spec.description = %q{ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.}
12
+ spec.summary = 'Conventions-based JSON generation for Rails.'
13
+ spec.description = 'ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.'
14
+ spec.homepage = 'https://github.com/rails-api/active_model_serializers'
14
15
  spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
data/docs/README.md CHANGED
@@ -8,6 +8,7 @@ This is the documentation of AMS, it's focused on the **0.10.x version.**
8
8
 
9
9
  - [Getting Started](general/getting_started.md)
10
10
  - [Adapters](general/adapters.md)
11
+ - [Configuration Options](general/configuration_options.md)
11
12
 
12
13
  ## How to
13
14
 
@@ -0,0 +1,11 @@
1
+ # Configuration Options
2
+
3
+ The following configuration options can be set on `ActiveModel::Serializer.config` inside an initializer.
4
+
5
+ ## General
6
+
7
+ - `adapter`: The [adapter](adapters.md) to use. Possible values: `:flatten_json, :json, :json_api`. Default: `:flatten_json`.
8
+
9
+ ## JSON API
10
+
11
+ - `jsonapi_resource_type`: Whether the `type` attributes of resources should be singular or plural. Possible values: `:singular, :plural`. Default: `:plural`.
@@ -17,8 +17,8 @@ module ActionController
17
17
  end
18
18
 
19
19
  def get_serializer(resource, options = {})
20
- if ! use_adapter?
21
- warn "ActionController::Serialization#use_adapter? has been removed. "\
20
+ if !use_adapter?
21
+ warn 'ActionController::Serialization#use_adapter? has been removed. '\
22
22
  "Please pass 'adapter: false' or see ActiveSupport::SerializableResource#serialize"
23
23
  options[:adapter] = false
24
24
  end