active_model_serializers 0.8.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +122 -5
  3. data/CONTRIBUTING.md +20 -0
  4. data/DESIGN.textile +4 -4
  5. data/{MIT-LICENSE.txt → MIT-LICENSE} +0 -0
  6. data/README.md +396 -95
  7. data/lib/action_controller/serialization.rb +50 -12
  8. data/lib/action_controller/serialization_test_case.rb +79 -0
  9. data/lib/active_model/array_serializer.rb +47 -78
  10. data/lib/active_model/default_serializer.rb +32 -0
  11. data/lib/active_model/serializable/utils.rb +16 -0
  12. data/lib/active_model/serializable.rb +62 -0
  13. data/lib/active_model/serializer/association/has_many.rb +39 -0
  14. data/lib/active_model/serializer/association/has_one.rb +25 -0
  15. data/lib/active_model/serializer/association.rb +58 -0
  16. data/lib/active_model/serializer/config.rb +31 -0
  17. data/lib/active_model/serializer/generators/resource_override.rb +13 -0
  18. data/lib/{generators → active_model/serializer/generators}/serializer/USAGE +0 -0
  19. data/lib/active_model/serializer/generators/serializer/scaffold_controller_generator.rb +14 -0
  20. data/lib/active_model/serializer/generators/serializer/serializer_generator.rb +37 -0
  21. data/lib/active_model/serializer/generators/serializer/templates/controller.rb +93 -0
  22. data/lib/active_model/serializer/generators/serializer/templates/serializer.rb +8 -0
  23. data/lib/active_model/serializer/railtie.rb +18 -0
  24. data/lib/active_model/{serializers → serializer}/version.rb +1 -1
  25. data/lib/active_model/serializer.rb +214 -423
  26. data/lib/active_model/serializer_support.rb +5 -0
  27. data/lib/active_model_serializers/mime_types.rb +14 -0
  28. data/lib/active_model_serializers.rb +12 -87
  29. data/test/fixtures/active_record.rb +96 -0
  30. data/test/fixtures/poro.rb +187 -0
  31. data/test/fixtures/template.html.erb +1 -0
  32. data/test/integration/action_controller/namespaced_serialization_test.rb +105 -0
  33. data/test/integration/action_controller/serialization_test.rb +287 -0
  34. data/test/integration/action_controller/serialization_test_case_test.rb +71 -0
  35. data/test/integration/active_record/active_record_test.rb +94 -0
  36. data/test/integration/generators/resource_generator_test.rb +26 -0
  37. data/test/integration/generators/scaffold_controller_generator_test.rb +64 -0
  38. data/test/integration/generators/serializer_generator_test.rb +41 -0
  39. data/test/test_app.rb +14 -0
  40. data/test/test_helper.rb +10 -18
  41. data/test/unit/active_model/array_serializer/except_test.rb +18 -0
  42. data/test/unit/active_model/array_serializer/key_format_test.rb +18 -0
  43. data/test/unit/active_model/array_serializer/meta_test.rb +53 -0
  44. data/test/unit/active_model/array_serializer/only_test.rb +18 -0
  45. data/test/unit/active_model/array_serializer/options_test.rb +16 -0
  46. data/test/unit/active_model/array_serializer/root_test.rb +102 -0
  47. data/test/unit/active_model/array_serializer/scope_test.rb +24 -0
  48. data/test/unit/active_model/array_serializer/serialization_test.rb +216 -0
  49. data/test/unit/active_model/default_serializer_test.rb +13 -0
  50. data/test/unit/active_model/serializer/associations/build_serializer_test.rb +36 -0
  51. data/test/unit/active_model/serializer/associations_test.rb +19 -0
  52. data/test/unit/active_model/serializer/attributes_test.rb +57 -0
  53. data/test/unit/active_model/serializer/config_test.rb +91 -0
  54. data/test/unit/active_model/serializer/filter_test.rb +69 -0
  55. data/test/unit/active_model/serializer/has_many_polymorphic_test.rb +189 -0
  56. data/test/unit/active_model/serializer/has_many_test.rb +265 -0
  57. data/test/unit/active_model/serializer/has_one_and_has_many_test.rb +27 -0
  58. data/test/unit/active_model/serializer/has_one_polymorphic_test.rb +196 -0
  59. data/test/unit/active_model/serializer/has_one_test.rb +253 -0
  60. data/test/unit/active_model/serializer/key_format_test.rb +25 -0
  61. data/test/unit/active_model/serializer/meta_test.rb +39 -0
  62. data/test/unit/active_model/serializer/options_test.rb +42 -0
  63. data/test/unit/active_model/serializer/root_test.rb +117 -0
  64. data/test/unit/active_model/serializer/scope_test.rb +49 -0
  65. data/test/unit/active_model/serializer/url_helpers_test.rb +35 -0
  66. metadata +107 -64
  67. data/.gitignore +0 -18
  68. data/.travis.yml +0 -28
  69. data/Gemfile +0 -4
  70. data/Gemfile.edge +0 -9
  71. data/Rakefile +0 -18
  72. data/active_model_serializers.gemspec +0 -24
  73. data/bench/perf.rb +0 -43
  74. data/cruft.md +0 -19
  75. data/lib/active_model/serializer/associations.rb +0 -233
  76. data/lib/active_record/serializer_override.rb +0 -16
  77. data/lib/generators/resource_override.rb +0 -13
  78. data/lib/generators/serializer/serializer_generator.rb +0 -42
  79. data/lib/generators/serializer/templates/serializer.rb +0 -19
  80. data/test/array_serializer_test.rb +0 -75
  81. data/test/association_test.rb +0 -592
  82. data/test/caching_test.rb +0 -96
  83. data/test/generators_test.rb +0 -85
  84. data/test/no_serialization_scope_test.rb +0 -34
  85. data/test/serialization_scope_name_test.rb +0 -67
  86. data/test/serialization_test.rb +0 -392
  87. data/test/serializer_support_test.rb +0 -51
  88. data/test/serializer_test.rb +0 -1465
  89. 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: f42ff2b93cdc399b58c219efd12add5e5757612a
