grape-active_model_serializers 1.5.2 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2d1b47b4d3f44dde1cb0c35ce95cb37564f4a136
4
- data.tar.gz: 958969c14502aba0f2c60b243a9d748627825639
2
+ SHA256:
3
+ metadata.gz: ae3a400f492d5ceea5ac3f6cf516b76487f29bba1dd4689d559ebe09d1b38eff
4
+ data.tar.gz: 1358b3656b5acd6c516cffa2199e4800474e855d5fa4c52854d1cd73c3eb82da
5
5
  SHA512:
6
- metadata.gz: 1b97e9cd92e4b755ac4a724cedbbffc520de4b8a23466589621e8c697ff076eaea3f8f2a1a3d2468246a157c9aacf235476705bfd623cebffc4ad7e2ee7c0f85
7
- data.tar.gz: e76168614c025652c0766f42b11a474ea23794774f27f441df99de1a9efbf009af15f263d81afeefaa6d17a65f578cfa47494c5f7f58461d682c00bbaa1321e2
6
+ metadata.gz: 1661311cfb871028cb7f7020b940cc924f01a05a2dd27e0bd11b8dd090ed57937e940a3a21e23765384fd1ae796929afdd6e9afa171207d86721f323aa591461
7
+ data.tar.gz: 9e52fa9aac9e61a5401c2900b55c24405d07101a21126632393e0abfd14b19cffafc25f594e1cdd53f0824192c94e8576ede697e9ebc594aceff35a8ec0fb258
@@ -0,0 +1,33 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+
4
+ jobs:
5
+ danger:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v4
9
+ - uses: ruby/setup-ruby@v1
10
+ with:
11
+ ruby-version: 3.4.4
12
+ - name: Install dependencies
13
+ run: bundle install --jobs 4 --retry 3
14
+ - name: Run Danger
15
+ run: |
16
+ # the token is public, has public_repo scope and belongs to the grape-bot user owned by @dblock, this is ok
17
+ TOKEN=$(echo -n Z2hwX2lYb0dPNXNyejYzOFJyaTV3QUxUdkNiS1dtblFwZTFuRXpmMwo= | base64 --decode)
18
+ DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
19
+
20
+ test:
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ ruby-version: [3.4.4, 3.3.8, 3.2.8, 3.1.7]
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ - name: Install dependencies
31
+ run: bundle install --jobs 4 --retry 3
32
+ - name: Run tests
33
+ run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -4,6 +4,10 @@ AllCops:
4
4
  Exclude:
5
5
  - Guardfile
6
6
  - grape-active_model_serializers.gemspec
7
+ NewCops: enable
7
8
 
8
9
  Style/BlockDelimiters:
9
10
  Enabled: false
11
+
12
+ Style/FrozenStringLiteralComment:
13
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,33 +1,47 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-10-09 10:22:52 -0500 using RuboCop version 0.41.2.
3
+ # on 2018-03-14 14:59:23 -0400 using RuboCop version 0.53.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
12
+ Bundler/DuplicatedGem:
13
+ Exclude:
14
+ - 'Gemfile'
15
+
9
16
  # Offense count: 1
10
17
  Metrics/AbcSize:
11
18
  Max: 18
12
19
 
20
+ # Offense count: 23
21
+ # Configuration parameters: CountComments, ExcludedMethods.
22
+ Metrics/BlockLength:
23
+ Max: 133
24
+
13
25
  # Offense count: 1
14
26
  Metrics/CyclomaticComplexity:
15
27
  Max: 9
16
28
 
17
- # Offense count: 1
18
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
19
- # URISchemes: http, https
20
- Metrics/LineLength:
21
- Max: 87
22
-
23
29
  # Offense count: 1
24
30
  # Configuration parameters: CountComments.
25
31
  Metrics/MethodLength:
26
- Max: 18
32
+ Max: 15
27
33
 
28
34
  # Offense count: 1
29
35
  Metrics/PerceivedComplexity:
