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.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +82 -0
  4. data/.rubocop_todo.yml +315 -0
  5. data/.simplecov +99 -0
  6. data/.travis.yml +26 -20
  7. data/CHANGELOG.md +14 -67
  8. data/CONTRIBUTING.md +31 -0
  9. data/Gemfile +45 -1
  10. data/{MIT-LICENSE.txt → LICENSE.txt} +3 -2
  11. data/README.md +186 -488
  12. data/Rakefile +33 -12
  13. data/active_model_serializers.gemspec +49 -23
  14. data/appveyor.yml +25 -0
  15. data/docs/README.md +29 -0
  16. data/docs/general/adapters.md +110 -0
  17. data/docs/general/configuration_options.md +11 -0
  18. data/docs/general/getting_started.md +73 -0
  19. data/docs/howto/add_pagination_links.md +112 -0
  20. data/docs/howto/add_root_key.md +51 -0
  21. data/docs/howto/outside_controller_use.md +42 -0
  22. data/lib/action_controller/serialization.rb +31 -31
  23. data/lib/active_model/serializable_resource.rb +70 -0
  24. data/lib/active_model/serializer/adapter/flatten_json.rb +12 -0
  25. data/lib/active_model/serializer/adapter/fragment_cache.rb +75 -0
  26. data/lib/active_model/serializer/adapter/json/fragment_cache.rb +5 -0
  27. data/lib/active_model/serializer/adapter/json.rb +47 -0
  28. data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +13 -0
  29. data/lib/active_model/serializer/adapter/json_api/pagination_links.rb +50 -0
  30. data/lib/active_model/serializer/adapter/json_api.rb +158 -0
  31. data/lib/active_model/serializer/adapter/null.rb +5 -0
  32. data/lib/active_model/serializer/adapter.rb +159 -0
  33. data/lib/active_model/serializer/array_serializer.rb +40 -0
  34. data/lib/active_model/serializer/association.rb +20 -0
  35. data/lib/active_model/serializer/associations.rb +83 -219
  36. data/lib/active_model/serializer/belongs_to_reflection.rb +10 -0
  37. data/lib/active_model/serializer/collection_reflection.rb +7 -0
  38. data/lib/active_model/serializer/configuration.rb +14 -0
  39. data/lib/active_model/serializer/fieldset.rb +40 -0
  40. data/lib/active_model/serializer/has_many_reflection.rb +10 -0
  41. data/lib/active_model/serializer/has_one_reflection.rb +10 -0
  42. data/lib/active_model/serializer/lint.rb +129 -0
  43. data/lib/active_model/serializer/railtie.rb +15 -0
  44. data/lib/active_model/serializer/reflection.rb +74 -0
  45. data/lib/active_model/serializer/singular_reflection.rb +7 -0
  46. data/lib/active_model/serializer/utils.rb +35 -0
  47. data/lib/active_model/{serializers → serializer}/version.rb +1 -1
  48. data/lib/active_model/serializer.rb +121 -465
  49. data/lib/active_model_serializers.rb +26 -88
  50. data/lib/generators/serializer/USAGE +0 -3
  51. data/lib/generators/serializer/resource_override.rb +12 -0
  52. data/lib/generators/serializer/serializer_generator.rb +8 -13
  53. data/lib/generators/serializer/templates/serializer.rb.erb +8 -0
  54. data/lib/tasks/rubocop.rake +0 -0
  55. data/test/action_controller/adapter_selector_test.rb +53 -0
  56. data/test/action_controller/explicit_serializer_test.rb +134 -0
  57. data/test/action_controller/json_api/linked_test.rb +179 -0
  58. data/test/action_controller/json_api/pagination_test.rb +116 -0
  59. data/test/{serialization_scope_name_test.rb → action_controller/serialization_scope_name_test.rb} +15 -15
  60. data/test/action_controller/serialization_test.rb +420 -0
  61. data/test/active_record_test.rb +9 -0
  62. data/test/adapter/fragment_cache_test.rb +37 -0
  63. data/test/adapter/json/belongs_to_test.rb +47 -0
  64. data/test/adapter/json/collection_test.rb +82 -0
  65. data/test/adapter/json/has_many_test.rb +47 -0
  66. data/test/adapter/json_api/belongs_to_test.rb +157 -0
  67. data/test/adapter/json_api/collection_test.rb +95 -0
  68. data/test/adapter/json_api/has_many_embed_ids_test.rb +45 -0
  69. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +98 -0
  70. data/test/adapter/json_api/has_many_test.rb +145 -0
  71. data/test/adapter/json_api/has_one_test.rb +81 -0
  72. data/test/adapter/json_api/json_api_test.rb +37 -0
  73. data/test/adapter/json_api/linked_test.rb +283 -0
  74. data/test/adapter/json_api/pagination_links_test.rb +115 -0
  75. data/test/adapter/json_api/resource_type_config_test.rb +59 -0
  76. data/test/adapter/json_test.rb +47 -0
  77. data/test/adapter/null_test.rb +25 -0
  78. data/test/adapter_test.rb +42 -0
  79. data/test/array_serializer_test.rb +99 -73
  80. data/test/capture_warnings.rb +65 -0
  81. data/test/fixtures/active_record.rb +56 -0
  82. data/test/fixtures/poro.rb +261 -0
  83. data/test/generators/scaffold_controller_generator_test.rb +23 -0
  84. data/test/generators/serializer_generator_test.rb +56 -0
  85. data/test/lint_test.rb +37 -0
  86. data/test/logger_test.rb +18 -0
  87. data/test/poro_test.rb +9 -0
  88. data/test/serializable_resource_test.rb +27 -0
  89. data/test/serializers/adapter_for_test.rb +170 -0
  90. data/test/serializers/association_macros_test.rb +36 -0
  91. data/test/serializers/associations_test.rb +150 -0
  92. data/test/serializers/attribute_test.rb +62 -0
  93. data/test/serializers/attributes_test.rb +57 -0
  94. data/test/serializers/cache_test.rb +165 -0
  95. data/test/serializers/configuration_test.rb +15 -0
  96. data/test/serializers/fieldset_test.rb +25 -0
  97. data/test/serializers/meta_test.rb +121 -0
  98. data/test/serializers/options_test.rb +21 -0
  99. data/test/serializers/root_test.rb +21 -0
  100. data/test/serializers/serializer_for_test.rb +65 -0
  101. data/test/support/rails_app.rb +21 -0
  102. data/test/support/serialization_testing.rb +13 -0
  103. data/test/support/simplecov.rb +6 -0
  104. data/test/support/stream_capture.rb +50 -0
  105. data/test/support/test_case.rb +5 -0
  106. data/test/test_helper.rb +48 -24
  107. data/test/utils/include_args_to_hash_test.rb +79 -0
  108. metadata +219 -47
  109. data/DESIGN.textile +0 -586
  110. data/Gemfile.edge +0 -9
  111. data/bench/perf.rb +0 -43
  112. data/cruft.md +0 -19
  113. data/lib/active_model/array_serializer.rb +0 -104
  114. data/lib/active_record/serializer_override.rb +0 -16
  115. data/lib/generators/resource_override.rb +0 -13
  116. data/lib/generators/serializer/templates/serializer.rb +0 -19
  117. data/test/association_test.rb +0 -592
  118. data/test/caching_test.rb +0 -96
  119. data/test/generators_test.rb +0 -85
  120. data/test/no_serialization_scope_test.rb +0 -34
  121. data/test/serialization_test.rb +0 -392
  122. data/test/serializer_support_test.rb +0 -51
  123. data/test/serializer_test.rb +0 -1465
  124. data/test/test_fakes.rb +0 -217
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,31 @@
1
+ ## How can I help?
2
+
3
+ Everyone is encouraged to open issues that are affecting you: bugs, ideas, performance problems – everything helps!
4
+
5
+ The first place to start is by looking at our [GitHub Issues](https://github.com/rails-api/active_model_serializers/issues).
6
+
7
+ The vast majority of development is happening under the `master` branch, currently slated for release as `0.10.x`. This is where we would suggest you start.
8
+
9
+ Fixing bugs is extraordinarily helpful and requires the least familiarity with AMS. Look for issues labeled [**Needs Bug Verification**](https://github.com/rails-api/active_model_serializers/labels/Needs%20Bug%20Verification) and [**Bug**](https://github.com/rails-api/active_model_serializers/labels/bug).
10
+
11
+ We are also actively working to identify tasks under the label [**Good for New Contributors**](https://github.com/rails-api/active_model_serializers/labels/Good%20for%20New%20Contributors). Some bugs are expressly not good for new contributors, so don't expect 100% overlap between the two.
12
+
13
+ If you want to work on new feature development, look for the label [**Feature**](https://github.com/rails-api/active_model_serializers/labels/Feature).
14
+
15
+ We are also encouraging comments to substantial changes (larger than bugfixes and simple features) under an "RFC" (Request for Comments) process before we start active development. Look for the [**RFC**](https://github.com/rails-api/active_model_serializers/labels/RFC) label.
16
+
17
+ ## Issue Labeling
18
+
19
+ AMS uses a subset of [StandardIssueLabels](https://github.com/wagenet/StandardIssueLabels) for Github Issues. You can [see our labels here](https://github.com/rails-api/active_model_serializers/labels).
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork it ( https://github.com/rails-api/active_model_serializers/fork )
24
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 3. Write tests for your feature, or regression tests highlighting a bug
26
+ 4. Write the feature itself, or fix your bug
27
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 6. Push to the branch (`git push origin my-new-feature`)
29
+ 7. Create a new Pull Request
30
+
31
+ Remember to squash your commits and rebase off `master`.
data/Gemfile CHANGED
@@ -1,4 +1,48 @@
1
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)
2
6
 
3
- # Specify gem dependencies in active_model_serializers.gemspec
7
+ # Specify your gem's dependencies in active_model_serializers.gemspec
4
8
  gemspec
9
+
10
+ version = ENV['RAILS_VERSION'] || '4.2'
11
+
12
+ if version == 'master'
13
+ gem 'rack', github: 'rack/rack'
14
+ git 'https://github.com/rails/rails.git' do
15
+ gem 'railties'
16
+ gem 'activesupport'
17
+ gem 'activemodel'
18
+ gem 'actionpack'
19
+ # Rails 5
20
+ gem 'actionview'
21
+ end
22
+ # Rails 5
23
+ gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
24
+ else
25
+ gem_version = "~> #{version}.0"
26
+ gem 'railties', gem_version
27
+ gem 'activesupport', gem_version
28
+ gem 'activemodel', gem_version
29
+ gem 'actionpack', gem_version
30
+ end
31
+
32
+ group :test do
33
+ gem 'activerecord'
34
+ gem 'sqlite3', platform: [:ruby, :mingw, :x64_mingw, :mswin]
35
+ gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
36
+ gem 'codeclimate-test-reporter', require: false
37
+ end
38
+
39
+ group :test, :development do
40
+ gem 'simplecov', '~> 0.10', require: false
41
+ end
42
+
43
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
44
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
45
+
46
+ group :development, :test do
47
+ gem 'rubocop', '~> 0.34.0', require: false
48
+ end
@@ -1,4 +1,6 @@
1
- Copyright (c) 2011-2012 José Valim & Yehuda Katz
1
+ Copyright (c) 2014 Steve Klabnik
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
@@ -18,4 +20,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-