active_model_serializers 0.10.7 → 0.10.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/README.md +2 -2
  4. data/lib/action_controller/serialization.rb +11 -1
  5. data/lib/active_model/serializable_resource.rb +2 -0
  6. data/lib/active_model/serializer/adapter/attributes.rb +2 -0
  7. data/lib/active_model/serializer/adapter/base.rb +2 -0
  8. data/lib/active_model/serializer/adapter/json.rb +2 -0
  9. data/lib/active_model/serializer/adapter/json_api.rb +2 -0
  10. data/lib/active_model/serializer/adapter/null.rb +2 -0
  11. data/lib/active_model/serializer/adapter.rb +2 -0
  12. data/lib/active_model/serializer/array_serializer.rb +2 -0
  13. data/lib/active_model/serializer/association.rb +2 -0
  14. data/lib/active_model/serializer/attribute.rb +2 -0
  15. data/lib/active_model/serializer/belongs_to_reflection.rb +2 -0
  16. data/lib/active_model/serializer/collection_serializer.rb +6 -6
  17. data/lib/active_model/serializer/concerns/caching.rb +5 -1
  18. data/lib/active_model/serializer/error_serializer.rb +2 -0
  19. data/lib/active_model/serializer/errors_serializer.rb +2 -0
  20. data/lib/active_model/serializer/field.rb +2 -0
  21. data/lib/active_model/serializer/fieldset.rb +2 -0
  22. data/lib/active_model/serializer/has_many_reflection.rb +2 -0
  23. data/lib/active_model/serializer/has_one_reflection.rb +2 -0
  24. data/lib/active_model/serializer/lazy_association.rb +6 -2
  25. data/lib/active_model/serializer/link.rb +23 -0
  26. data/lib/active_model/serializer/lint.rb +2 -0
  27. data/lib/active_model/serializer/null.rb +2 -0
  28. data/lib/active_model/serializer/reflection.rb +5 -0
  29. data/lib/active_model/serializer/version.rb +3 -1
  30. data/lib/active_model/serializer.rb +32 -16
  31. data/lib/active_model_serializers/adapter/attributes.rb +23 -0
  32. data/lib/active_model_serializers/adapter/base.rb +2 -0
  33. data/lib/active_model_serializers/adapter/json.rb +2 -0
  34. data/lib/active_model_serializers/adapter/json_api/deserialization.rb +2 -0
  35. data/lib/active_model_serializers/adapter/json_api/error.rb +2 -0
  36. data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +2 -0
  37. data/lib/active_model_serializers/adapter/json_api/link.rb +2 -0
  38. data/lib/active_model_serializers/adapter/json_api/meta.rb +2 -0
  39. data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +2 -0
  40. data/lib/active_model_serializers/adapter/json_api/relationship.rb +2 -0
  41. data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +3 -1
  42. data/lib/active_model_serializers/adapter/json_api.rb +14 -9
  43. data/lib/active_model_serializers/adapter/null.rb +2 -0
  44. data/lib/active_model_serializers/adapter.rb +3 -1
  45. data/lib/active_model_serializers/callbacks.rb +2 -0
  46. data/lib/active_model_serializers/deprecate.rb +2 -0
  47. data/lib/active_model_serializers/deserialization.rb +2 -0
  48. data/lib/active_model_serializers/json_pointer.rb +2 -0
  49. data/lib/active_model_serializers/logging.rb +2 -0
  50. data/lib/active_model_serializers/lookup_chain.rb +2 -0
  51. data/lib/active_model_serializers/model.rb +2 -0
  52. data/lib/active_model_serializers/railtie.rb +4 -0
  53. data/lib/active_model_serializers/register_jsonapi_renderer.rb +2 -0
  54. data/lib/active_model_serializers/serializable_resource.rb +4 -2
  55. data/lib/active_model_serializers/serialization_context.rb +2 -0
  56. data/lib/active_model_serializers/test/schema.rb +2 -0
  57. data/lib/active_model_serializers/test/serializer.rb +2 -0
  58. data/lib/active_model_serializers/test.rb +2 -0
  59. data/lib/active_model_serializers.rb +20 -10
  60. data/lib/generators/rails/resource_override.rb +2 -0
  61. data/lib/generators/rails/serializer_generator.rb +2 -0
  62. data/lib/grape/active_model_serializers.rb +2 -0
  63. data/lib/grape/formatters/active_model_serializers.rb +2 -0
  64. data/lib/grape/helpers/active_model_serializers.rb +2 -0
  65. data/lib/tasks/rubocop.rake +2 -0
  66. metadata +64 -290
  67. data/.github/ISSUE_TEMPLATE.md +0 -29
  68. data/.github/PULL_REQUEST_TEMPLATE.md +0 -15
  69. data/.gitignore +0 -35
  70. data/.rubocop.yml +0 -105
  71. data/.simplecov +0 -110
  72. data/.travis.yml +0 -52
  73. data/CODE_OF_CONDUCT.md +0 -74
  74. data/CONTRIBUTING.md +0 -105
  75. data/Gemfile +0 -72
  76. data/Rakefile +0 -74
  77. data/active_model_serializers.gemspec +0 -63
  78. data/appveyor.yml +0 -28
  79. data/bin/bench +0 -171
  80. data/bin/bench_regression +0 -316
  81. data/bin/rubocop +0 -38
  82. data/bin/serve_benchmark +0 -39
  83. data/docs/README.md +0 -41
  84. data/docs/STYLE.md +0 -58
  85. data/docs/general/adapters.md +0 -269
  86. data/docs/general/caching.md +0 -58
  87. data/docs/general/configuration_options.md +0 -185
  88. data/docs/general/deserialization.md +0 -100
  89. data/docs/general/fields.md +0 -31
  90. data/docs/general/getting_started.md +0 -133
  91. data/docs/general/instrumentation.md +0 -40
  92. data/docs/general/key_transforms.md +0 -40
  93. data/docs/general/logging.md +0 -21
  94. data/docs/general/rendering.md +0 -293
  95. data/docs/general/serializers.md +0 -483
  96. data/docs/how-open-source-maintained.jpg +0 -0
  97. data/docs/howto/add_pagination_links.md +0 -138
  98. data/docs/howto/add_relationship_links.md +0 -140
  99. data/docs/howto/add_root_key.md +0 -62
  100. data/docs/howto/grape_integration.md +0 -42
  101. data/docs/howto/outside_controller_use.md +0 -66
  102. data/docs/howto/passing_arbitrary_options.md +0 -27
  103. data/docs/howto/serialize_poro.md +0 -73
  104. data/docs/howto/test.md +0 -154
  105. data/docs/howto/upgrade_from_0_8_to_0_10.md +0 -265
  106. data/docs/integrations/ember-and-json-api.md +0 -147
  107. data/docs/integrations/grape.md +0 -19
  108. data/docs/jsonapi/errors.md +0 -56
  109. data/docs/jsonapi/schema/schema.json +0 -366
  110. data/docs/jsonapi/schema.md +0 -151
  111. data/docs/rfcs/0000-namespace.md +0 -106
  112. data/docs/rfcs/template.md +0 -15
  113. data/test/action_controller/adapter_selector_test.rb +0 -62
  114. data/test/action_controller/explicit_serializer_test.rb +0 -135
  115. data/test/action_controller/json/include_test.rb +0 -246
  116. data/test/action_controller/json_api/deserialization_test.rb +0 -112
  117. data/test/action_controller/json_api/errors_test.rb +0 -40
  118. data/test/action_controller/json_api/fields_test.rb +0 -66
  119. data/test/action_controller/json_api/linked_test.rb +0 -202
  120. data/test/action_controller/json_api/pagination_test.rb +0 -124
  121. data/test/action_controller/json_api/transform_test.rb +0 -189
  122. data/test/action_controller/lookup_proc_test.rb +0 -49
  123. data/test/action_controller/namespace_lookup_test.rb +0 -232
  124. data/test/action_controller/serialization_scope_name_test.rb +0 -235
  125. data/test/action_controller/serialization_test.rb +0 -472
  126. data/test/active_model_serializers/adapter_for_test.rb +0 -208
  127. data/test/active_model_serializers/json_pointer_test.rb +0 -22
  128. data/test/active_model_serializers/logging_test.rb +0 -77
  129. data/test/active_model_serializers/model_test.rb +0 -142
  130. data/test/active_model_serializers/railtie_test_isolated.rb +0 -68
  131. data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +0 -161
  132. data/test/active_model_serializers/serialization_context_test_isolated.rb +0 -71
  133. data/test/active_model_serializers/test/schema_test.rb +0 -131
  134. data/test/active_model_serializers/test/serializer_test.rb +0 -62
  135. data/test/active_record_test.rb +0 -9
  136. data/test/adapter/attributes_test.rb +0 -40
  137. data/test/adapter/deprecation_test.rb +0 -100
  138. data/test/adapter/json/belongs_to_test.rb +0 -45
  139. data/test/adapter/json/collection_test.rb +0 -104
  140. data/test/adapter/json/has_many_test.rb +0 -53
  141. data/test/adapter/json/transform_test.rb +0 -93
  142. data/test/adapter/json_api/belongs_to_test.rb +0 -155
  143. data/test/adapter/json_api/collection_test.rb +0 -96
  144. data/test/adapter/json_api/errors_test.rb +0 -76
  145. data/test/adapter/json_api/fields_test.rb +0 -96
  146. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +0 -96
  147. data/test/adapter/json_api/has_many_test.rb +0 -173
  148. data/test/adapter/json_api/has_one_test.rb +0 -80
  149. data/test/adapter/json_api/include_data_if_sideloaded_test.rb +0 -213
  150. data/test/adapter/json_api/json_api_test.rb +0 -33
  151. data/test/adapter/json_api/linked_test.rb +0 -413
  152. data/test/adapter/json_api/links_test.rb +0 -95
  153. data/test/adapter/json_api/pagination_links_test.rb +0 -206
  154. data/test/adapter/json_api/parse_test.rb +0 -137
  155. data/test/adapter/json_api/relationship_test.rb +0 -397
  156. data/test/adapter/json_api/resource_meta_test.rb +0 -100
  157. data/test/adapter/json_api/toplevel_jsonapi_test.rb +0 -82
  158. data/test/adapter/json_api/transform_test.rb +0 -512
  159. data/test/adapter/json_api/type_test.rb +0 -193
  160. data/test/adapter/json_test.rb +0 -46
  161. data/test/adapter/null_test.rb +0 -22
  162. data/test/adapter/polymorphic_test.rb +0 -218
  163. data/test/adapter_test.rb +0 -67
  164. data/test/array_serializer_test.rb +0 -22
  165. data/test/benchmark/app.rb +0 -65
  166. data/test/benchmark/benchmarking_support.rb +0 -67
  167. data/test/benchmark/bm_active_record.rb +0 -81
  168. data/test/benchmark/bm_adapter.rb +0 -38
  169. data/test/benchmark/bm_caching.rb +0 -119
  170. data/test/benchmark/bm_lookup_chain.rb +0 -83
  171. data/test/benchmark/bm_transform.rb +0 -45
  172. data/test/benchmark/config.ru +0 -3
  173. data/test/benchmark/controllers.rb +0 -83
  174. data/test/benchmark/fixtures.rb +0 -219
  175. data/test/cache_test.rb +0 -651
  176. data/test/collection_serializer_test.rb +0 -127
  177. data/test/fixtures/active_record.rb +0 -113
  178. data/test/fixtures/poro.rb +0 -225
  179. data/test/generators/scaffold_controller_generator_test.rb +0 -24
  180. data/test/generators/serializer_generator_test.rb +0 -75
  181. data/test/grape_test.rb +0 -196
  182. data/test/lint_test.rb +0 -49
  183. data/test/logger_test.rb +0 -20
  184. data/test/poro_test.rb +0 -9
  185. data/test/serializable_resource_test.rb +0 -79
  186. data/test/serializers/association_macros_test.rb +0 -37
  187. data/test/serializers/associations_test.rb +0 -468
  188. data/test/serializers/attribute_test.rb +0 -153
  189. data/test/serializers/attributes_test.rb +0 -52
  190. data/test/serializers/caching_configuration_test_isolated.rb +0 -170
  191. data/test/serializers/configuration_test.rb +0 -32
  192. data/test/serializers/fieldset_test.rb +0 -14
  193. data/test/serializers/meta_test.rb +0 -202
  194. data/test/serializers/options_test.rb +0 -32
  195. data/test/serializers/read_attribute_for_serialization_test.rb +0 -79
  196. data/test/serializers/reflection_test.rb +0 -427
  197. data/test/serializers/root_test.rb +0 -21
  198. data/test/serializers/serialization_test.rb +0 -55
  199. data/test/serializers/serializer_for_test.rb +0 -136
  200. data/test/serializers/serializer_for_with_namespace_test.rb +0 -88
  201. data/test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
  202. data/test/support/isolated_unit.rb +0 -84
  203. data/test/support/rails5_shims.rb +0 -53
  204. data/test/support/rails_app.rb +0 -38
  205. data/test/support/schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
  206. data/test/support/schemas/active_model_serializers/test/schema_test/my/show.json +0 -6
  207. data/test/support/schemas/custom/show.json +0 -7
  208. data/test/support/schemas/hyper_schema.json +0 -93
  209. data/test/support/schemas/render_using_json_api.json +0 -43
  210. data/test/support/schemas/simple_json_pointers.json +0 -10
  211. data/test/support/serialization_testing.rb +0 -79
  212. data/test/test_helper.rb +0 -70