30
- Max: 11
36
+ Max: 10
37
+
38
+ # Offense count: 2
39
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
40
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
41
+ Naming/FileName:
42
+ Exclude:
43
+ - 'lib/grape-active_model_serializers.rb'
44
+ - 'spec/grape-active_model_serializers_spec.rb'
31
45
 
32
46
  # Offense count: 5
33
47
  Style/Documentation:
@@ -40,9 +54,18 @@ Style/Documentation:
40
54
  - 'lib/grape-active_model_serializers/options_builder.rb'
41
55
  - 'lib/grape-active_model_serializers/serializer_resolver.rb'
42
56
 
57
+ # Offense count: 1
58
+ # Configuration parameters: MinBodyLength.
59
+ Style/GuardClause:
60
+ Exclude:
61
+ - 'lib/grape-active_model_serializers/serializer_resolver.rb'
62
+
43
63
  # Offense count: 2
44
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
45
- Style/FileName:
64
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
65
+ # URISchemes: http, https
66
+ Layout/LineLength:
67
+ Max: 87
68
+
69
+ Lint/ConstantDefinitionInBlock:
46
70
  Exclude:
47
- - 'lib/grape-active_model_serializers.rb'
48
- - 'spec/grape-active_model_serializers_spec.rb'
71
+ - spec/integration/sequel_spec.rb
data/CHANGELOG.md CHANGED
@@ -1,17 +1,22 @@
1
1
  ## Changelog
2
2
 
