active_model_serializers 0.10.0.rc2 → 0.10.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +82 -0
- data/.rubocop_todo.yml +315 -0
- data/.simplecov +99 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +9 -3
- data/Gemfile +39 -8
- data/README.md +55 -31
- data/Rakefile +29 -2
- data/active_model_serializers.gemspec +37 -13
- data/appveyor.yml +25 -0
- data/docs/README.md +29 -0
- data/docs/general/adapters.md +110 -0
- data/docs/general/configuration_options.md +11 -0
- data/docs/general/getting_started.md +73 -0
- data/docs/howto/add_pagination_links.md +112 -0
- data/docs/howto/add_root_key.md +51 -0
- data/docs/howto/outside_controller_use.md +42 -0
- data/lib/action_controller/serialization.rb +24 -33
- data/lib/active_model/serializable_resource.rb +70 -0
- data/lib/active_model/serializer.rb +50 -131
- data/lib/active_model/serializer/adapter.rb +84 -21
- data/lib/active_model/serializer/adapter/flatten_json.rb +9 -9
- data/lib/active_model/serializer/adapter/fragment_cache.rb +10 -13
- data/lib/active_model/serializer/adapter/json.rb +25 -28
- data/lib/active_model/serializer/adapter/json/fragment_cache.rb +2 -12
- data/lib/active_model/serializer/adapter/json_api.rb +100 -98
- data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +4 -14
- data/lib/active_model/serializer/adapter/json_api/pagination_links.rb +50 -0
- data/lib/active_model/serializer/adapter/null.rb +2 -8
- data/lib/active_model/serializer/array_serializer.rb +22 -17
- data/lib/active_model/serializer/association.rb +20 -0
- data/lib/active_model/serializer/associations.rb +97 -0
- data/lib/active_model/serializer/belongs_to_reflection.rb +10 -0
- data/lib/active_model/serializer/collection_reflection.rb +7 -0
- data/lib/active_model/serializer/configuration.rb +1 -0
- data/lib/active_model/serializer/fieldset.rb +7 -7
- data/lib/active_model/serializer/has_many_reflection.rb +10 -0
- data/lib/active_model/serializer/has_one_reflection.rb +10 -0
- data/lib/active_model/serializer/lint.rb +129 -0
- data/lib/active_model/serializer/railtie.rb +7 -0
- data/lib/active_model/serializer/reflection.rb +74 -0
- data/lib/active_model/serializer/singular_reflection.rb +7 -0
- data/lib/active_model/serializer/utils.rb +35 -0
- data/lib/active_model/serializer/version.rb +1 -1
- data/lib/active_model_serializers.rb +28 -14
- data/lib/generators/serializer/serializer_generator.rb +7 -7
- data/lib/generators/serializer/templates/{serializer.rb → serializer.rb.erb} +2 -2
- data/lib/tasks/rubocop.rake +0 -0
- data/test/action_controller/adapter_selector_test.rb +3 -3
- data/test/action_controller/explicit_serializer_test.rb +9 -9
- data/test/action_controller/json_api/linked_test.rb +179 -0
- data/test/action_controller/json_api/pagination_test.rb +116 -0
- data/test/action_controller/serialization_scope_name_test.rb +10 -6
- data/test/action_controller/serialization_test.rb +149 -112
- data/test/active_record_test.rb +9 -0
- data/test/adapter/fragment_cache_test.rb +11 -1
- data/test/adapter/json/belongs_to_test.rb +4 -5
- data/test/adapter/json/collection_test.rb +30 -21
- data/test/adapter/json/has_many_test.rb +20 -9
- data/test/adapter/json_api/belongs_to_test.rb +38 -38
- data/test/adapter/json_api/collection_test.rb +22 -23
- data/test/adapter/json_api/has_many_embed_ids_test.rb +2 -2
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +4 -4
- data/test/adapter/json_api/has_many_test.rb +54 -19
- data/test/adapter/json_api/has_one_test.rb +28 -8
- data/test/adapter/json_api/json_api_test.rb +37 -0
- data/test/adapter/json_api/linked_test.rb +75 -75
- data/test/adapter/json_api/pagination_links_test.rb +115 -0
- data/test/adapter/json_api/resource_type_config_test.rb +59 -0
- data/test/adapter/json_test.rb +18 -5
- data/test/adapter_test.rb +10 -11
- data/test/array_serializer_test.rb +63 -5
- data/test/capture_warnings.rb +65 -0
- data/test/fixtures/active_record.rb +56 -0
- data/test/fixtures/poro.rb +60 -29
- data/test/generators/scaffold_controller_generator_test.rb +1 -2
- data/test/generators/serializer_generator_test.rb +17 -12
- data/test/lint_test.rb +37 -0
- data/test/logger_test.rb +18 -0
- data/test/poro_test.rb +9 -0
- data/test/serializable_resource_test.rb +27 -0
- data/test/serializers/adapter_for_test.rb +123 -3
- data/test/serializers/association_macros_test.rb +36 -0
- data/test/serializers/associations_test.rb +70 -47
- data/test/serializers/attribute_test.rb +28 -4
- data/test/serializers/attributes_test.rb +8 -14
- data/test/serializers/cache_test.rb +58 -31
- data/test/serializers/fieldset_test.rb +3 -4
- data/test/serializers/meta_test.rb +42 -28
- data/test/serializers/root_test.rb +21 -0
- data/test/serializers/serializer_for_test.rb +1 -1
- data/test/support/rails_app.rb +21 -0
- data/test/support/serialization_testing.rb +13 -0
- data/test/support/simplecov.rb +6 -0
- data/test/support/stream_capture.rb +50 -0
- data/test/support/test_case.rb +5 -0
- data/test/test_helper.rb +41 -29
- data/test/utils/include_args_to_hash_test.rb +79 -0
- metadata +123 -17
- data/test/action_controller/json_api_linked_test.rb +0 -179
- data/test/action_controller/rescue_from_test.rb +0 -32
- data/test/serializers/urls_test.rb +0 -26
data/.travis.yml
CHANGED
@@ -2,6 +2,9 @@ language: ruby
|
|
2
2
|
|
3
3
|
sudo: false
|
4
4
|
|
5
|
+
cache:
|
6
|
+
bundler: true
|
7
|
+
|
5
8
|
rvm:
|
6
9
|
- 1.9.3
|
7
10
|
- 2.0.0
|
@@ -14,6 +17,10 @@ rvm:
|
|
14
17
|
install:
|
15
18
|
- bundle install --retry=3
|
16
19
|
|
20
|
+
script:
|
21
|
+
- bundle exec rake
|
22
|
+
- bundle exec rake rubocop
|
23
|
+
|
17
24
|
env:
|
18
25
|
- "RAILS_VERSION=4.0"
|
19
26
|
- "RAILS_VERSION=4.1"
|
@@ -24,3 +31,4 @@ matrix:
|
|
24
31
|
allow_failures:
|
25
32
|
- rvm: ruby-head
|
26
33
|
- env: "RAILS_VERSION=master"
|
34
|
+
fast_finish: true
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
### 0.10.0
|
2
2
|
|
3
|
+
* adds adapters pattern
|
3
4
|
* adds support for `meta` and `meta_key` [@kurko]
|
4
|
-
* adds method to override association [
|
5
|
+
* adds method to override association [@kurko]
|
5
6
|
* adds `has_one` attribute for backwards compatibility [@ggordon]
|
6
|
-
*
|
7
|
+
* adds JSON API support 1.0 [@benedikt]
|
7
8
|
* adds fragment cache support [@joaomdmoura]
|
8
|
-
* adds cache support to attributes and associations [@joaomdmoura]
|
9
|
+
* adds cache support to attributes and associations [@joaomdmoura]
|
10
|
+
* uses model name to determine the type [@lsylvester]
|
11
|
+
* remove root key option and split JSON adapter [@joaomdmoura]
|
12
|
+
* adds FlattenJSON as default adapter [@joaomdmoura]
|
13
|
+
* adds support for `pagination links` at top level of JsonApi adapter [@bacarini]
|
14
|
+
* adds extended format for `include` option to JSONAPI adapter [@beauby]
|
data/Gemfile
CHANGED
@@ -1,17 +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
7
|
# Specify your gem's dependencies in active_model_serializers.gemspec
|
4
8
|
gemspec
|
5
9
|
|
6
|
-
|
10
|
+
version = ENV['RAILS_VERSION'] || '4.2'
|
7
11
|
|
8
|
-
version
|
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
|
9
31
|
|
10
|
-
|
11
|
-
gem
|
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
|
12
38
|
|
13
|
-
|
14
|
-
gem
|
15
|
-
|
16
|
-
|
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
|
17
48
|
end
|
data/README.md
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
# ActiveModel::
|
1
|
+
# ActiveModel::Serializer
|
2
2
|
|
3
3
|
[](https://travis-ci.org/rails-api/active_model_serializers)
|
4
|
+
<a href="https://codeclimate.com/github/rails-api/active_model_serializers"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/gpa.svg" /></a>
|
5
|
+
<a href="https://codeclimate.com/github/rails-api/active_model_serializers/coverage"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/coverage.svg" /></a>
|
4
6
|
|
5
|
-
|
7
|
+
_Windows Build Status -_ [](https://ci.appveyor.com/project/joaomdmoura/active-model-serializers/branch/master)
|
8
|
+
|
9
|
+
ActiveModel::Serializer brings convention over configuration to your JSON generation.
|
6
10
|
|
7
11
|
AMS does this through two components: **serializers** and **adapters**.
|
8
12
|
Serializers describe _which_ attributes and relationships should be serialized.
|
9
13
|
Adapters describe _how_ attributes and relationships should be serialized.
|
10
14
|
|
11
|
-
By default AMS will use the **Json Adapter**. But we strongly advise you to use JsonApi Adapter that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
|
15
|
+
By default AMS will use the **Flatten Json Adapter**. But we strongly advise you to use **JsonApi Adapter** that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
|
12
16
|
Check how to change the adapter in the sections bellow.
|
13
17
|
|
14
18
|
# RELEASE CANDIDATE, PLEASE READ
|
@@ -23,7 +27,7 @@ architecture. We'd love your help. [Learn how you can help here.](https://github
|
|
23
27
|
## Example
|
24
28
|
|
25
29
|
Given two models, a `Post(title: string, body: text)` and a
|
26
|
-
`Comment(name:string, body:text, post_id:integer)`, you will have two
|
30
|
+
`Comment(name: string, body: text, post_id: integer)`, you will have two
|
27
31
|
serializers:
|
28
32
|
|
29
33
|
```ruby
|
@@ -32,8 +36,6 @@ class PostSerializer < ActiveModel::Serializer
|
|
32
36
|
attributes :title, :body
|
33
37
|
|
34
38
|
has_many :comments
|
35
|
-
|
36
|
-
url :post
|
37
39
|
end
|
38
40
|
```
|
39
41
|
|
@@ -44,8 +46,6 @@ class CommentSerializer < ActiveModel::Serializer
|
|
44
46
|
attributes :name, :body
|
45
47
|
|
46
48
|
belongs_to :post
|
47
|
-
|
48
|
-
url [:post, :comment]
|
49
49
|
end
|
50
50
|
```
|
51
51
|
|
@@ -66,6 +66,12 @@ ActiveModel::Serializer.config.adapter = :json_api
|
|
66
66
|
You won't need to implement an adapter unless you wish to use a new format or
|
67
67
|
media type with AMS.
|
68
68
|
|
69
|
+
If you want to have a root key on your responses you should use the Json adapter, instead of the default FlattenJson:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
ActiveModel::Serializer.config.adapter = :json
|
73
|
+
```
|
74
|
+
|
69
75
|
If you would like the key in the outputted JSON to be different from its name in ActiveRecord, you can use the :key option to customize it:
|
70
76
|
|
71
77
|
```ruby
|
@@ -112,7 +118,7 @@ If you wish to use a serializer other than the default, you can explicitly pass
|
|
112
118
|
render json: @posts, each_serializer: PostPreviewSerializer
|
113
119
|
|
114
120
|
# Or, you can explicitly provide the collection serializer as well
|
115
|
-
render json: @posts, serializer:
|
121
|
+
render json: @posts, serializer: CollectionSerializer, each_serializer: PostPreviewSerializer
|
116
122
|
```
|
117
123
|
|
118
124
|
### Meta
|
@@ -130,16 +136,23 @@ The key can be customized using `meta_key` option.
|
|
130
136
|
render json: @post, meta: { total: 10 }, meta_key: "custom_meta"
|
131
137
|
```
|
132
138
|
|
133
|
-
`meta` will only be included in your response if
|
134
|
-
it won't be included in array responses.
|
139
|
+
`meta` will only be included in your response if you are using an Adapter that supports `root`, as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.
|
135
140
|
|
136
|
-
###
|
141
|
+
### Using a serializer without `render`
|
137
142
|
|
138
|
-
|
139
|
-
call
|
143
|
+
At times, you might want to use a serializer without rendering it to the view. For those cases, you can create an instance of `ActiveModel::SerializableResource` with
|
144
|
+
the resource you want to be serialized and call `.serializable_hash`.
|
140
145
|
|
141
146
|
```ruby
|
142
|
-
|
147
|
+
def create
|
148
|
+
@message = current_user.messages.create!(message_params)
|
149
|
+
MessageCreationWorker.perform(serialized_message)
|
150
|
+
head 204
|
151
|
+
end
|
152
|
+
|
153
|
+
def serialized_message
|
154
|
+
ActiveModel::SerializableResource.new(@message).serializable_hash
|
155
|
+
end
|
143
156
|
```
|
144
157
|
|
145
158
|
### Overriding association methods
|
@@ -176,17 +189,27 @@ end
|
|
176
189
|
|
177
190
|
### Built in Adapters
|
178
191
|
|
192
|
+
#### FlattenJSON
|
193
|
+
|
194
|
+
It's the default adapter, it generates a json response without a root key.
|
195
|
+
Doesn't follow any specifc convention.
|
196
|
+
|
197
|
+
#### JSON
|
198
|
+
|
199
|
+
It also generates a json response but always with a root key. The root key **can't be overridden**, and will be automatically defined accordingly with the objects being serialized.
|
200
|
+
Doesn't follow any specifc convention.
|
201
|
+
|
179
202
|
#### JSONAPI
|
180
203
|
|
181
|
-
This adapter follows
|
204
|
+
This adapter follows 1.0 of the format specified in
|
182
205
|
[jsonapi.org/format](http://jsonapi.org/format). It will include the associated
|
183
206
|
resources in the `"included"` member when the resource names are included in the
|
184
|
-
`include` option.
|
207
|
+
`include` option. Including nested associated resources is also supported.
|
185
208
|
|
186
209
|
```ruby
|
187
|
-
render @posts, include: ['
|
210
|
+
render @posts, include: ['author', 'comments', 'comments.author']
|
188
211
|
# or
|
189
|
-
render @posts, include: '
|
212
|
+
render @posts, include: 'author,comments,comments.author'
|
190
213
|
```
|
191
214
|
|
192
215
|
## Installation
|
@@ -229,8 +252,6 @@ class PostSerializer < ActiveModel::Serializer
|
|
229
252
|
|
230
253
|
has_many :comments
|
231
254
|
has_one :author
|
232
|
-
|
233
|
-
url :post
|
234
255
|
end
|
235
256
|
```
|
236
257
|
|
@@ -241,15 +262,13 @@ class CommentSerializer < ActiveModel::Serializer
|
|
241
262
|
attributes :name, :body
|
242
263
|
|
243
264
|
belongs_to :post_id
|
244
|
-
|
245
|
-
url [:post, :comment]
|
246
265
|
end
|
247
266
|
```
|
248
267
|
|
249
268
|
The attribute names are a **whitelist** of attributes to be serialized.
|
250
269
|
|
251
270
|
The `has_many`, `has_one`, and `belongs_to` declarations describe relationships between
|
252
|
-
resources. By default, when you serialize a `Post`, you will get its `
|
271
|
+
resources. By default, when you serialize a `Post`, you will get its `Comments`
|
253
272
|
as well.
|
254
273
|
|
255
274
|
You may also use the `:serializer` option to specify a custom serializer class, for example:
|
@@ -258,8 +277,17 @@ You may also use the `:serializer` option to specify a custom serializer class,
|
|
258
277
|
has_many :comments, serializer: CommentPreviewSerializer
|
259
278
|
```
|
260
279
|
|
261
|
-
|
262
|
-
|
280
|
+
And you can change the JSON key that the serializer should use for a particular association:
|
281
|
+
|
282
|
+
```ruby
|
283
|
+
has_many :comments, key: :reviews
|
284
|
+
```
|
285
|
+
|
286
|
+
## Pagination
|
287
|
+
|
288
|
+
Pagination links will be included in your response automatically as long as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate) and if you are using a ```JSON-API``` adapter.
|
289
|
+
|
290
|
+
Although the others adapters does not have this feature, it is possible to implement pagination links to `JSON` adapter. For more information about it, please see in our docs [How to add pagination links](https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/add_pagination_links.md)
|
263
291
|
|
264
292
|
## Caching
|
265
293
|
|
@@ -272,7 +300,7 @@ The cache support is optimized to use the cached object in multiple request. An
|
|
272
300
|
|
273
301
|
**[NOTE] Every object is individually cached.**
|
274
302
|
|
275
|
-
**[NOTE] The cache is automatically expired after
|
303
|
+
**[NOTE] The cache is automatically expired after an object is updated, but it's not deleted.**
|
276
304
|
|
277
305
|
```ruby
|
278
306
|
cache(options = nil) # options: ```{key, expires_in, compress, force, race_condition_ttl}```
|
@@ -286,8 +314,6 @@ class PostSerializer < ActiveModel::Serializer
|
|
286
314
|
attributes :title, :body
|
287
315
|
|
288
316
|
has_many :comments
|
289
|
-
|
290
|
-
url :post
|
291
317
|
end
|
292
318
|
```
|
293
319
|
|
@@ -311,8 +337,6 @@ class PostSerializer < ActiveModel::Serializer
|
|
311
337
|
attributes :title, :body
|
312
338
|
|
313
339
|
has_many :comments
|
314
|
-
|
315
|
-
url :post
|
316
340
|
end
|
317
341
|
```
|
318
342
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,36 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'simplecov'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'bundler/gem_tasks'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubocop'
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
rescue LoadError
|
12
|
+
else
|
13
|
+
Rake::Task[:rubocop].clear if Rake::Task.task_defined?(:rubocop)
|
14
|
+
if !defined?(::Rubinius)
|
15
|
+
Rake::Task[:rubocop].clear if Rake::Task.task_defined?(:rubocop)
|
16
|
+
desc 'Execute rubocop'
|
17
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
18
|
+
task.options = ['--rails', '--display-cop-names', '--display-style-guide']
|
19
|
+
task.fail_on_error = true
|
20
|
+
end
|
21
|
+
else
|
22
|
+
desc 'No-op rubocop to avoid rbx segfault'
|
23
|
+
task :rubocop do
|
24
|
+
puts 'Skipping rubocop on rbx due to segfault'
|
25
|
+
puts 'https://github.com/rubinius/rubinius/issues/3499'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
2
29
|
|
3
30
|
require 'rake/testtask'
|
4
31
|
|
5
32
|
Rake::TestTask.new do |t|
|
6
|
-
t.libs <<
|
33
|
+
t.libs << 'test'
|
7
34
|
t.test_files = FileList['test/**/*_test.rb']
|
8
35
|
t.ruby_opts = ['-r./test/test_helper.rb']
|
9
36
|
t.verbose = true
|
@@ -4,23 +4,47 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'active_model/serializer/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'active_model_serializers'
|
8
8
|
spec.version = ActiveModel::Serializer::VERSION
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
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'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
|
-
|
24
|
-
spec.
|
25
|
-
|
23
|
+
rails_versions = '>= 4.0'
|
24
|
+
spec.add_runtime_dependency 'activemodel', rails_versions
|
25
|
+
# 'activesupport', rails_versions
|
26
|
+
# 'builder'
|
27
|
+
|
28
|
+
spec.add_runtime_dependency 'actionpack', rails_versions
|
29
|
+
# 'activesupport', rails_versions
|
30
|
+
# 'rack'
|
31
|
+
# 'rack-test', '~> 0.6.2'
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'railties', rails_versions
|
34
|
+
# 'activesupport', rails_versions
|
35
|
+
# 'actionpack', rails_versions
|
36
|
+
# 'rake', '>= 0.8.7'
|
37
|
+
|
38
|
+
# 'activesupport', rails_versions
|
39
|
+
# 'i18n,
|
40
|
+
# 'tzinfo'
|
41
|
+
# 'minitest'
|
42
|
+
# 'thread_safe'
|
43
|
+
|
44
|
+
# Soft dependency for pagination
|
45
|
+
spec.add_development_dependency 'kaminari', ' ~> 0.16.3'
|
46
|
+
spec.add_development_dependency 'will_paginate', '~> 3.0', '>= 3.0.7'
|
47
|
+
|
48
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
49
|
+
spec.add_development_dependency 'timecop', '~> 0.7'
|
26
50
|
end
|
data/appveyor.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
skip_tags: true
|
4
|
+
|
5
|
+
environment:
|
6
|
+
matrix:
|
7
|
+
- ruby_version: "193"
|
8
|
+
- ruby_version: "193-x64"
|
9
|
+
- ruby_version: "200"
|
10
|
+
- ruby_version: "200-x64"
|
11
|
+
- ruby_version: "21"
|
12
|
+
- ruby_version: "21-x64"
|
13
|
+
|
14
|
+
install:
|
15
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
16
|
+
- ruby --version
|
17
|
+
- gem --version
|
18
|
+
- gem install bundler
|
19
|
+
- bundler --version
|
20
|
+
- bundle install --retry=3
|
21
|
+
|
22
|
+
test_script:
|
23
|
+
- bundle exec rake
|
24
|
+
|
25
|
+
build: off
|
data/docs/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Docs - ActiveModel::Serializer 0.10.x
|
2
|
+
|
3
|
+
This is the documentation of AMS, it's focused on the **0.10.x version.**
|
4
|
+
|
5
|
+
-----
|
6
|
+
|
7
|
+
## General
|
8
|
+
|
9
|
+
- [Getting Started](general/getting_started.md)
|
10
|
+
- [Adapters](general/adapters.md)
|
11
|
+
- [Configuration Options](general/configuration_options.md)
|
12
|
+
|
13
|
+
## How to
|
14
|
+
|
15
|
+
- [How to add root key](howto/add_root_key.md)
|
16
|
+
- [How to add pagination links](howto/add_pagination_links.md)
|
17
|
+
- [Using AMS Outside Of Controllers](howto/outside_controller_use.md)
|
18
|
+
|
19
|
+
## Getting Help
|
20
|
+
|
21
|
+
If you find a bug, please report an [Issue](https://github.com/rails-api/active_model_serializers/issues/new).
|
22
|
+
|
23
|
+
If you have a question, please [post to Stack Overflow](http://stackoverflow.com/questions/tagged/active-model-serializers).
|
24
|
+
|
25
|
+
Thanks!
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
See [CONTRIBUTING.md](https://github.com/rails-api/active_model_serializers/blob/master/CONTRIBUTING.md)
|