active_model_serializers 0.8.3 → 0.10.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +29 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +15 -0
  4. data/.gitignore +7 -0
  5. data/.rubocop.yml +104 -0
  6. data/.rubocop_todo.yml +167 -0
  7. data/.simplecov +110 -0
  8. data/.travis.yml +46 -23
  9. data/CHANGELOG.md +442 -6
  10. data/CONTRIBUTING.md +95 -0
  11. data/Gemfile +51 -1
  12. data/{MIT-LICENSE.txt → MIT-LICENSE} +3 -2
  13. data/README.md +102 -590
  14. data/Rakefile +93 -8
  15. data/active_model_serializers.gemspec +65 -23
  16. data/appveyor.yml +28 -0
  17. data/bin/bench +171 -0
  18. data/bin/bench_regression +316 -0
  19. data/bin/serve_benchmark +39 -0
  20. data/docs/ARCHITECTURE.md +126 -0
  21. data/docs/README.md +39 -0
  22. data/docs/STYLE.md +58 -0
  23. data/docs/general/adapters.md +245 -0
  24. data/docs/general/caching.md +52 -0
  25. data/docs/general/configuration_options.md +100 -0
  26. data/docs/general/deserialization.md +100 -0
  27. data/docs/general/getting_started.md +133 -0
  28. data/docs/general/instrumentation.md +40 -0
  29. data/docs/general/key_transforms.md +40 -0
  30. data/docs/general/logging.md +14 -0
  31. data/docs/general/rendering.md +255 -0
  32. data/docs/general/serializers.md +339 -0
  33. data/docs/how-open-source-maintained.jpg +0 -0
  34. data/docs/howto/add_pagination_links.md +139 -0
  35. data/docs/howto/add_root_key.md +51 -0
  36. data/docs/howto/outside_controller_use.md +58 -0
  37. data/docs/howto/passing_arbitrary_options.md +27 -0
  38. data/docs/howto/test.md +152 -0
  39. data/docs/integrations/ember-and-json-api.md +112 -0
  40. data/docs/integrations/grape.md +19 -0
  41. data/docs/jsonapi/errors.md +56 -0
  42. data/docs/jsonapi/schema/schema.json +366 -0
  43. data/docs/jsonapi/schema.md +151 -0
  44. data/docs/rfcs/0000-namespace.md +106 -0
  45. data/docs/rfcs/template.md +15 -0
  46. data/lib/action_controller/serialization.rb +31 -36
  47. data/lib/active_model/serializable_resource.rb +11 -0
  48. data/lib/active_model/serializer/adapter/attributes.rb +15 -0
  49. data/lib/active_model/serializer/adapter/base.rb +16 -0
  50. data/lib/active_model/serializer/adapter/json.rb +15 -0
  51. data/lib/active_model/serializer/adapter/json_api.rb +15 -0
  52. data/lib/active_model/serializer/adapter/null.rb +15 -0
  53. data/lib/active_model/serializer/adapter.rb +24 -0
  54. data/lib/active_model/serializer/array_serializer.rb +9 -0
  55. data/lib/active_model/serializer/association.rb +19 -0
  56. data/lib/active_model/serializer/associations.rb +87 -220
  57. data/lib/active_model/serializer/attribute.rb +25 -0
  58. data/lib/active_model/serializer/attributes.rb +82 -0
  59. data/lib/active_model/serializer/belongs_to_reflection.rb +10 -0
  60. data/lib/active_model/serializer/caching.rb +151 -0
  61. data/lib/active_model/serializer/collection_reflection.rb +7 -0
  62. data/lib/active_model/serializer/collection_serializer.rb +64 -0
  63. data/lib/active_model/serializer/configuration.rb +35 -0
  64. data/lib/active_model/serializer/error_serializer.rb +10 -0
  65. data/lib/active_model/serializer/errors_serializer.rb +27 -0
  66. data/lib/active_model/serializer/field.rb +56 -0
  67. data/lib/active_model/serializer/fieldset.rb +31 -0
  68. data/lib/active_model/serializer/has_many_reflection.rb +10 -0
  69. data/lib/active_model/serializer/has_one_reflection.rb +10 -0
  70. data/lib/active_model/serializer/include_tree.rb +111 -0
  71. data/lib/active_model/serializer/links.rb +35 -0
  72. data/lib/active_model/serializer/lint.rb +156 -0
  73. data/lib/active_model/serializer/meta.rb +29 -0
  74. data/lib/active_model/serializer/null.rb +17 -0
  75. data/lib/active_model/serializer/reflection.rb +147 -0
  76. data/lib/active_model/serializer/singular_reflection.rb +7 -0
  77. data/lib/active_model/serializer/type.rb +25 -0
  78. data/lib/active_model/{serializers → serializer}/version.rb +1 -1
  79. data/lib/active_model/serializer.rb +156 -481
  80. data/lib/active_model_serializers/adapter/attributes.rb +94 -0
  81. data/lib/active_model_serializers/adapter/base.rb +90 -0
  82. data/lib/active_model_serializers/adapter/json.rb +11 -0
  83. data/lib/active_model_serializers/adapter/json_api/deserialization.rb +213 -0
  84. data/lib/active_model_serializers/adapter/json_api/error.rb +96 -0
  85. data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +49 -0
  86. data/lib/active_model_serializers/adapter/json_api/link.rb +83 -0
  87. data/lib/active_model_serializers/adapter/json_api/meta.rb +37 -0
  88. data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +57 -0
  89. data/lib/active_model_serializers/adapter/json_api/relationship.rb +52 -0
  90. data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +37 -0
  91. data/lib/active_model_serializers/adapter/json_api.rb +513 -0
  92. data/lib/active_model_serializers/adapter/null.rb +10 -0
  93. data/lib/active_model_serializers/adapter.rb +92 -0
  94. data/lib/active_model_serializers/cached_serializer.rb +87 -0
  95. data/lib/active_model_serializers/callbacks.rb +55 -0
  96. data/lib/active_model_serializers/deprecate.rb +55 -0
  97. data/lib/active_model_serializers/deserialization.rb +13 -0
  98. data/lib/active_model_serializers/fragment_cache.rb +118 -0
  99. data/lib/active_model_serializers/json_pointer.rb +14 -0
  100. data/lib/active_model_serializers/key_transform.rb +70 -0
  101. data/lib/active_model_serializers/logging.rb +122 -0
  102. data/lib/active_model_serializers/model.rb +49 -0
  103. data/lib/active_model_serializers/railtie.rb +46 -0
  104. data/lib/active_model_serializers/register_jsonapi_renderer.rb +64 -0
  105. data/lib/active_model_serializers/serializable_resource.rb +81 -0
  106. data/lib/active_model_serializers/serialization_context.rb +32 -0
  107. data/lib/active_model_serializers/test/schema.rb +103 -0
  108. data/lib/active_model_serializers/test/serializer.rb +125 -0
  109. data/lib/active_model_serializers/test.rb +7 -0
  110. data/lib/active_model_serializers.rb +34 -89
  111. data/lib/generators/rails/USAGE +6 -0
  112. data/lib/generators/rails/resource_override.rb +10 -0
  113. data/lib/generators/rails/serializer_generator.rb +36 -0
  114. data/lib/generators/rails/templates/serializer.rb.erb +8 -0
  115. data/lib/grape/active_model_serializers.rb +14 -0
  116. data/lib/grape/formatters/active_model_serializers.rb +15 -0
  117. data/lib/grape/helpers/active_model_serializers.rb +16 -0
  118. data/test/action_controller/adapter_selector_test.rb +53 -0
  119. data/test/action_controller/explicit_serializer_test.rb +134 -0
  120. data/test/action_controller/json/include_test.rb +167 -0
  121. data/test/action_controller/json_api/deserialization_test.rb +112 -0
  122. data/test/action_controller/json_api/errors_test.rb +41 -0
  123. data/test/action_controller/json_api/linked_test.rb +197 -0
  124. data/test/action_controller/json_api/pagination_test.rb +116 -0
  125. data/test/action_controller/json_api/transform_test.rb +180 -0
  126. data/test/action_controller/serialization_scope_name_test.rb +229 -0
  127. data/test/action_controller/serialization_test.rb +467 -0
  128. data/test/active_model_serializers/adapter_for_test.rb +208 -0
  129. data/test/active_model_serializers/cached_serializer_test.rb +80 -0
  130. data/test/active_model_serializers/fragment_cache_test.rb +34 -0
  131. data/test/active_model_serializers/json_pointer_test.rb +20 -0
  132. data/test/active_model_serializers/key_transform_test.rb +263 -0
  133. data/test/active_model_serializers/logging_test.rb +77 -0
  134. data/test/active_model_serializers/model_test.rb +9 -0
  135. data/test/active_model_serializers/railtie_test_isolated.rb +63 -0
  136. data/test/active_model_serializers/serialization_context_test_isolated.rb +58 -0
  137. data/test/active_model_serializers/test/schema_test.rb +128 -0
  138. data/test/active_model_serializers/test/serializer_test.rb +63 -0
  139. data/test/active_record_test.rb +9 -0
  140. data/test/adapter/deprecation_test.rb +100 -0
  141. data/test/adapter/json/belongs_to_test.rb +45 -0
  142. data/test/adapter/json/collection_test.rb +90 -0
  143. data/test/adapter/json/has_many_test.rb +45 -0
  144. data/test/adapter/json/transform_test.rb +93 -0
  145. data/test/adapter/json_api/belongs_to_test.rb +155 -0
  146. data/test/adapter/json_api/collection_test.rb +95 -0
  147. data/test/adapter/json_api/errors_test.rb +78 -0
  148. data/test/adapter/json_api/fields_test.rb +87 -0
  149. data/test/adapter/json_api/has_many_embed_ids_test.rb +43 -0
  150. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +96 -0
  151. data/test/adapter/json_api/has_many_test.rb +143 -0
  152. data/test/adapter/json_api/has_one_test.rb +79 -0
  153. data/test/adapter/json_api/json_api_test.rb +35 -0
  154. data/test/adapter/json_api/linked_test.rb +392 -0
  155. data/test/adapter/json_api/links_test.rb +93 -0
  156. data/test/adapter/json_api/pagination_links_test.rb +148 -0
  157. data/test/adapter/json_api/parse_test.rb +137 -0
  158. data/test/adapter/json_api/relationship_test.rb +161 -0
  159. data/test/adapter/json_api/relationships_test.rb +199 -0
  160. data/test/adapter/json_api/resource_identifier_test.rb +85 -0
  161. data/test/adapter/json_api/resource_meta_test.rb +100 -0
  162. data/test/adapter/json_api/toplevel_jsonapi_test.rb +82 -0
  163. data/test/adapter/json_api/transform_test.rb +500 -0
  164. data/test/adapter/json_api/type_test.rb +61 -0
  165. data/test/adapter/json_test.rb +45 -0
  166. data/test/adapter/null_test.rb +23 -0
  167. data/test/adapter/polymorphic_test.rb +72 -0
  168. data/test/adapter_test.rb +40 -0
  169. data/test/array_serializer_test.rb +35 -73
  170. data/test/benchmark/app.rb +65 -0
  171. data/test/benchmark/benchmarking_support.rb +67 -0
  172. data/test/benchmark/bm_caching.rb +117 -0
  173. data/test/benchmark/bm_transform.rb +34 -0
  174. data/test/benchmark/config.ru +3 -0
  175. data/test/benchmark/controllers.rb +77 -0
  176. data/test/benchmark/fixtures.rb +167 -0
  177. data/test/cache_test.rb +388 -0
  178. data/test/collection_serializer_test.rb +110 -0
  179. data/test/fixtures/active_record.rb +68 -0
  180. data/test/fixtures/poro.rb +254 -0
  181. data/test/generators/scaffold_controller_generator_test.rb +24 -0
  182. data/test/generators/serializer_generator_test.rb +57 -0
  183. data/test/grape_test.rb +82 -0
  184. data/test/include_tree/from_include_args_test.rb +26 -0
  185. data/test/include_tree/from_string_test.rb +94 -0
  186. data/test/include_tree/include_args_to_hash_test.rb +64 -0
  187. data/test/lint_test.rb +49 -0
  188. data/test/logger_test.rb +18 -0
  189. data/test/poro_test.rb +9 -0
  190. data/test/serializable_resource_test.rb +83 -0
  191. data/test/serializers/association_macros_test.rb +36 -0
  192. data/test/serializers/associations_test.rb +267 -0
  193. data/test/serializers/attribute_test.rb +123 -0
  194. data/test/serializers/attributes_test.rb +52 -0
  195. data/test/serializers/caching_configuration_test_isolated.rb +170 -0
  196. data/test/serializers/configuration_test.rb +32 -0
  197. data/test/serializers/fieldset_test.rb +14 -0
  198. data/test/serializers/meta_test.rb +198 -0
  199. data/test/serializers/options_test.rb +21 -0
  200. data/test/serializers/read_attribute_for_serialization_test.rb +79 -0
  201. data/test/serializers/root_test.rb +21 -0
  202. data/test/serializers/serialization_test.rb +55 -0
  203. data/test/serializers/serializer_for_test.rb +134 -0
  204. data/test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json +6 -0
  205. data/test/support/isolated_unit.rb +80 -0
  206. data/test/support/rails5_shims.rb +47 -0
  207. data/test/support/rails_app.rb +45 -0
  208. data/test/support/schemas/active_model_serializers/test/schema_test/my/index.json +6 -0
  209. data/test/support/schemas/active_model_serializers/test/schema_test/my/show.json +6 -0
  210. data/test/support/schemas/custom/show.json +7 -0
  211. data/test/support/schemas/hyper_schema.json +93 -0
  212. data/test/support/schemas/render_using_json_api.json +43 -0
  213. data/test/support/schemas/simple_json_pointers.json +10 -0
  214. data/test/support/serialization_testing.rb +53 -0
  215. data/test/test_helper.rb +51 -24
  216. metadata +456 -45
  217. data/DESIGN.textile +0 -586
  218. data/Gemfile.edge +0 -9
  219. data/bench/perf.rb +0 -43
  220. data/cruft.md +0 -19
  221. data/lib/active_model/array_serializer.rb +0 -104
  222. data/lib/active_record/serializer_override.rb +0 -16
  223. data/lib/generators/resource_override.rb +0 -13
  224. data/lib/generators/serializer/USAGE +0 -9
  225. data/lib/generators/serializer/serializer_generator.rb +0 -42
  226. data/lib/generators/serializer/templates/serializer.rb +0 -19
  227. data/test/association_test.rb +0 -592
  228. data/test/caching_test.rb +0 -96
  229. data/test/generators_test.rb +0 -85
  230. data/test/no_serialization_scope_test.rb +0 -34
  231. data/test/serialization_scope_name_test.rb +0 -67
  232. data/test/serialization_test.rb +0 -392
  233. data/test/serializer_support_test.rb +0 -51
  234. data/test/serializer_test.rb +0 -1465
  235. data/test/test_fakes.rb +0 -217
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94274a9d3a573ae8f656719aef33825cabb68673
4
- data.tar.gz: b1d614a90149ec109b67e963464c232d0b5ed3f1
3
+ metadata.gz: 79d558ff503a5d3d80c7e28d07fbad6858c87416
4
+ data.tar.gz: e1345a0b533ac95996f62e873366907377f8e175
5
5
  SHA512:
