New Upstream Release - ruby-grape-entity

Ready changes

Summary

Merged new upstream version: 1.0.0 (was: 0.10.2).

Resulting package

Built on 2023-03-16T12:48 (took 4m57s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-grape-entity

Lintian Result

Diff

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 2098d37..d017aad 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -12,3 +12,9 @@ updates:
       day: "friday"
     assignees:
       - "LeFnord"
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: weekly
+    assignees:
+     - "LeFnord"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..a280bc7
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,41 @@
+name: Ruby
+
+on:
+  push:
+    branches:
+      - '*'
+  pull_request:
+    branches:
+      - '*'
+
+permissions:
+  contents: read
+
+jobs:
+  rubocop:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: '3.2'
+          bundler-cache: true
+      - name: Run rubocop
+        run: bundle exec rubocop --parallel --format progress
+
+  rspec:
+    runs-on: ubuntu-latest
+    needs: ['rubocop']
+    strategy:
+      matrix:
+        ruby-version: ['3.0', '3.1', '3.2', 'head']
+    steps:
+    - name: Check out branch
+      uses: actions/checkout@v3
+    - name: Set up Ruby
+      uses: ruby/setup-ruby@v1
+      with:
+        ruby-version: ${{ matrix.ruby-version }}
+        bundler-cache: true
+    - name: Run rspec rest of the suite
+      run: bundle exec rspec
diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml
deleted file mode 100644
index cf7f60b..0000000
--- a/.github/workflows/rubocop.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Rubocop
-
-on:
-  push:
-    branches:
-      - '*'
-  pull_request:
-    branches:
-      - '*'
-
-jobs:
-  rubocop:
-    name: Rubocop
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-ruby@v1
-        with:
-          ruby-version: '3.0'
-      - run: gem install rubocop --no-doc
-      - run: rubocop --format progress --format json --out rubocop.json
-        id: rubocop
-      - uses: duderman/rubocop-annotate-action@v0.1.0
-        with:
-          path: rubocop.json
-        if: ${{ failure() }}
diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml
deleted file mode 100644
index 1871710..0000000
--- a/.github/workflows/ruby.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Ruby
-
-on:
-  push:
-    branches:
-      - '*'
-  pull_request:
-    branches:
-      - '*'
-
-jobs:
-  spec:
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        ruby-version: ['2.6', '2.7', '3.0', head, jruby, truffleruby]
-
-    steps:
-    - uses: actions/checkout@v2
-    - name: Set up Ruby
-      uses: ruby/setup-ruby@v1
-      with:
-        ruby-version: ${{ matrix.ruby-version }}
-        bundler-cache: true
-    - name: Run rspec
-      run: bundle exec rspec
diff --git a/.rubocop.yml b/.rubocop.yml
index b04706e..0524f52 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -5,7 +5,7 @@ AllCops:
     - vendor/**/*
     - example/**/*
   NewCops: enable
-  TargetRubyVersion: 3.0
+  TargetRubyVersion: 3.2
   SuggestExtensions: false
 
 #  Layout stuff
@@ -38,7 +38,7 @@ Lint/ConstantDefinitionInBlock:
 #
 Metrics/AbcSize:
   Max: 25
-  IgnoredMethods:
+  AllowedMethods:
     # from lib/grape_entity/exposure/nesting_exposure.rb
     - 'normalized_exposures'
 
@@ -59,7 +59,7 @@ Metrics/MethodLength:
 
 Metrics/PerceivedComplexity:
   Max: 11
-  IgnoredMethods:
+  AllowedMethods:
     # from lib/grape_entity/entity.rb
     - 'expose'
     - 'merge_options'
@@ -77,6 +77,9 @@ Naming:
 Style/Documentation:
   Enabled: false
 
+Style/HashSyntax:
+  Enabled: false
+
 Style/OptionalBooleanParameter:
   AllowedMethods:
     # from lib/grape_entity/condition/base.rb
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 27d8265..1f31c04 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,11 +1,27 @@
 # This configuration was generated by
 # `rubocop --auto-gen-config`
-# on 2020-11-07 00:01:40 UTC using RuboCop version 1.2.0.
+# on 2022-07-26 21:29:59 UTC using RuboCop version 1.32.0.
 # The point is for the user to remove these configuration records
 # one by one as the offenses are removed from the code base.
 # Note that changes in the inspected code, or installation of new
 # versions of RuboCop, may require this file to be generated again.
 
+# Offense count: 1
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: Include.
+# Include: **/*.gemspec
+Gemspec/DeprecatedAttributeAssignment:
+  Exclude:
+    - 'grape-entity.gemspec'
+
+# Offense count: 1
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: Include.
+# Include: **/*.gemspec
+Gemspec/RequireMFA:
+  Exclude:
+    - 'grape-entity.gemspec'
+
 # Offense count: 1
 # Configuration parameters: Include.
 # Include: **/*.gemspec
@@ -14,14 +30,20 @@ Gemspec/RequiredRubyVersion:
     - 'grape-entity.gemspec'
 
 # Offense count: 6
-# Cop supports --auto-correct.
+# This cop supports unsafe autocorrection (--autocorrect-all).
 Lint/BooleanSymbol:
   Exclude:
     - 'spec/grape_entity/exposure_spec.rb'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: IgnoredMethods.
+# Offense count: 15
+Style/OpenStructUse:
+  Exclude:
+    - 'lib/grape_entity/delegator.rb'
+    - 'spec/grape_entity/entity_spec.rb'
+
+# Offense count: 2
+# This cop supports unsafe autocorrection (--autocorrect-all).
+# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments.
 # IgnoredMethods: respond_to, define_method
 Style/SymbolProc:
   Exclude:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e95e18d..86fb5cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,24 @@
 * Your contribution here.
 
 
+### ### 1.0.0 (2023-02-16)
+
+#### Fixes
+
+**Breaking change:**
+* [#352](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior. - [@danielvdao](https://github.com/danielvdao).
+* [#371](https://github.com/ruby-grape/grape-entity/pull/371): Allow default exposed value to be `false` or any empty data - [@norydev](https://github.com/norydev).
+
+
+### 0.10.2 (2022-07-29)
+
+#### Fixes
+
+* [#366](https://github.com/ruby-grape/grape-entity/pull/366): Don't suppress regular ArgumentError exceptions - [splattael](https://github.com/splattael).
+* [#363](https://github.com/ruby-grape/grape-entity/pull/338): Fix typo - [@OuYangJinTing](https://github.com/OuYangJinTing).
+* [#361](https://github.com/ruby-grape/grape-entity/pull/361): Require 'active_support/core_ext' - [@pravi](https://github.com/pravi).
+
+
 ### 0.10.1 (2021-10-22)
 
 #### Fixes
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e120beb..6023a84 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -78,7 +78,7 @@ git push origin my-feature-branch
 
 #### Make a Pull Request
 
-Go to https://github.com/contributor/grape-entity and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
+Go to https://github.com/ruby-grape/grape-entity and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
 
 #### Rebase
 
diff --git a/Gemfile b/Gemfile
index 51967f1..eef58cd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,15 @@ source 'http://rubygems.org'
 gemspec
 
 group :development, :test do
-  gem 'rubocop', '~> 1.0', require: false
+  gem 'bundler'
+  gem 'maruku'
+  gem 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
+  gem 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
+  gem 'rack-test'
+  gem 'rake'
+  gem 'rspec', '~> 3.9'
+  gem 'rubocop', '~> 1.0'
+  gem 'yard'
 end
 
 group :test do
diff --git a/UPGRADING.md b/UPGRADING.md
index 1dfe961..50ee6da 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -1,6 +1,11 @@
 # Upgrading Grape Entity
 
 
+### Upgrading to >= 0.10.2
+Official support for `FetchableObject` was removed.
+
+See [#352](https://github.com/ruby-grape/grape-entity/pull/369) for more information.
+
 ### Upgrading to >= 0.8.2
 
 Official support for ruby < 2.5 removed, ruby 2.5 only in testing mode, but no support.
diff --git a/debian/changelog b/debian/changelog
index 4242314..a9fc09f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ruby-grape-entity (1.0.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 16 Mar 2023 12:44:00 -0000
+
 ruby-grape-entity (0.10.1-3) unstable; urgency=medium
 
   * Reupload to unstable
diff --git a/debian/patches/0001-cleanup_spec_helper.patch b/debian/patches/0001-cleanup_spec_helper.patch
index 9c7c463..460d14a 100644
--- a/debian/patches/0001-cleanup_spec_helper.patch
+++ b/debian/patches/0001-cleanup_spec_helper.patch
@@ -2,11 +2,13 @@ Description: clean up require stuff from spec_helper
 Author: Lucas Kanashiro <kanashiro@debian.org>
 Last-Updated: 2016-11-29
 
---- a/spec/spec_helper.rb
-+++ b/spec/spec_helper.rb
-@@ -15,13 +15,6 @@
- 
- Coveralls.wear! unless RUBY_PLATFORM.eql? 'java'
+Index: ruby-grape-entity.git/spec/spec_helper.rb
+===================================================================
+--- ruby-grape-entity.git.orig/spec/spec_helper.rb
++++ ruby-grape-entity.git/spec/spec_helper.rb
+@@ -19,13 +19,6 @@ unless RUBY_VERSION >= '3.1'
+   Coveralls.wear! unless RUBY_PLATFORM.eql? 'java'
+ end
  
 -$LOAD_PATH.unshift(File.dirname(__FILE__))
 -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
diff --git a/debian/patches/0002-require-activerecord.patch b/debian/patches/0002-require-activerecord.patch
index 2f1e99c..226e3a8 100644
--- a/debian/patches/0002-require-activerecord.patch
+++ b/debian/patches/0002-require-activerecord.patch
@@ -1,9 +1,12 @@
 Forwarded: https://github.com/ruby-grape/grape-entity/pull/361
 
---- a/lib/grape_entity/exposure/base.rb
-+++ b/lib/grape_entity/exposure/base.rb
-@@ -1,5 +1,8 @@
- # frozen_string_literal: true
+Index: ruby-grape-entity.git/lib/grape_entity/exposure/base.rb
+===================================================================
+--- ruby-grape-entity.git.orig/lib/grape_entity/exposure/base.rb
++++ ruby-grape-entity.git/lib/grape_entity/exposure/base.rb
+@@ -3,6 +3,9 @@
+ require 'active_support'
+ require 'active_support/core_ext'
  
 +require 'active_support'
 +require 'active_support/core_ext'
diff --git a/grape-entity.gemspec b/grape-entity.gemspec
index be23e0d..8e7de26 100644
--- a/grape-entity.gemspec
+++ b/grape-entity.gemspec
@@ -7,28 +7,19 @@ Gem::Specification.new do |s|
   s.name        = 'grape-entity'
   s.version     = GrapeEntity::VERSION
   s.platform    = Gem::Platform::RUBY
-  s.authors     = ['Michael Bleigh']
-  s.email       = ['michael@intridea.com']
+  s.authors     = ['LeFnord', 'Michael Bleigh']
+  s.email       = ['pscholz.le@gmail.com', 'michael@intridea.com']
   s.homepage    = 'https://github.com/ruby-grape/grape-entity'
   s.summary     = 'A simple facade for managing the relationship between your model and API.'
   s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
   s.license     = 'MIT'
 
-  s.required_ruby_version = '>= 2.5'
+  s.required_ruby_version = '>= 2.7'
 
   s.add_runtime_dependency 'activesupport', '>= 3.0.0'
   # FIXME: remove dependecy
   s.add_runtime_dependency 'multi_json', '>= 1.3.2'
 
-  s.add_development_dependency 'bundler'
-  s.add_development_dependency 'maruku'
-  s.add_development_dependency 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
-  s.add_development_dependency 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
-  s.add_development_dependency 'rack-test'
-  s.add_development_dependency 'rake'
-  s.add_development_dependency 'rspec', '~> 3.9'
-  s.add_development_dependency 'yard'
-
   s.files         = `git ls-files`.split("\n")
   s.test_files    = `git ls-files -- {test,spec}/*`.split("\n")
   s.require_paths = ['lib']
diff --git a/lib/grape_entity/delegator.rb b/lib/grape_entity/delegator.rb
index c274723..5d976e8 100644
--- a/lib/grape_entity/delegator.rb
+++ b/lib/grape_entity/delegator.rb
@@ -3,7 +3,6 @@
 require 'grape_entity/delegator/base'
 require 'grape_entity/delegator/hash_object'
 require 'grape_entity/delegator/openstruct_object'
-require 'grape_entity/delegator/fetchable_object'
 require 'grape_entity/delegator/plain_object'
 
 module Grape
@@ -15,8 +14,6 @@ module Grape
             HashObject
           elsif defined?(OpenStruct) && object.is_a?(OpenStruct)
             OpenStructObject
-          elsif object.respond_to?(:fetch, true)
-            FetchableObject
           else
             PlainObject
           end
diff --git a/lib/grape_entity/delegator/fetchable_object.rb b/lib/grape_entity/delegator/fetchable_object.rb
deleted file mode 100644
index e43d11c..0000000
--- a/lib/grape_entity/delegator/fetchable_object.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-module Grape
-  class Entity
-    module Delegator
-      class FetchableObject < Base
-        def delegate(attribute)
-          object.fetch attribute
-        end
-      end
-    end
-  end
-end
diff --git a/lib/grape_entity/entity.rb b/lib/grape_entity/entity.rb
index 05f2ec7..ece867c 100644
--- a/lib/grape_entity/entity.rb
+++ b/lib/grape_entity/entity.rb
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 require 'multi_json'
-require 'set'
 
 module Grape
   # An Entity is a lightweight structure that allows you to easily
@@ -522,7 +521,10 @@ module Grape
       end
     rescue StandardError => e
       # it handles: https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes point 3, Proc
-      raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0' if e.is_a?(ArgumentError)
+      # accounting for expose :foo, &:bar
+      if e.is_a?(ArgumentError) && block.parameters == [[:req], [:rest]]
+        raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0'
+      end
 
       raise e
     end
diff --git a/lib/grape_entity/exposure/base.rb b/lib/grape_entity/exposure/base.rb
index 04d2b95..3202cf1 100644
--- a/lib/grape_entity/exposure/base.rb
+++ b/lib/grape_entity/exposure/base.rb
@@ -1,5 +1,8 @@
 # frozen_string_literal: true
 
+require 'active_support'
+require 'active_support/core_ext'
+
 module Grape
   class Entity
     module Exposure
@@ -86,7 +89,7 @@ module Grape
           return unless valid?(entity)
 
           output = value(entity, options)
-          output.blank? && @default_value.present? ? @default_value : output
+          output.blank? && !@default_value.nil? ? @default_value : output
         end
 
         def should_return_key?(options)
diff --git a/lib/grape_entity/options.rb b/lib/grape_entity/options.rb
index 6487a95..ea2da1b 100644
--- a/lib/grape_entity/options.rb
+++ b/lib/grape_entity/options.rb
@@ -9,7 +9,7 @@ module Grape
 
       attr_reader :opts_hash
 
-      def_delegators :opts_hash, :dig, :key?, :fetch, :[], :empty
+      def_delegators :opts_hash, :dig, :key?, :fetch, :[], :empty?
 
       def initialize(opts_hash = {})
         @opts_hash = opts_hash
diff --git a/lib/grape_entity/version.rb b/lib/grape_entity/version.rb
index c2e49b7..dae01ec 100644
--- a/lib/grape_entity/version.rb
+++ b/lib/grape_entity/version.rb
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
 
 module GrapeEntity
-  VERSION = '0.10.1'
+  VERSION = '1.0.0'
 end
diff --git a/spec/grape_entity/entity_spec.rb b/spec/grape_entity/entity_spec.rb
index 36beaaa..6a08109 100644
--- a/spec/grape_entity/entity_spec.rb
+++ b/spec/grape_entity/entity_spec.rb
@@ -30,7 +30,9 @@ describe Grape::Entity do
 
         it 'makes sure that :format_with as a proc cannot be used with a block' do
           # rubocop:disable Style/BlockDelimiters
+          # rubocop:disable Lint/Debugger
           expect { subject.expose :name, format_with: proc {} do p 'hi' end }.to raise_error ArgumentError
+          # rubocop:enable Lint/Debugger
           # rubocop:enable Style/BlockDelimiters
         end
 
@@ -245,9 +247,9 @@ describe Grape::Entity do
           context 'when default option is set' do
             it 'exposes default values for attributes' do
               subject.expose(:a, default: 'a')
-              subject.expose(:b, default: 'b')
+              subject.expose(:b, default: false)
               subject.expose(:c, default: 'c')
-              expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: 'b', c: 'value')
+              expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: false, c: 'value')
             end
           end
 
@@ -389,6 +391,10 @@ describe Grape::Entity do
             def method_without_args
               'result'
             end
+
+            def raises_argument_error
+              raise ArgumentError, 'something different'
+            end
           end
 
           describe 'with block passed in' do
@@ -402,6 +408,17 @@ describe Grape::Entity do
               value = subject.represent(object).value_for(:that_method_without_args)
               expect(value).to eq('result')
             end
+
+            it 'does not suppress ArgumentError' do
+              subject.expose :raises_argument_error do |object|
+                object.raises_argument_error
+              end
+
+              object = SomeObject.new
+              expect do
+                subject.represent(object).value_for(:raises_argument_error)
+              end.to raise_error(ArgumentError, 'something different')
+            end
           end
 
           context 'with block passed in via &' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4d0d97a..b375bf5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,12 +9,16 @@ require 'active_support/core_ext/hash' if ActiveSupport::VERSION &&
                                           ActiveSupport::VERSION::MAJOR &&
                                           ActiveSupport::VERSION::MAJOR < 4
 
-SimpleCov.start do
-  add_filter 'spec/'
+# Skip code covarge on Ruby >= 3.1
+# See https://github.com/simplecov-ruby/simplecov/issues/1003
+unless RUBY_VERSION >= '3.1'
+  SimpleCov.start do
+    add_filter 'spec/'
+  end
+
+  Coveralls.wear! unless RUBY_PLATFORM.eql? 'java'
 end
 
-Coveralls.wear! unless RUBY_PLATFORM.eql? 'java'
-
 $LOAD_PATH.unshift(File.dirname(__FILE__))
 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support'))

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/grape-entity-1.0.0.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/ruby/vendor_ruby/grape_entity/delegator/fetchable_object.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/grape-entity-0.10.1.gemspec

No differences were encountered in the control files

More details

Full run details