data/.rubocop.yml DELETED
@@ -1,105 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.1
3
- Exclude:
4
- - !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
5
- DisplayCopNames: true
6
- DisplayStyleGuide: true
7
- # https://github.com/bbatsov/rubocop/blob/master/manual/caching.md
8
- # https://github.com/bbatsov/rubocop/blob/e8680418b351491e111a18cf5b453fc07a3c5239/config/default.yml#L60-L77
9
- UseCache: true
10
- CacheRootDirectory: tmp
11
-
12
- Rails:
13
- Enabled: true
14
-
15
- Lint/NestedMethodDefinition:
16
- Enabled: false
17
- Exclude:
18
- - test/action_controller/serialization_test.rb
19
-
20
- Style/Alias:
21
- EnforcedStyle: prefer_alias
22
-
23
- Style/StringLiterals:
24
- EnforcedStyle: single_quotes
25
-
26
- Metrics/AbcSize:
27
- Max: 35 # TODO: Lower to 15
28
-
29
- Metrics/ClassLength:
30
- Max: 261 # TODO: Lower to 100
31
- Exclude:
32
- - test/**/*.rb
33
-
34
- Metrics/CyclomaticComplexity:
35
- Max: 7 # TODO: Lower to 6
36
-
37
- Metrics/LineLength:
38
- Max: 251 # TODO: Lower to 80
39
-
40
- Metrics/MethodLength:
41
- Max: 106 # TODO: Lower to 10
42
-
43
- Metrics/PerceivedComplexity:
44
- Max: 9 # TODO: Lower to 7
45
-
46
- Style/AlignParameters:
47
- EnforcedStyle: with_fixed_indentation
48
-
49
- Style/ClassAndModuleChildren:
50
- EnforcedStyle: nested
51
-
52
- Style/Documentation:
53
- Enabled: false
54
-
55
- Style/MissingElse:
56
- Enabled: true
57
- EnforcedStyle: case
58
-
59
- Style/EmptyElse:
60
- EnforcedStyle: empty
61
-
62
- Style/MultilineOperationIndentation:
63
- EnforcedStyle: indented
64
-
65
- Style/BlockDelimiters:
66
- Enabled: true
67
- EnforcedStyle: line_count_based
68
-
69
- Style/SignalException:
70
- EnforcedStyle: semantic
71
-
72
- Style/TrailingCommaInLiteral:
73
- EnforcedStyleForMultiline: no_comma
74
-
75
- Style/ConditionalAssignment:
76
- Enabled: false
77
-
78
- Style/DotPosition:
79
- EnforcedStyle: leading
80
-
81
- ########## test_helper.rb sanity
82
- Style/EndBlock:
83
- Exclude:
84
- - test/test_helper.rb
85
-
86
- Style/SpecialGlobalVars:
87
- Exclude:
88
- - test/test_helper.rb
89
-
90
- Style/GlobalVars:
91
- Exclude:
92
- - test/test_helper.rb
93
-
94
- Style/AndOr:
95
- Exclude:
96
- - test/test_helper.rb
97
- - 'lib/active_model/serializer/lint.rb'
98
-
99
- Style/Not:
100
- Exclude:
101
- - test/test_helper.rb
102
-
103
- Style/ClassCheck:
104
- Exclude:
105
- - test/test_helper.rb
data/.simplecov DELETED
@@ -1,110 +0,0 @@
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 DELETED
@@ -1,52 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- cache:
5
- directories:
6
- - vendor/bundle
7
-
8
- before_install:
9
- - "travis_retry gem update --system"
10
- - "travis_retry gem update bundler"
11
- install: bundle install --path=vendor/bundle --retry=3 --jobs=3
12
-
13
- script:
14
- - bundle exec rake ci
15
- after_success:
16
- - codeclimate-test-reporter
17
-
18
- env:
19
- matrix:
20
- - "RAILS_VERSION=4.1"
21
- - "RAILS_VERSION=4.2"
22
- - "RAILS_VERSION=5.0"
23
- - "RAILS_VERSION=5.1"
24
- - "RAILS_VERSION=master"
25
-
26
- rvm:
27
- - 2.1.10
28
- - 2.2.8
29
- - 2.3.5
30
- - 2.4.2
31
- - ruby-head
32
-
33
- matrix:
34
- include:
35
- - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
36
- - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
37
- - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
38
- # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
39
- # - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
40
- # - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
41
- exclude:
42
- - { rvm: 2.1.10, env: RAILS_VERSION=master }
43
- - { rvm: 2.1.10, env: RAILS_VERSION=5.0 }
44
- - { rvm: 2.1.10, env: RAILS_VERSION=5.1 }
45
- - { rvm: 2.4.2, env: RAILS_VERSION=4.1 }
46
- - { rvm: ruby-head, env: RAILS_VERSION=4.1 }
47
- allow_failures:
48
- - rvm: ruby-head
49
- - rvm: jruby-head
50
- # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708
51
- - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
52
- fast_finish: true
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting one of the owners listed at https://rubygems.org/gems/active_model_serializers. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md DELETED
@@ -1,105 +0,0 @@
1
- ## Have an issue?
2
-
3
- Before opening an issue, try the following:
4
-
5
- ##### Consult the documentation
6
-
7
- See if your issue can be resolved by information in the documentation.
8
-
9
- - [0.10 (master) Documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
10
- - [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/v0.10.0)
11
- - [Guides](docs)
12
- - [0.9 (0-9-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
13
- - [0.8 (0-8-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
14
-
15
- ##### Check for an existing issue
16
-
17
- Take a look at the issues to see if a similar one has already been created. If
18
- one exists, please add any additional information that might expedite
19
- resolution.
20
-
21
- #### Open an issue
22
-
23
- If the documentation wasn't able to help resolve the issue and no issue already
24
- exists, please open a new issue with the following in mind:
25
-
26
- - Please make sure only to include one issue per report. If you encounter
27
- multiple, unrelated issues, please report them as such.
28
- - Be detailed. Provide backtraces and example code when possible. Provide
29
- information about your environment. e.g., Ruby version, rails version, etc.
30
- - Own your issue. Actively participate in the discussion and help drive the
31
- issue to closure.
32
- - If you resolve your own issue, please share the details on the issue and close
33
- it out. Others might have the same issue and sharing solutions is helpful.
34
-
35
- ## Contributing
36
-
37
- Contributing can be done in many ways and is not exclusive to code. If you have
38
- thoughts on a particular issue or feature, we encourage you to open new issues
39
- for discussion or add your comments to existing ones.
40
-
41
- #### Pull requests
42
-
43
- We also gladly welcome pull requests. When preparing to work on pull request,
44
- please adhere to these standards:
45
-
46
- - Base work on the master branch unless fixing an issue with
47
- [0.9-stable](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
48
- or
49
- [0.8-stable](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
50
- - Squash your commits and regularly rebase off master.
51
- - Provide a description of the changes contained in the pull request.
52
- - Note any specific areas that should be reviewed.
53
- - Include tests.
54
- - The test suite must pass on [supported Ruby versions](.travis.yml)
55
- - Include updates to the [documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
56
- where applicable.
57
- - Update the
58
- [CHANGELOG](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG.md)
59
- to the appropriate sections with a brief description of the changes.
60
- - Do not change the VERSION file.
61
-
62
- #### Running tests
63
-
64
- Run all tests
65
-
66
- `$ rake test`
67
-
68
- Run a single test suite
69
-
70
- `$ rake test TEST=path/to/test.rb`
71
-
72
- Run a single test
73
-
74
- `$ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"`
75
-
76
- Run tests against different Rails versions by setting the RAILS_VERSION variable
77
- and bundling gems. (save this script somewhere executable and run from top of AMS repository)
78
-
79
- ```bash
80
- #!/usr/bin/env bash
81
-
82
- rcommand='puts YAML.load_file("./.travis.yml")["env"]["matrix"].join(" ").gsub("RAILS_VERSION=", "")'
83
- versions=$(ruby -ryaml -e "$rcommand")
84
-
85
- for version in ${versions[@]}; do
86
- export RAILS_VERSION="$version"
87
- rm -f Gemfile.lock
88
- bundle check || bundle --local || bundle
89
- bundle exec rake test
90
- if [ "$?" -eq 0 ]; then
91
- # green in ANSI
92
- echo -e "\033[32m **** Tests passed against Rails ${RAILS_VERSION} **** \033[0m"
93
- else
94
- # red in ANSI
95
- echo -e "\033[31m **** Tests failed against Rails ${RAILS_VERSION} **** \033[0m"
96
- read -p '[Enter] any key to continue, [q] to quit...' prompt
97
- if [ "$prompt" = 'q' ]; then
98
- unset RAILS_VERSION
99
- exit 1
100
- fi
101
- fi
102
- unset RAILS_VERSION
103
- done
104
- ```
105
-
data/Gemfile DELETED
@@ -1,72 +0,0 @@
1
- source 'https://rubygems.org'
2
- #
3
- # Add a Gemfile.local to locally bundle gems outside of version control
4
- local_gemfile = File.join(File.expand_path('..', __FILE__), 'Gemfile.local')
5
- eval_gemfile local_gemfile if File.readable?(local_gemfile)
6
-
7
- # Specify your gem's dependencies in active_model_serializers.gemspec
8
- gemspec
9
-
10
- version = ENV['RAILS_VERSION'] || '4.2'
11
-
12
- if version == 'master'
13
- gem 'rack', github: 'rack/rack'
14
- gem 'arel', github: 'rails/arel'
15
- gem 'rails', github: 'rails/rails'
16
- git 'https://github.com/rails/rails.git' do
17
- gem 'railties'
18
- gem 'activesupport'
19
- gem 'activemodel'
20
- gem 'actionpack'
21
- gem 'activerecord', group: :test
22
- # Rails 5
23
- gem 'actionview'
24
- end
25
- else
26
- gem_version = "~> #{version}.0"
27
- gem 'rails', gem_version
28
- gem 'railties', gem_version
29
- gem 'activesupport', gem_version
30
- gem 'activemodel', gem_version
31
- gem 'actionpack', gem_version
32
- gem 'activerecord', gem_version, group: :test
33
- end
34
-
35
- # https://github.com/bundler/bundler/blob/89a8778c19269561926cea172acdcda241d26d23/lib/bundler/dependency.rb#L30-L54
36
- @windows_platforms = [:mswin, :mingw, :x64_mingw]
37
-
38
- # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
39
- gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
40
-
41
- if ENV['CI']
42
- if RUBY_VERSION < '2.4'
43
- # Windows: An error occurred while installing nokogiri (1.8.0)
44
- gem 'nokogiri', '< 1.7', platforms: @windows_platforms
45
- end
46
- end
47
-
48
- group :bench do
49
- # https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76
50
- gem 'benchmark-ips', '>= 2.7.2', require: false, group: :development
51
- end
52
-
53
- group :test do
54
- gem 'sqlite3', platform: (@windows_platforms + [:ruby])
55
- platforms :jruby do
56
- if version == 'master' || version >= '5'
57
- gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' # github: 'jruby/activerecord-jdbc-adapter', branch: 'master'
58
- else
59
- gem 'activerecord-jdbcsqlite3-adapter'
60
- end
61
- end
62
- gem 'codeclimate-test-reporter', require: false
63
- gem 'm', '~> 1.5'
64
- gem 'pry', '>= 0.10'
65
- gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2'
66
- gem 'pry-byebug', platform: :ruby
67
- end
68
-
69
- group :development, :test do
70
- gem 'rubocop', '~> 0.40.0', require: false
71
- gem 'yard', require: false
72
- end
data/Rakefile DELETED
@@ -1,74 +0,0 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
- begin
7
- require 'simplecov'
8
- rescue LoadError # rubocop:disable Lint/HandleExceptions
9
- end
10
- import('lib/tasks/rubocop.rake')
11
-
12
- Bundler::GemHelper.install_tasks
13
-
14
- require 'yard'
15
-
16
- namespace :yard do
17
- YARD::Rake::YardocTask.new(:doc) do |t|
18
- t.stats_options = ['--list-undoc']
19
- end
20
-
21
- desc 'start a gem server'
22
- task :server do
23
- sh 'bundle exec yard server --gems'
24
- end
25
-
26
- desc 'use Graphviz to generate dot graph'
27
- task :graph do
28
- output_file = 'doc/erd.dot'
29
- sh "bundle exec yard graph --protected --full --dependencies > #{output_file}"
30
- puts 'open doc/erd.dot if you have graphviz installed'
31
- end
32
- end
33
-
34
- require 'rake/testtask'
35
-
36
- Rake::TestTask.new(:test) do |t|
37
- t.libs << 'lib'
38
- t.libs << 'test'
39
- t.pattern = 'test/**/*_test.rb'
40
- t.ruby_opts = ['-r./test/test_helper.rb']
41
- t.ruby_opts << ' -w' unless ENV['NO_WARN'] == 'true'
42
- t.verbose = true
43
- end
44
-
45
- desc 'Run isolated tests'
46
- task isolated: ['test:isolated']
47
- namespace :test do
48
- task :isolated do
49
- desc 'Run isolated tests for Railtie'
50
- require 'shellwords'
51
- dir = File.dirname(__FILE__)
52
- dir = Shellwords.shellescape(dir)
53
- isolated_test_files = FileList['test/**/*_test_isolated.rb']
54
- # https://github.com/rails/rails/blob/3d590add45/railties/lib/rails/generators/app_base.rb#L345-L363
55
- _bundle_command = Gem.bin_path('bundler', 'bundle')
56
- require 'bundler'
57
- Bundler.with_clean_env do
58
- isolated_test_files.all? do |test_file|
59
- command = "-w -I#{dir}/lib -I#{dir}/test #{Shellwords.shellescape(test_file)}"
60
- full_command = %("#{Gem.ruby}" #{command})
61
- system(full_command)
62
- end or fail 'Failures' # rubocop:disable Style/AndOr
63
- end
64
- end
65
- end
66
-
67
- if ENV['RAILS_VERSION'].to_s > '4.0' && RUBY_ENGINE == 'ruby'
68
- task default: [:isolated, :test, :rubocop]
69
- else
70
- task default: [:test, :rubocop]
71
- end
72
-
73
- desc 'CI test task'
74
- task ci: [:default]
@@ -1,63 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'active_model/serializer/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'active_model_serializers'
8
- spec.version = ActiveModel::Serializer::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ['Steve Klabnik']
11
- spec.email = ['steve@steveklabnik.com']
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'
15
- spec.license = 'MIT'
16
-
17
- spec.files = `git ls-files -z`.split("\x0")
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
- spec.executables = []
21
-
22
- spec.required_ruby_version = '>= 2.1'
23
-
24
- rails_versions = ['>= 4.1', '< 6']
25
- spec.add_runtime_dependency 'activemodel', rails_versions
26
- # 'activesupport', rails_versions
27
- # 'builder'
28
-
29
- spec.add_runtime_dependency 'actionpack', rails_versions
30
- # 'activesupport', rails_versions
31
- # 'rack'
32
- # 'rack-test', '~> 0.6.2'
33
-
34
- spec.add_development_dependency 'railties', rails_versions
35
- # 'activesupport', rails_versions
36
- # 'actionpack', rails_versions
37
- # 'rake', '>= 0.8.7'
38
-
39
- # 'activesupport', rails_versions
40
- # 'i18n,
41
- # 'tzinfo'
42
- # 'minitest'
43
- # 'thread_safe'
44
-
45
- spec.add_runtime_dependency 'jsonapi-renderer', ['>= 0.1.1.beta1', '< 0.3']
46
- spec.add_runtime_dependency 'case_transform', '>= 0.2'
47
-
48
- spec.add_development_dependency 'activerecord', rails_versions
49
- # arel
50
- # activesupport
51
- # activemodel
52
-
53
- # Soft dependency for pagination
54
- spec.add_development_dependency 'kaminari', ' ~> 0.16.3'
55
- spec.add_development_dependency 'will_paginate', '~> 3.0', '>= 3.0.7'
56
-
57
- spec.add_development_dependency 'bundler', '~> 1.6'
58
- spec.add_development_dependency 'simplecov', '~> 0.11'
59
- spec.add_development_dependency 'timecop', '~> 0.7'
60
- spec.add_development_dependency 'grape', ['>= 0.13', '< 0.19.1']
61
- spec.add_development_dependency 'json_schema'
62
- spec.add_development_dependency 'rake', ['>= 10.0', '< 12.0']
63
- end
data/appveyor.yml DELETED
@@ -1,28 +0,0 @@
1
- version: 1.0.{build}-{branch}
2
-
3
- skip_tags: true
4
-
5
- environment:
6
- JRUBY_OPTS: "--dev -J-Xmx1024M --debug"
7
- matrix:
8
- - ruby_version: "Ruby23"
9
- - ruby_version: "Ruby23-x64"
10
-
11
- cache:
12
- - vendor/bundle
13
-
14
- install:
15
- - SET PATH=C:\%ruby_version%\bin;%PATH%
16
- - bundle env
17
- - bundle check || bundle install --path=vendor/bundle --retry=3 --jobs=3
18
- - bundle clean --force
19
-
20
- before_test:
21
- - ruby -v
22
- - gem -v
23
- - bundle -v
24
-
25
- test_script:
26
- - bundle exec rake ci
27
-
28
- build: off