active_model_serializers 0.8.3 → 0.10.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +19 -20
  4. data/CHANGELOG.md +8 -67
  5. data/CONTRIBUTING.md +31 -0
  6. data/Gemfile +14 -1
  7. data/{MIT-LICENSE.txt → LICENSE.txt} +3 -2
  8. data/README.md +166 -495
  9. data/Rakefile +6 -12
  10. data/active_model_serializers.gemspec +21 -19
  11. data/lib/action_controller/serialization.rb +28 -27
  12. data/lib/active_model/serializer/adapter/fragment_cache.rb +78 -0
  13. data/lib/active_model/serializer/adapter/json/fragment_cache.rb +15 -0
  14. data/lib/active_model/serializer/adapter/json.rb +52 -0
  15. data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +22 -0
  16. data/lib/active_model/serializer/adapter/json_api.rb +152 -0
  17. data/lib/active_model/serializer/adapter/null.rb +11 -0
  18. data/lib/active_model/serializer/adapter.rb +87 -0
  19. data/lib/active_model/serializer/array_serializer.rb +32 -0
  20. data/lib/active_model/serializer/configuration.rb +13 -0
  21. data/lib/active_model/serializer/fieldset.rb +40 -0
  22. data/lib/active_model/{serializers → serializer}/version.rb +1 -1
  23. data/lib/active_model/serializer.rb +179 -436
  24. data/lib/active_model_serializers.rb +9 -86
  25. data/lib/generators/serializer/USAGE +0 -3
  26. data/lib/generators/serializer/serializer_generator.rb +1 -6
  27. data/lib/generators/serializer/templates/serializer.rb +2 -13
  28. data/test/action_controller/adapter_selector_test.rb +51 -0
  29. data/test/action_controller/explicit_serializer_test.rb +110 -0
  30. data/test/action_controller/json_api_linked_test.rb +173 -0
  31. data/test/{serialization_scope_name_test.rb → action_controller/serialization_scope_name_test.rb} +7 -11
  32. data/test/action_controller/serialization_test.rb +365 -0
  33. data/test/adapter/fragment_cache_test.rb +27 -0
  34. data/test/adapter/json/belongs_to_test.rb +41 -0
  35. data/test/adapter/json/collection_test.rb +59 -0
  36. data/test/adapter/json/has_many_test.rb +36 -0
  37. data/test/adapter/json_api/belongs_to_test.rb +147 -0
  38. data/test/adapter/json_api/collection_test.rb +89 -0
  39. data/test/adapter/json_api/has_many_embed_ids_test.rb +45 -0
  40. data/test/adapter/json_api/has_many_explicit_serializer_test.rb +98 -0
  41. data/test/adapter/json_api/has_many_test.rb +106 -0
  42. data/test/adapter/json_api/has_one_test.rb +59 -0
  43. data/test/adapter/json_api/linked_test.rb +257 -0
  44. data/test/adapter/json_test.rb +34 -0
  45. data/test/adapter/null_test.rb +25 -0
  46. data/test/adapter_test.rb +43 -0
  47. data/test/array_serializer_test.rb +21 -67
  48. data/test/fixtures/poro.rb +206 -0
  49. data/test/serializers/adapter_for_test.rb +50 -0
  50. data/test/serializers/associations_test.rb +106 -0
  51. data/test/serializers/attribute_test.rb +23 -0
  52. data/test/serializers/attributes_test.rb +28 -0
  53. data/test/serializers/cache_test.rb +128 -0
  54. data/test/serializers/configuration_test.rb +15 -0
  55. data/test/serializers/fieldset_test.rb +26 -0
  56. data/test/{generators_test.rb → serializers/generators_test.rb} +1 -27
  57. data/test/serializers/meta_test.rb +78 -0
  58. data/test/serializers/options_test.rb +21 -0
  59. data/test/serializers/serializer_for_test.rb +56 -0
  60. data/test/serializers/urls_test.rb +26 -0
  61. data/test/test_helper.rb +22 -13
  62. metadata +101 -42
  63. data/DESIGN.textile +0 -586
  64. data/Gemfile.edge +0 -9
  65. data/bench/perf.rb +0 -43
  66. data/cruft.md +0 -19
  67. data/lib/active_model/array_serializer.rb +0 -104
  68. data/lib/active_model/serializer/associations.rb +0 -233
  69. data/lib/active_record/serializer_override.rb +0 -16
  70. data/lib/generators/resource_override.rb +0 -13
  71. data/test/association_test.rb +0 -592
  72. data/test/caching_test.rb +0 -96
  73. data/test/no_serialization_scope_test.rb +0 -34
  74. data/test/serialization_test.rb +0 -392
  75. data/test/serializer_support_test.rb +0 -51
  76. data/test/serializer_test.rb +0 -1465
  77. 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: e77127a346e9bfdfb4b48152c333394b5c5e2e41
4
+ data.tar.gz: cc4ba7acbb64a83d588e6da78c54ace9e9309734
5
5
  SHA512:
6
- metadata.gz: cc3140d1676014d8ce4aa0add253d247c55652a689cb83e7f7f7a71a81ae8d7c601fc5e2d261d415e243857a479a15156d0a84a67beb1c72475ef51c063cdfca
7
- data.tar.gz: cfc92ac9bb7dfca07cebdd32ef4a120aa5784cc7f1a6bfc8a65900b553be736b174b6bbf22fb7ebd55e8295ea1d118373245396e3c0ac883e954ab27e925bca2
6
+ metadata.gz: fca71a58180a630765a4628c9202b775fb855c36d517546a6fa122166944cd14d79e968369d7fdabce45c6bd585b55a3e9c17ccd72b8b1287fe8eff0b8507167
7
+ data.tar.gz: dafdf5f8c3f57bdbaf141d05573459bc14f314a0a5bc6a30f94eb8f8d6f2e8d29649ba34187112c27c819536dd77a7983715b066c83283ef1434a8ea333669ff
data/.gitignore CHANGED
@@ -10,9 +10,12 @@ coverage
10
10
  doc/