6
- metadata.gz: cc3140d1676014d8ce4aa0add253d247c55652a689cb83e7f7f7a71a81ae8d7c601fc5e2d261d415e243857a479a15156d0a84a67beb1c72475ef51c063cdfca
7
- data.tar.gz: cfc92ac9bb7dfca07cebdd32ef4a120aa5784cc7f1a6bfc8a65900b553be736b174b6bbf22fb7ebd55e8295ea1d118373245396e3c0ac883e954ab27e925bca2
6
+ metadata.gz: ded6c2f6e8a7bbe81543a4939ae02c255908697a3894556bc81b5c46cb21b81cf771370fc60a902d393391b0b3addd9a5018cf142a04ecf3752c2aa1dcab2292
7
+ data.tar.gz: 285de3be1603f3ad013da4813ff3a95528e99bf3b2b4f511e780cefb6babd8d9555b113a3eaca762400e64e941d2fc699de02a73745ff56d7365b9dc6c41957a
@@ -0,0 +1,29 @@
1
+ #### Expected behavior vs actual behavior
2
+
3
+
4
+
5
+ #### Steps to reproduce
6
+ *(e.g., detailed walkthrough, runnable script, example application)*
7
+
8
+
9
+
10
+ #### Environment
11
+
12
+ ActiveModelSerializers Version *(commit ref if not on tag)*:
13
+
14
+ Output of `ruby -e "puts RUBY_DESCRIPTION"`:
15
+
16
+ OS Type & Version:
17
+
18
+ Integrated application and version *(e.g., Rails, Grape, etc)*:
19
+
20
+
21
+ #### Backtrace
22
+ *(e.g., provide any applicable backtraces from your application)*
23
+
24
+
25
+
26
+ #### Additonal helpful information
27
+ *(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)*
28
+
29
+
@@ -0,0 +1,15 @@
1
+ #### Purpose
2
+
3
+
4
+ #### Changes
5
+
6
+
7
+ #### Caveats
8
+
9
+
10
+ #### Related GitHub issues
11
+
12
+
13
+ #### Additional helpful information
14
+
15
+
data/.gitignore CHANGED
@@ -4,15 +4,22 @@
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
24
+ vendor/bundle
25
+ tags
data/.rubocop.yml ADDED
@@ -0,0 +1,104 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.2
5
+ Exclude:
6
+ - config/initializers/forbidden_yaml.rb
7
+ - !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
8
+ DisplayCopNames: true
9
+ DisplayStyleGuide: true
10
+
11
+ Rails:
12
+ Enabled: true
13
+
14
+ Lint/NestedMethodDefinition:
15
+ Enabled: false
16
+ Exclude:
17
+ - test/action_controller/serialization_test.rb
18
+
19
+ Style/Alias:
20
+ EnforcedStyle: prefer_alias
21
+
22
+ Style/StringLiterals:
23
+ EnforcedStyle: single_quotes
24
+
25
+ Metrics/AbcSize:
26
+ Max: 35 # TODO: Lower to 15
27
+
28
+ Metrics/ClassLength:
29
+ Max: 261 # TODO: Lower to 100
30
+ Exclude:
31
+ - test/**/*.rb
32
+
33
+ Metrics/CyclomaticComplexity:
34
+ Max: 7 # TODO: Lower to 6
35
+
36
+ Metrics/LineLength:
37
+ Max: 251 # TODO: Lower to 80
38
+
39
+ Metrics/MethodLength:
40
+ Max: 106 # TODO: Lower to 10
41
+
42
+ Metrics/PerceivedComplexity:
43
+ Max: 9 # TODO: Lower to 7
44
+
45
+ Style/AlignParameters:
46
+ EnforcedStyle: with_fixed_indentation
47
+
48
+ Style/ClassAndModuleChildren:
49
+ EnforcedStyle: compact
50
+
51
+ Style/Documentation:
52
+ Enabled: false
53
+
54
+ Style/MissingElse:
55
+ Enabled: true
56
+ EnforcedStyle: case
57
+
58
+ Style/EmptyElse:
59
+ EnforcedStyle: empty
60
+
61
+ Style/MultilineOperationIndentation:
62
+ EnforcedStyle: indented
63
+
64
+ Style/BlockDelimiters:
65
+ Enabled: true
66
+ EnforcedStyle: line_count_based
67
+
68
+ Style/SignalException:
69
+ EnforcedStyle: semantic
70
+
71
+ Style/TrailingCommaInLiteral:
72
+ EnforcedStyleForMultiline: no_comma
73
+
74
+ Style/ConditionalAssignment:
75
+ Enabled: false
76
+
77
+ Style/DotPosition:
78
+ EnforcedStyle: leading
79
+
80
+ ########## test_helper.rb sanity
81
+ Style/EndBlock:
82
+ Exclude:
83
+ - test/test_helper.rb
84
+
85
+ Style/SpecialGlobalVars:
86
+ Exclude:
87
+ - test/test_helper.rb
88
+
89
+ Style/GlobalVars:
90
+ Exclude:
91
+ - test/test_helper.rb
92
+
93
+ Style/AndOr:
94
+ Exclude:
95
+ - test/test_helper.rb
96
+ - 'lib/active_model/serializer/lint.rb'
97
+
98
+ Style/Not:
99
+ Exclude:
100
+ - test/test_helper.rb
101
+
102
+ Style/ClassCheck:
103
+ Exclude:
104
+ - test/test_helper.rb
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,167 @@
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'
data/.simplecov ADDED
@@ -0,0 +1,110 @@
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
+
23
+ SimpleCov.profiles.define 'app' do
24
+ coverage_dir 'coverage'
25
+ load_profile 'test_frameworks'
26
+
27
+ add_group 'Libraries', 'lib'
28
+
29
+ add_group 'Long files' do |src_file|
30
+ src_file.lines.count > 100
31
+ end
32
+ class MaxLinesFilter < SimpleCov::Filter
33
+ def matches?(source_file)
34
+ source_file.lines.count < filter_argument
35
+ end
36
+ end
37
+ add_group 'Short files', MaxLinesFilter.new(5)
38
+
39
+ # Exclude these paths from analysis
40
+ add_filter '/config/'
41
+ add_filter '/db/'
42
+ add_filter 'tasks'
43
+ add_filter '/.bundle/'
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
+ next if $! and not ($!.kind_of? SystemExit and $!.success?)
53
+
54
+ header = "#{'*' * 20} SimpleCov Results #{'*' * 20}"
55
+ results = SimpleCov.result.format!.join("\n")
56
+ exit_message = <<-EOF
57
+
58
+ #{header}
59
+ {{RESULTS}}
60
+ {{FAILURE_MESSAGE}}
61
+
62
+ #{'*' * header.size}
63
+ EOF
64
+ percent = Float(SimpleCov.result.covered_percent)
65
+ if percent < @minimum_coverage
66
+ failure_message = <<-EOF
67
+ Spec coverage was not high enough: #{percent.round(2)}% is < #{@minimum_coverage}%
68
+ EOF
69
+ exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', failure_message)
70
+ @output.puts exit_message
71
+ abort(failure_message) if @generate_report
72
+ elsif @running_ci
73
+ exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', <<-EOF)
74
+ Nice job! Spec coverage (#{percent.round(2)}%) is still at or above #{@minimum_coverage}%
75
+ EOF
76
+ @output.puts exit_message
77
+ end
78
+ end
79
+
80
+ ## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start'
81
+ ## to defer running until test/test_helper.rb is loaded.
82
+ # rubocop:disable Style/MultilineBlockChain
83
+ AppCoverage = Class.new do
84
+ def initialize(&block)
85
+ @block = block
86
+ end
87
+
88
+ def start
89
+ @block.call
90
+ end
91
+ end.new do
92
+ SimpleCov.start 'app'
93
+ if @generate_report
94
+ if @running_ci
95
+ require 'codeclimate-test-reporter'
96
+ @output.puts '[COVERAGE] Running with SimpleCov Simple Formatter and CodeClimate Test Reporter'
97
+ formatters = [
98
+ SimpleCov::Formatter::SimpleFormatter,
99
+ CodeClimate::TestReporter::Formatter
100
+ ]
101
+ else
102
+ @output.puts '[COVERAGE] Running with SimpleCov HTML Formatter'
103
+ formatters = [SimpleCov::Formatter::HTMLFormatter]
104
+ end
105
+ else
106
+ formatters = []
107
+ end
108
+ SimpleCov.formatters = formatters
109
+ end
110
+ # rubocop:enable Style/MultilineBlockChain
data/.travis.yml CHANGED
@@ -1,28 +1,51 @@
1
1
  language: ruby
2
+
3
+ sudo: false
4
+
2
5
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
6
  - 2.0.0
7
- - ree
8
- - jruby-18mode
9
- - jruby-19mode
10
- - rbx-2
11
- gemfile:
12
- - Gemfile
13
- - Gemfile.edge
7
+ - 2.1
8
+ - 2.2.3
9
+ - 2.3.0
10
+ - ruby-head
11
+ - jruby-9.0.4.0
12
+ - jruby-head
13
+
14
+ jdk:
15
+ - oraclejdk8
16
+
17
+ install: bundle install --path=vendor/bundle --retry=3 --jobs=3
18
+ cache:
19
+ directories:
20
+ - vendor/bundle
21
+
22
+ script:
23
+ - bundle exec rake ci
24
+
25
+ env:
26
+ global:
27
+ - "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
28
+ matrix:
29
+ - "RAILS_VERSION=4.0"
30
+ - "RAILS_VERSION=4.1"
31
+ - "RAILS_VERSION=4.2"
32
+ - "RAILS_VERSION=master"
33
+
14
34
  matrix:
15
- allow_failures:
16
- - gemfile: Gemfile.edge
17
35
  exclude:
18
- # Edge Rails is only compatible with 1.9.3
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
36
+ - rvm: 2.0.0
37
+ env: RAILS_VERSION=master
38
+ - rvm: 2.1
39
+ env: RAILS_VERSION=master
40
+ - rvm: jruby-9.0.4.0
41
+ env: RAILS_VERSION=master
42
+ - rvm: jruby-9.0.4.0
43
+ env: RAILS_VERSION=4.0
44
+ - rvm: jruby-head
45
+ env: RAILS_VERSION=master
46
+ - rvm: jruby-head
47
+ env: RAILS_VERSION=4.0
48
+ allow_failures:
49
+ - rvm: ruby-head
50
+ - rvm: jruby-head
51
+ fast_finish: true