3
- ### 1.5.2 (March 14, 2018)
3
+ ### 2.0.0 (2025/06/02)
4
+
5
+ * [#96](https://github.com/ruby-grape/grape-active_model_serializers/pull/96): Add compatibility for Grape 2.3 - [@samsonjs](https://github.com/samsonjs).
6
+ * [#98](https://github.com/ruby-grape/grape-active_model_serializers/pull/98): Out with Travis CI, in with GitHub Actions - [@samsonjs](https://github.com/samsonjs).
7
+
8
+ ### 1.5.2 (2018/03/14)
4
9
 
5
10
  * [#76](https://github.com/ruby-grape/grape-active_model_serializers/pull/76): Add custom error formatter - [@xn](https://github.com/xn).
6
11
 
7
- ### 1.5.1 (April 25, 2017)
12
+ ### 1.5.1 (2017/04/25)
8
13
 
9
14
  * [#74](https://github.com/ruby-grape/grape-active_model_serializers/pull/74): Add support for Sequel - [@drn](https://github.com/drn).
10
15
  * [#73](https://github.com/ruby-grape/grape-active_model_serializers/pull/73): Ensure all AMS options are passed through - [@drn](https://github.com/drn).
11
16
  * [#65](https://github.com/ruby-grape/grape-active_model_serializers/pull/65): Added Danger, PR linter - [@dblock](https://github.com/dblock).
12
17
  * [#63](https://github.com/ruby-grape/grape-active_model_serializers/pull/63): Pass adapter options through render - [@drn](https://github.com/drn).
13
18
 
14
- ### 1.5.0 (August 24, 2016)
19
+ ### 1.5.0 (2016/08/24)
15
20
 
16
21
  * [#61](https://github.com/ruby-grape/grape-active_model_serializers/pull/61): Adds support for collection serializers - [@drn](https://github.com/drn).
17
22
  * [#60](https://github.com/ruby-grape/grape-active_model_serializers/pull/60): Namespace serializer inference - [@drn](https://github.com/drn).
@@ -19,22 +24,22 @@
19
24
  * [#57](https://github.com/ruby-grape/grape-active_model_serializers/pull/57): Solve line length linter issues - [@drn](https://github.com/drn).
20
25
  * [#54](https://github.com/ruby-grape/grape-active_model_serializers/pull/54): Adding support for ASM v0.10. Drops support for ASM v0.9 - [@drn](https://github.com/drn).
21
26
 
22
- ### 1.4.0 (July 14, 2016)
27
+ ### 1.4.0 (2016/07/14)
23
28
 
24
29
  * [#49](https://github.com/ruby-grape/grape-active_model_serializers/pull/49): Adds support for active model serializer namespace - [@syntaxTerr0r](https://github.com/syntaxTerr0r).
25
30
  * [#36](https://github.com/ruby-grape/grape-active_model_serializers/pull/36), [#50](https://github.com/jrhe/grape-active_model_serializers/pull/50): Added support through Grape 0.16.x - [@dblock](https://github.com/dblock).
26
31
 
27
- ### v1.3.2 (February 27, 2015)
32
+ ### 1.3.2 (2015/02/27)
28
33
 
29
34
  * [#40](https://github.com/ruby-grape/grape-active_model_serializers/pull/40): Use env to pass AMS meta around - [@dblock](https://github.com/dblock).
30
35
  * [#39](https://github.com/ruby-grape/grape-active_model_serializers/pull/39): Look for namespace and other options to configure serializers - [@jwkoelewijn](https://github.com/jwkoelewijn).
31
36
 
32
- ### v1.3.1 (November 20, 2014)
37
+ ### 1.3.1 (2014/11/20)
33
38
 
34
39
  * [#30](https://github.com/ruby-grape/grape-active_model_serializers/pull/30): Read options from default_serializer_options - [@siong1987](https://github.com/siong1987).
35
40
  * [#24](https://github.com/ruby-grape/grape-active_model_serializers/pull/24): Makes it possible to use `current_user` within serializers - [@sonxurxo](https://github.com/sonxurxo).
36
41
 
37
- ### v1.2.1 (July 23, 2014)
42
+ ### 1.2.1 (2014/07/23)
38
43
 
39
44
  * [#21](https://github.com/ruby-grape/grape-active_model_serializers/pull/21): Correctly fetch serialization scope - [@radanskoric](https://github.com/radanskoric).
40
45
  * [#18](https://github.com/ruby-grape/grape-active_model_serializers/pull/18): Added support for active model serializer 0.9.x - [@sbounmy](https://github.com/sbounmy).
@@ -44,12 +49,12 @@
44
49
  * [#12](https://github.com/ruby-grape/grape-active_model_serializers/pull/12): Added support for `current_user` - [@kpassapk](https://github.com/kpassapk).
45
50
  * [#11](https://github.com/ruby-grape/grape-active_model_serializers/pull/11): Fixed require path - [@schickling](https://github.com/schickling).
46
51
 
47
- ### v1.0.1 (September 9, 2013)
52
+ ### 1.0.1 (2013/09/09)
48
53
 
49
54
  * [#6](https://github.com/ruby-grape/grape-active_model_serializers/pull/6): Conform to ActiveModel::Serializers way of determining array-ness - [@tfe](https://github.com/tfe).
50
55
  * [#4](https://github.com/ruby-grape/grape-active_model_serializers/pull/4): Support for namespace options and rely more on active_model_serializers - [@johnallen3d](https://github.com/johnallen3d).
51
56
  * [#1](https://github.com/ruby-grape/grape-active_model_serializers/pull/1): Fix: Grape::ActiveModelSerializers for models with compound names - [@george](https://github.com/george).
52
57
 
53
- ### v1.0.0
58
+ ### 1.0.0 (2013/09/09)
54
59
 
55
60
  * Initial public release - [@jrhe](https://github.com/jrhe).
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- case version = ENV['GRAPE_VERSION'] || '~> 1.0.0'
5
+ case version = ENV['GRAPE_VERSION'] || '~> 2.3.0'
6
6
  when 'HEAD'
7
7
  gem 'grape', github: 'intridea/grape'
8
8
  else
@@ -10,7 +10,16 @@ else
10
10
  end
11
11
 
12
12
  group :test do
13
+ gem 'rack-test'
14
+ gem 'ruby-grape-danger', '~> 0.2.0', require: false
15
+ gem 'sequel', '~> 5.91', require: false
13
16
  gem 'sqlite3'
14
- gem 'sequel', '~> 4.37', require: false
15
- gem 'ruby-grape-danger', '~> 0.1.0', require: false
17
+ end
18
+
19
+ group :development, :test do
20
+ gem 'guard-rspec'
21
+ gem 'listen', '~> 3.9.0'
22
+ gem 'rake'
23
+ gem 'rspec'
24
+ gem 'rubocop', '1.75.7'
16
25
  end
data/README.md CHANGED
@@ -1,9 +1,29 @@
1
+ # Table of Contents
2
+
3
+ - [Grape::ActiveModelSerializers](#grapeactivemodelserializers)
4
+ - [Installation](#installation)
5
+ - [Dependencies](#dependencies)
6
+ - [Usage](#usage)
7
+ - [Require grape-active_model_serializers](#require-grape-active_model_serializers)
8
+ - [Tell your API to use Grape::Formatter::ActiveModelSerializers](#tell-your-api-to-use-grapeformatteractivemodelserializers)
9
+ - [Writing Serializers](#writing-serializers)
10
+ - [Serializers are inferred by active_record model names](#serializers-are-inferred-by-active_record-model-names)
11
+ - [Array Roots](#array-roots)
12
+ - [API Versioning](#api-versioning)
13
+ - [Manually specifying serializer / adapter options](#manually-specifying-serializer--adapter-options)
14
+ - [Custom Metadata](#custom-metadata)
15
+ - [Default Serializer Options](#default-serializer-options)
16
+ - [Current User](#current-user)
17
+ - [Full Example](#full-example)
18
+ - [Contributing](#contributing)
19
+ - [History](#history)
20
+
1
21
  # Grape::ActiveModelSerializers
2
22
 
3
23
  Use [active_model_serializers](https://github.com/rails-api/active_model_serializers) with [Grape](https://github.com/intridea/grape)!
4
24
 
5
25
  [![Gem Version](https://badge.fury.io/rb/grape-active_model_serializers.svg)](https://badge.fury.io/rb/grape-active_model_serializers)
6
- [![Build Status](https://api.travis-ci.org/ruby-grape/grape-active_model_serializers.svg)](http://travis-ci.org/ruby-grape/grape-active_model_serializers) [![Dependency Status](https://gemnasium.com/ruby-grape/grape-active_model_serializers.svg)](https://gemnasium.com/ruby-grape/grape-active_model_serializers) [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-active_model_serializers.svg)](https://codeclimate.com/github/ruby-grape/grape-active_model_serializers)
26
+ [![Build Status](https://github.com/ruby-grape/grape-active_model_serializers/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby-grape/grape-active_model_serializers/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-active_model_serializers.svg)](https://codeclimate.com/github/ruby-grape/grape-active_model_serializers)
7
27
 
8
28
  ## Installation
9
29
 
@@ -17,9 +37,9 @@ See [UPGRADING](UPGRADING.md) if you're upgrading from a previous version.
17
37
 
18
38
  ## Dependencies
19
39
 
20
- * >= Ruby v2.2
21
- * >= [grape](https://github.com/intridea/grape) v0.8.0
22
- * >= [active_model_serializers](https://github.com/rails-api/active_model_serializers) v0.10.0
40
+ * >= Ruby v3.1
41
+ * >= [grape](https://github.com/ruby-grape/grape) v2.3.0
42
+ * >= [active_model_serializers](https://github.com/rails-api/active_model_serializers) v0.10.0
23
43
 
24
44
  ## Usage
25
45
 
@@ -283,4 +303,4 @@ See [CONTRIBUTING](CONTRIBUTING.md).
283
303
 
284
304
  ## History
285
305
 
286
- Structured and based upon [grape-rabl](https://github.com/LTe/grape-rabl).
306
+ Structured and based upon [grape-rabl](https://github.com/ruby-grape/grape-rabl).
data/RELEASING.md CHANGED
@@ -11,12 +11,12 @@ bundle install
11
11
  rake
12
12
  ```
13
13
 
14
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape-active_model_serializers) for all supported platforms.
14
+ Check that the last build succeeded in [GitHub Actions](https://github.com/ruby-grape/grape-active_model_serializers/actions/workflows/ci.yml) for all supported platforms.
15
15
 
16
16
  Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
17
17
 
18
18
  ```
19
- ### 0.7.2 (February 6, 2014)
19
+ ### 0.7.2 (2014/02/06)
20
20
  ```
21
21
 
22
22
  Remove the line with "Your contribution here.", since there will be no more contributions to this release.
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rake
2
+
2
3
  require 'bundler/gem_tasks'
3
4
 
4
5
  require 'rspec/core'
@@ -11,4 +12,4 @@ end
11
12
  require 'rubocop/rake_task'
12
13
  RuboCop::RakeTask.new(:rubocop)
13
14
 
14
- task default: [:rubocop, :spec]
15
+ task default: %i[rubocop spec]
@@ -16,13 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Grape::ActiveModelSerializers::VERSION
17
17
  gem.licenses = ['MIT']
18
18
 
19
- gem.add_dependency 'grape', '>= 0.8.0'
19
+ gem.add_dependency 'grape', '>= 2.3.0'
20
20
  gem.add_dependency 'active_model_serializers', '>= 0.10.0'
21
-
22
- gem.add_development_dependency 'listen', '~> 3.0.7'
23
- gem.add_development_dependency 'rspec'
24
- gem.add_development_dependency 'rack-test'
25
- gem.add_development_dependency 'rake'
26
- gem.add_development_dependency 'guard-rspec'
27
- gem.add_development_dependency 'rubocop', '0.41.2'
28
21
  end
@@ -32,6 +32,7 @@ module Grape
32
32
  def serialization_scope
33
33
  return unless _serialization_scope
34
34
  return unless respond_to?(_serialization_scope, true)
35
+
35
36
  send(_serialization_scope)
36
37
  end
37
38
  end
@@ -50,12 +51,10 @@ module Grape
50
51
  resources
51
52
  end
52
53
 
53
- def default_serializer_options
54
- end
54
+ def default_serializer_options; end
55
55
 
56
- def url_options
57
- end
56
+ def url_options; end
58
57
  end
59
58
 
60
- Endpoint.send(:include, EndpointExtension)
59
+ Endpoint.include EndpointExtension
61
60
  end
@@ -1,8 +1,6 @@
1
1
  module Grape
2
2
  module ErrorFormatter
3
- module ActiveModelSerializers
4
- extend Base
5
-
3
+ class ActiveModelSerializers < Base
6
4
  class << self
7
5
  def call(message, backtrace, options = {}, env = nil, original_exception = nil)
8
6
  message = present(message, env) if respond_to?(:present)
@@ -1,6 +1,6 @@
1
1
  module Grape
2
2
  module Formatter
3
- module ActiveModelSerializers
3
+ class ActiveModelSerializers
4
4
  class << self
5
5
  def call(resource, env)
6
6
  options = build_options(resource, env)
@@ -7,7 +7,7 @@ module Grape
7
7
  end
8
8
 
9
9
  def options
10
- @options ||= (
10
+ @options ||= begin
11
11
  options = endpoint_options
12
12
  options[:scope] = endpoint unless options.key?(:scope)
13
13
  options.merge!(default_root_options) unless options.key?(:root)
@@ -15,7 +15,7 @@ module Grape
15
15
  options.merge!(adapter_options)
16
16
  options.merge!(extra_options)
17
17
  options
18
- )
18
+ end
19
19
  end
20
20
 
21
21
  private
@@ -73,6 +73,7 @@ module Grape
73
73
  def extra_options
74
74
  options = env['ams_extra'] || {}
75
75
  return options if options.is_a?(Hash)
76
+
76
77
  raise 'Extra options must be a hash'
77
78
  end
78
79
  end
@@ -7,7 +7,7 @@ module Grape
7
7
  end
8
8
 
9
9
  def serializer
10
- serializer_class.new(resource, serializer_options) if serializer_class
10
+ serializer_class&.new(resource, serializer_options)
11
11
  end
12
12
 
13
13
  private
@@ -16,6 +16,7 @@ module Grape
16
16
 
17
17
  def serializer_class
18
18
  return @serializer_class if defined?(@serializer_class)
19
+
19
20
  @serializer_class = resource_defined_class
20
21
  @serializer_class ||= collection_class
21
22
  @serializer_class ||= options[:serializer]
@@ -55,12 +56,14 @@ module Grape
55
56
 
56
57
  def namespace_inferred_class
57
58
  return nil unless options.key?(:for)
59
+
58
60
  namespace = options[:for].to_s.deconstantize
59
61
  "#{namespace}::#{resource_serializer_klass}".safe_constantize
60
62
  end
61
63
 
62
64
  def version_inferred_class
63
65
  return nil unless options.key?(:version)
66
+
64
67
  "#{version}::#{resource_serializer_klass}".safe_constantize
65
68
  end
66
69
 
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module ActiveModelSerializers
3
- VERSION = '1.5.2'.freeze
3
+ VERSION = '2.0.0'.freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ describe Grape::ActiveModelSerializers::OptionsBuilder do
12
12
  let(:env) { super().merge('ams_meta' => meta_options) }
13
13
  let(:meta_options) {
14
14
  {
15
- meta: meta,
15
+ meta: meta,
16
16
  meta_key: meta_key
17
17
  }
18
18
  }
@@ -15,8 +15,8 @@ describe Grape::ActiveModelSerializers::SerializerResolver do
15
15
  let(:options) {
16
16
  {
17
17
  serializer: options_serializer_class, # options defined
18
- for: V4::UsersApi, # namespace inference
19
- version: 'v5' # version inference
18
+ for: V4::UsersApi, # namespace inference
19
+ version: 'v5' # version inference
20
20
  }
21
21
  }
22
22
  # resource defined
@@ -5,7 +5,7 @@ describe 'Grape::EndpointExtension' do
5
5
  subject do
6
6
  Grape::Endpoint.new(
7
7
  Grape::Util::InheritableSetting.new,
8
- path: '/',
8
+ path: '/',
9
9
  method: 'foo'
10
10
  )
11
11
  end
@@ -27,7 +27,7 @@ describe 'Grape::EndpointExtension' do
27
27
 
28
28
  describe '#render' do
29
29
  let(:env) { {} }
30
- let(:env_key) {}
30
+ let(:env_key) { nil }
31
31
 
32
32
  before do
33
33
  allow(subject).to receive(:env).and_return(env)
@@ -4,7 +4,7 @@ require 'grape-active_model_serializers/error_formatter'
4
4
  describe Grape::ErrorFormatter::ActiveModelSerializers do
5
5
  subject { Grape::ErrorFormatter::ActiveModelSerializers }
6
6
  let(:backtrace) { ['Line:1'] }
7
- let(:options) { Hash.new }
7
+ let(:options) { {} }
8
8
  let(:env) { { 'api.endpoint' => app.endpoints.first } }
9
9
  let(:original_exception) { StandardError.new('oh noes!') }
10
10
 
@@ -18,8 +18,8 @@ describe Grape::Formatter::ActiveModelSerializers do
18
18
  {
19
19
  user: {
20
20
  first_name: 'JR',
21
- last_name: 'HE',
22
- email: 'jrhe@github.com'
21
+ last_name: 'HE',
22
+ email: 'jrhe@github.com'
23
23
  }
24
24
  }
25
25
  end
@@ -42,8 +42,8 @@ describe Grape::ActiveModelSerializers do
42
42
  app.get('/home') do
43
43
  User.new(
44
44
  first_name: 'JR',
45
- last_name: 'HE',
46
- email: 'contact@jrhe.co.uk'
45
+ last_name: 'HE',
46
+ email: 'contact@jrhe.co.uk'
47
47
  )
48
48
  end
49
49
  end
@@ -60,17 +60,17 @@ describe Grape::ActiveModelSerializers do
60
60
  app.get('/users') do
61
61
  user = User.new(
62
62
  first_name: 'JR',
63
- last_name: 'HE',
64
- email: 'contact@jrhe.co.uk'
63
+ last_name: 'HE',
64
+ email: 'contact@jrhe.co.uk'
65
65
  )
66
66
  [user, user]
67
67
  end
68
68
 
69
69
  get '/users'
70
70
  expect(subject).to eq(
71
- '{"users":['\
72
- '{"first_name":"JR","last_name":"HE"},'\
73
- '{"first_name":"JR","last_name":"HE"}'\
71
+ '{"users":[' \
72
+ '{"first_name":"JR","last_name":"HE"},' \
73
+ '{"first_name":"JR","last_name":"HE"}' \
74
74
  ']}'
75
75
  )
76
76
  end
@@ -83,8 +83,8 @@ describe Grape::ActiveModelSerializers do
83
83
 
84
84
  get '/home'
85
85
  expect(subject).to eq(
86
- '{"blog_post":'\
87
- '{"title":"Grape AM::S Rocks!","body":"Really, it does."}'\
86
+ '{"blog_post":' \
87
+ '{"title":"Grape AM::S Rocks!","body":"Really, it does."}' \
88
88
  '}'
89
89
  )
90
90
  end
@@ -93,16 +93,16 @@ describe Grape::ActiveModelSerializers do
93
93
  app.get('/blog_posts') do
94
94
  blog_post = BlogPost.new(
95
95
  title: 'Grape AM::S Rocks!',
96
- body: 'Really, it does.'
96
+ body: 'Really, it does.'
97
97
  )
98
98
  [blog_post, blog_post]
99
99
  end
100
100
 
101
101
  get '/blog_posts'
102
102
  expect(subject).to eq(
103
- '{"blog_posts":['\
104
- '{"title":"Grape AM::S Rocks!","body":"Really, it does."},'\
105
- '{"title":"Grape AM::S Rocks!","body":"Really, it does."}'\
103
+ '{"blog_posts":[' \
104
+ '{"title":"Grape AM::S Rocks!","body":"Really, it does."},' \
105
+ '{"title":"Grape AM::S Rocks!","body":"Really, it does."}' \
106
106
  ']}'
107
107
  )
108
108
  end
@@ -132,9 +132,9 @@ describe Grape::ActiveModelSerializers do
132
132
 
133
133
  get '/admin/jeff'
134
134
  expect(subject).to eq(
135
- '{"admin":['\
136
- '{"first_name":"Jeff","last_name":null},'\
137
- '{"first_name":"Jeff","last_name":null}'\
135
+ '{"admin":[' \
136
+ '{"first_name":"Jeff","last_name":null},' \
137
+ '{"first_name":"Jeff","last_name":null}' \
138
138
  ']}'
139
139
  )
140
140
  end
@@ -149,9 +149,9 @@ describe Grape::ActiveModelSerializers do
149
149
 
150
150
  get '/people'
151
151
  expect(subject).to eq(
152
- '{"people":['\
153
- '{"first_name":"Jeff","last_name":null},'\
154
- '{"first_name":"Jeff","last_name":null}'\
152
+ '{"people":[' \
153
+ '{"first_name":"Jeff","last_name":null},' \
154
+ '{"first_name":"Jeff","last_name":null}' \
155
155
  ']}'
156
156
  )
157
157
  end
data/spec/spec_helper.rb CHANGED
@@ -15,4 +15,4 @@ RSpec.configure do |config|
15
15
  config.include Rack::Test::Methods
16
16
  end
17
17
 
18
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
18
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-active_model_serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Richard Henry Evans
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: grape
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 0.8.0
18
+ version: 2.3.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 0.8.0
25
+ version: 2.3.0
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: active_model_serializers
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -38,90 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: 0.10.0
41
- - !ruby/object:Gem::Dependency
42
- name: listen
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.0.7
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.0.7
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rack-test
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: guard-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 0.41.2
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 0.41.2
125
40
  description: Provides a Formatter for the Grape API DSL to emit objects serialized
126
41
  with active_model_serializers.
127
42
  email:
@@ -130,10 +45,10 @@ executables: []
130
45
  extensions: []
131
46
  extra_rdoc_files: []
132
47
  files:
48
+ - ".github/workflows/ci.yml"
133
49
  - ".gitignore"
134
50
  - ".rubocop.yml"
135
51
  - ".rubocop_todo.yml"
136
- - ".travis.yml"
137
52
  - CHANGELOG.md
138
53
  - CONTRIBUTING.md
139
54
  - Dangerfile
@@ -159,7 +74,6 @@ files:
159
74
  - spec/grape-active_model_serializers/error_formatter_spec.rb
160
75
  - spec/grape-active_model_serializers/formatter_spec.rb
161
76
  - spec/grape-active_model_serializers/versioned_api_formatter_spec.rb
162
- - spec/grape-active_model_serializers_spec.rb
163
77
  - spec/grape/active_model_serializers/options_builder_spec.rb
164
78
  - spec/grape/active_model_serializers/serializer_resolver_spec.rb
165
79
  - spec/integration/sequel_spec.rb
@@ -180,7 +94,6 @@ homepage: https://github.com/ruby-grape/grape-active_model_serializers
180
94
  licenses:
181
95
  - MIT
182
96
  metadata: {}
183
- post_install_message:
184
97
  rdoc_options: []
185
98
  require_paths:
186
99
  - lib
@@ -195,9 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
108
  - !ruby/object:Gem::Version
196
109
  version: '0'
197
110
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.6.12
200
- signing_key:
111
+ rubygems_version: 3.6.7
201
112
  specification_version: 4
202
113
  summary: Use active_model_serializer in grape
203
114
  test_files:
@@ -206,7 +117,6 @@ test_files:
206
117
  - spec/grape-active_model_serializers/error_formatter_spec.rb
207
118
  - spec/grape-active_model_serializers/formatter_spec.rb
208
119
  - spec/grape-active_model_serializers/versioned_api_formatter_spec.rb
209
- - spec/grape-active_model_serializers_spec.rb
210
120
  - spec/grape/active_model_serializers/options_builder_spec.rb
211
121
  - spec/grape/active_model_serializers/serializer_resolver_spec.rb
212
122
  - spec/integration/sequel_spec.rb
data/.travis.yml DELETED
@@ -1,39 +0,0 @@
1
- language: ruby
2
-
3
- sudo: false
4
-
5
- matrix:
6
- include:
7
- - rvm: 2.5.0
8
- script:
9
- - bundle exec danger
10
- - rvm: 2.5.0
11
- env: GRAPE_VERSION=0.8.0
12
- - rvm: 2.5.0
13
- env: GRAPE_VERSION=0.9.0
14
- - rvm: 2.5.0
15
- env: GRAPE_VERSION=0.10.1
16
- - rvm: 2.5.0
17
- env: GRAPE_VERSION=0.12.0
18
- - rvm: 2.5.0
19
- env: GRAPE_VERSION=0.13.0
20
- - rvm: 2.5.0
21
- env: GRAPE_VERSION=0.14.0
22
- - rvm: 2.5.0
23
- env: GRAPE_VERSION=0.15.0
24
- - rvm: 2.5.0
25
- env: GRAPE_VERSION=0.16.2
26
- - rvm: 2.5.0
27
- env: GRAPE_VERSION=HEAD
28
- - rvm: 2.4.3
29
- - rvm: 2.3.6
30
- - rvm: 2.2.9
31
- - rvm: rbx-2
32
- - rvm: jruby-19mode
33
- - rvm: ruby-head
34
- - rvm: jruby-head
35
- allow_failures:
36
- - rvm: rbx-2
37
- - rvm: jruby-19mode
38
- - rvm: ruby-head
39
- - rvm: jruby-head
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'grape-active_model_serializers' do
4
- end