4
+ data.tar.gz: 624cba1a3b71a9aa668f7612b1937a889b98d22e
5
5
  SHA512:
6
- metadata.gz: cc3140d1676014d8ce4aa0add253d247c55652a689cb83e7f7f7a71a81ae8d7c601fc5e2d261d415e243857a479a15156d0a84a67beb1c72475ef51c063cdfca
7
- data.tar.gz: cfc92ac9bb7dfca07cebdd32ef4a120aa5784cc7f1a6bfc8a65900b553be736b174b6bbf22fb7ebd55e8295ea1d118373245396e3c0ac883e954ab27e925bca2
6
+ metadata.gz: 4abbf3c69e8de7d29b24aab129229e5bfa6c94eb46c73212016d02592ea8fb3d3fbba6eb0effef1f8b0b3a03ca359f71933678fe98da58db21590f76f1c02dd3
7
+ data.tar.gz: b5730a2a45db222ee3b331e1ef3a1ba68efc86c17dc7d2c8172c59d4bb4273624031085d331b96078f861d764cb7b8a58d8405ffd9c081af5268b7b319688e94
data/CHANGELOG.md CHANGED
@@ -1,4 +1,121 @@
1
- # UNRELEASED
1
+ ## 0.09.x
2
+
3
+ ### [0-9-stable](https://github.com/rails-api/active_model_serializers/compare/v0.9.4...0-9-stable)
4
+
5
+ ### [v0.9.4 (2015-01-05)](https://github.com/rails-api/active_model_serializers/compare/v0.9.3...v0.9.4)
6
+
7
+ - [#752](https://github.com/rails-api/active_model_serializers/pull/752) Tiny improvement of README 0-9-stable (@basiam)
8
+ - [#749](https://github.com/rails-api/active_model_serializers/pull/749) remove trailing whitespace (@shwoodard)
9
+ - [#717](https://github.com/rails-api/active_model_serializers/pull/717) fixed issue with rendering Hash which appears in rails 4.2.0.beta4 (@kurko, @greshny)
10
+ - [#790](https://github.com/rails-api/active_model_serializers/pull/790) pass context to ArraySerializer (@lanej)
11
+ - [#797](https://github.com/rails-api/active_model_serializers/pull/797) Fix and test for #490 (@afn)
12
+ - [#813](https://github.com/rails-api/active_model_serializers/pull/813) Allow to define custom serializer for given class (@jtomaszewski)
13
+ - [#841](https://github.com/rails-api/active_model_serializers/pull/841) Fix issue with embedding multiple associations under the same root key (@antstorm)
14
+ - [#748](https://github.com/rails-api/active_model_serializers/pull/748) Propagate serialization_options across associations (@raphaelpereira)
15
+
16
+ ### [v0.9.3 (2015/01/21 20:29 +00:00)](https://github.com/rails-api/active_model_serializers/compare/v0.9.2...v0.9.3)
17
+
18
+ Features:
19
+ - [#774](https://github.com/rails-api/active_model_serializers/pull/774) Fix nested include attributes (@nhocki)
20
+ - [#771](https://github.com/rails-api/active_model_serializers/pull/771) Make linked resource type names consistent with root names (@sweatypitts)
21
+ - [#696](https://github.com/rails-api/active_model_serializers/pull/696) Explicitly set serializer for associations (@ggordon)
22
+ - [#700](https://github.com/rails-api/active_model_serializers/pull/700) sparse fieldsets (@arenoir)
23
+ - [#768](https://github.com/rails-api/active_model_serializers/pull/768) Adds support for `meta` and `meta_key` attribute (@kurko)
24
+
25
+ ### [v0.9.2](https://github.com/rails-api/active_model_serializers/compare/v0.9.1...v0.9.2)
26
+
27
+ ### [v0.9.1 (2014/12/04 11:54 +00:00)](https://github.com/rails-api/active_model_serializers/compare/v0.9.0...v0.9.1)
28
+
29
+ - [#707](https://github.com/rails-api/active_model_serializers/pull/707) A Friendly Note on Which AMS Version to Use (@jherdman)
30
+ - [#730](https://github.com/rails-api/active_model_serializers/pull/730) Fixes nested has_many links in JSONAPI (@kurko)
31
+ - [#718](https://github.com/rails-api/active_model_serializers/pull/718) Allow overriding the adapter with render option (@ggordon)
32
+ - [#720](https://github.com/rails-api/active_model_serializers/pull/720) Rename attribute with :key (0.8.x compatibility) (@ggordon)
33
+ - [#728](https://github.com/rails-api/active_model_serializers/pull/728) Use type as key for linked resources (@kurko)
34
+ - [#729](https://github.com/rails-api/active_model_serializers/pull/729) Use the new beta build env on Travis (@joshk)
35
+ - [#703](https://github.com/rails-api/active_model_serializers/pull/703) Support serializer and each_serializer options in renderer (@ggordon, @mieko)
36
+ - [#727](https://github.com/rails-api/active_model_serializers/pull/727) Includes links inside of linked resources (@kurko)
37
+ - [#726](https://github.com/rails-api/active_model_serializers/pull/726) Bugfix: include nested has_many associations (@kurko)
38
+ - [#722](https://github.com/rails-api/active_model_serializers/pull/722) Fix infinite recursion (@ggordon)
39
+ - [#1](https://github.com/rails-api/active_model_serializers/pull/1) Allow for the implicit use of ArraySerializer when :each_serializer is specified (@mieko)
40
+ - [#692](https://github.com/rails-api/active_model_serializers/pull/692) Include 'linked' member for json-api collections (@ggordon)
41
+ - [#714](https://github.com/rails-api/active_model_serializers/pull/714) Define as_json instead of to_json (@guilleiguaran)
42
+ - [#710](https://github.com/rails-api/active_model_serializers/pull/710) JSON-API: Don't include linked section if associations are empty (@guilleiguaran)
43
+ - [#711](https://github.com/rails-api/active_model_serializers/pull/711) Fixes rbx gems bundling on TravisCI (@kurko)
44
+ - [#709](https://github.com/rails-api/active_model_serializers/pull/709) Add type key when association name is different than object type (@guilleiguaran)
45
+ - [#708](https://github.com/rails-api/active_model_serializers/pull/708) Handle correctly null associations (@guilleiguaran)
46
+ - [#691](https://github.com/rails-api/active_model_serializers/pull/691) Fix embed option for associations (@jacob-s-son)
47
+ - [#689](https://github.com/rails-api/active_model_serializers/pull/689) Fix support for custom root in JSON-API adapter (@guilleiguaran)
48
+ - [#685](https://github.com/rails-api/active_model_serializers/pull/685) Serialize ids as strings in JSON-API adapter (@guilleiguaran)
49
+ - [#684](https://github.com/rails-api/active_model_serializers/pull/684) Refactor adapters to implement support for array serialization (@guilleiguaran)
50
+ - [#682](https://github.com/rails-api/active_model_serializers/pull/682) Include root by default in JSON-API serializers (@guilleiguaran)
51
+ - [#625](https://github.com/rails-api/active_model_serializers/pull/625) Add DSL for urls (@JordanFaust)
52
+ - [#677](https://github.com/rails-api/active_model_serializers/pull/677) Add support for embed: :ids option for in associations (@guilleiguaran)
53
+ - [#681](https://github.com/rails-api/active_model_serializers/pull/681) Check superclasses for Serializers (@quainjn)
54
+ - [#680](https://github.com/rails-api/active_model_serializers/pull/680) Add support for root keys (@NullVoxPopuli)
55
+ - [#675](https://github.com/rails-api/active_model_serializers/pull/675) Support Rails 4.2.0 (@tricknotes)
56
+ - [#667](https://github.com/rails-api/active_model_serializers/pull/667) Require only activemodel instead of full rails (@guilleiguaran)
57
+ - [#653](https://github.com/rails-api/active_model_serializers/pull/653) Add "_test" suffix to JsonApi::HasManyTest filename. (@alexgenco)
58
+ - [#631](https://github.com/rails-api/active_model_serializers/pull/631) Update build badge URL (@craiglittle)
59
+
60
+ ### [v0.9.0](https://github.com/rails-api/active_model_serializers/compare/v0.9.0.alpha1...v0.9.0)
61
+
62
+ ### [0.9.0.alpha1 - January 7, 2014](https://github.com/rails-api/active_model_serializers/compare/d72b66d4c...v0.9.0.alpha1)
63
+
64
+ ### 0.9.0.pre
65
+
66
+ * The following methods were removed
67
+ - Model#active\_model\_serializer
68
+ - Serializer#include!
69
+ - Serializer#include?
70
+ - Serializer#attr\_disabled=
71
+ - Serializer#cache
72
+ - Serializer#perform\_caching
73
+ - Serializer#schema (needs more discussion)
74
+ - Serializer#attribute
75
+ - Serializer#include\_#{name}? (filter method added)
76
+ - Serializer#attributes (took a hash)
77
+
78
+ * The following things were added
79
+ - Serializer#filter method
80
+ - CONFIG object
81
+
82
+ * Remove support for ruby 1.8 versions.
83
+
84
+ * Require rails >= 3.2.
85
+
86
+ * Serializers for associations are being looked up in a parent serializer's namespace first. Same with controllers' namespaces.
87
+
88
+ * Added a "prefix" option in case you want to use a different version of serializer.
89
+
90
+ * Serializers default namespace can be set in `default_serializer_options` and inherited by associations.
91
+
92
+ # VERSION 0.9.0.pre
93
+
94
+ * The following methods were removed
95
+ - Model#active\_model\_serializer
96
+ - Serializer#include!
97
+ - Serializer#include?
98
+ - Serializer#attr\_disabled=
99
+ - Serializer#cache
100
+ - Serializer#perform\_caching
101
+ - Serializer#schema (needs more discussion)
102
+ - Serializer#attribute
103
+ - Serializer#include\_#{name}? (filter method added)
104
+ - Serializer#attributes (took a hash)
105
+
106
+ * The following things were added
107
+ - Serializer#filter method
108
+ - CONFIG object
109
+
110
+ * Remove support for ruby 1.8 versions.
111
+
112
+ * Require rails >= 3.2.
113
+
114
+ * Serializers for associations are being looked up in a parent serializer's namespace first. Same with controllers' namespaces.
115
+
116
+ * Added a "prefix" option in case you want to use a different version of serializer.
117
+
118
+ * Serializers default namespace can be set in `default_serializer_options` and inherited by associations.
2
119
 
3
120
  # VERSION 0.8.1
4
121
 
@@ -10,13 +127,13 @@
10
127
 
11
128
  * A new DefaultSerializer ensures that POROs behave the same way as ActiveModels.
12
129
 
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
130
+ * If you wish to override ActiveRecord::Base#to\_Json, you can now require
131
+ 'active\_record/serializer\_override'. We don't recommend you do this, but
15
132
  many users do, so we've left it optional.
16
133
 
17
134
  * Fixed a bug where ActionController wouldn't always have MimeResponds.
18
135
 
19
- * An optinal caching feature allows you to cache JSON & hashes that AMS uses.
136
+ * An optional caching feature allows you to cache JSON & hashes that AMS uses.
20
137
  Adding 'cached true' to your Serializers will turn on this cache.
21
138
 
22
139
  * URL helpers used inside of Engines now work properly.
@@ -61,7 +178,7 @@
61
178
  * Allow serialization_scope to be disabled with serialization_scope nil
62
179
  * Array serializer should support pure ruby objects besides serializers
63
180
 
64
- # VERSION 0.5.0 (May 16, 2012)
181
+ # VERSION 0.5.0
65
182
 
66
183
  * First tagged version
67
184
  * Changes generators to always generate an ApplicationSerializer
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,20 @@
1
+ Contributing to AMS
2
+ ===================
3
+
4
+ First of all, **thank you**!
5
+
6
+ Now, for the details:
7
+
8
+ Please file issues on the [GitHub Issues
9
+ list](https://github.com/rails-api/active_model_serializers/issues).
10
+
11
+ Please discuss new features or ask for feedback about a new feature [on
12
+ rails-api-core](https://groups.google.com/forum/#!forum/rails-api-core).
13
+
14
+ If you want a feature implemented, the best way to get it done is to submit a
15
+ pull request that implements it. Tests and docs would be nice.
16
+
17
+ Please include a CHANGELOG with all entries that change behavior.
18
+
19
+ :heart: :sparkling_heart: :heart:
20
+
data/DESIGN.textile CHANGED
@@ -358,8 +358,8 @@ Here is an example:
358
358
 
359
359
  <pre lang="ruby">
360
360
  class UserSerializer < ActiveModel::Serializer
361
- has_many :followed_posts, :key => :posts
362
- has_one :owned_account, :key => :account
361
+ has_many :followed_posts, key: :posts
362
+ has_one :owned_account, key: :account
363
363
  end
364
364
  </pre>
365
365
 
@@ -370,8 +370,8 @@ to set it explicitly:
370
370
 
371
371
  <pre lang="ruby">
372
372
  class UserSerializer < ActiveModel::Serializer
373
- has_many :followed_posts, :key => :posts, :serializer => CustomPostSerializer
374
- has_one :owne_account, :key => :account, :serializer => PrivateAccountSerializer
373
+ has_many :followed_posts, key: :posts, serializer: CustomPostSerializer
374
+ has_one :owne_account, key: :account, serializer: PrivateAccountSerializer
375
375
  end
376
376
  </pre>
377
377
 
File without changes