11
11
  lib/bundler/man
12
12
  pkg
13
+ Vagrantfile
14
+ .vagrant
13
15
  rdoc
14
16
  spec/reports
15
17
  test/tmp
16
18
  test/version_tmp
17
19
  tmp
18
20
  *.swp
21
+ .ruby-version
data/.travis.yml CHANGED
@@ -1,28 +1,27 @@
1
1
  language: ruby
2
+
3
+ sudo: false
4
+
2
5
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
6
  - 1.9.3
6
7
  - 2.0.0
7
- - ree
8
- - jruby-18mode
8
+ - 2.1
9
+ - 2.2
9
10
  - jruby-19mode
10
11
  - rbx-2
11
- gemfile:
12
- - Gemfile
13
- - Gemfile.edge
12
+ - ruby-head
13
+
14
+ install:
15
+ - bundle install --retry=3
16
+
17
+ env:
18
+ - "RAILS_VERSION=3.2"
19
+ - "RAILS_VERSION=4.0"
20
+ - "RAILS_VERSION=4.1"
21
+ - "RAILS_VERSION=master"
22
+
14
23
  matrix:
15
24
  allow_failures:
16
- - gemfile: Gemfile.edge
17
- 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
25
+ - rvm: ruby-head
26
+ - env: "RAILS_VERSION=master"
27
+ - env: "RAILS_VERSION=3.2"
data/CHANGELOG.md CHANGED
@@ -1,67 +1,8 @@
1
- # UNRELEASED
2
-
3
- # VERSION 0.8.1
4
-
5
- * Fix bug whereby a serializer using 'options' would blow up.
6
-
7
- # VERSION 0.8.0
8
-
9
- * Attributes can now have optional types.
10
-
11
- * A new DefaultSerializer ensures that POROs behave the same way as ActiveModels.
12
-
13
- * If you wish to override ActiveRecord::Base#to_Json, you can now require
14
- 'active_record/serializer_override'. We don't recommend you do this, but
15
- many users do, so we've left it optional.
16
-
17
- * Fixed a bug where ActionController wouldn't always have MimeResponds.
18
-
19
- * An optinal caching feature allows you to cache JSON & hashes that AMS uses.
20
- Adding 'cached true' to your Serializers will turn on this cache.
21
-
22
- * URL helpers used inside of Engines now work properly.
23
-
24
- * Serializers now can filter attributes with `only` and `except`:
25
-
26
- ```
27
- UserSerializer.new(user, only: [:first_name, :last_name])
28
- UserSerializer.new(user, except: :first_name)
29
- ```
30
-
31
- * Basic Mongoid support. We now include our mixins in the right place.
32
-
33
- * On Ruby 1.8, we now generate an `id` method that properly serializes `id`
34
- columns. See issue #127 for more.
35
-
36
- * Add an alias for `scope` method to be the name of the context. By default
37
- this is `current_user`. The name is automatically set when using
38
- `serialization_scope` in the controller.
39
-
40
- * Pass through serialization options (such as `:include`) when a model
41
- has no serializer defined.
42
-
43
- # VERSION 0.7.0
44
-
45
- * ```embed_key``` option to allow embedding by attributes other than IDs
46
- * Fix rendering nil with custom serializer
47
- * Fix global ```self.root = false```
48
- * Add support for specifying the serializer for an association as a String
49
- * Able to specify keys on the attributes method
50
- * Serializer Reloading via ActiveSupport::DescendantsTracker
51
- * Reduce double map to once; Fixes datamapper eager loading.
52
-
53
- # VERSION 0.6.0
54
-
55
- * Serialize sets properly
56
- * Add root option to ArraySerializer
57
- * Support polymorphic associations
58
- * Support :each_serializer in ArraySerializer
59
- * Add `scope` method to easily access the scope in the serializer
60
- * Fix regression with Rails 3.2.6; add Rails 4 support
61
- * Allow serialization_scope to be disabled with serialization_scope nil
62
- * Array serializer should support pure ruby objects besides serializers
63
-
64
- # VERSION 0.5.0 (May 16, 2012)
65
-
66
- * First tagged version
67
- * Changes generators to always generate an ApplicationSerializer
1
+ ### 0.10.0
2
+
3
+ * adds support for `meta` and `meta_key` [@kurko]
4
+ * adds method to override association [adcb99e, @kurko]
5
+ * adds `has_one` attribute for backwards compatibility [@ggordon]
6
+ * updates JSON API support to RC3 [@mateomurphy]
7
+ * adds fragment cache support [@joaomdmoura]
8
+ * adds cache support to attributes and associations [@joaomdmoura]
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,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify gem dependencies in active_model_serializers.gemspec
3
+ # Specify your gem's dependencies in active_model_serializers.gemspec
4
4
  gemspec
5
+
6
+ gem "minitest"
7
+
8
+ version = ENV["RAILS_VERSION"] || "4.1"
9
+
10
+ if version == "master"
11
+ gem "rails", github: "rails/rails"
12
+
13
+ # ugh https://github.com/rails/rails/issues/16063#issuecomment-48090125
14
+ gem "arel", github: "rails/arel"
15
+ else
16
+ gem "rails", "~> #{version}.0"
17
+ 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
-