diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b335ef..f42b5d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ["2.6", "2.7", "3.0"] + ruby-version: ["2.7", "3.0", "3.1"] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 diff --git a/.rubocop.yml b/.rubocop.yml index 47b1395..e85159b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,6 @@ inherit_mode: - Exclude AllCops: - TargetRubyVersion: "2.6" + TargetRubyVersion: "2.7" Naming/FileName: Exclude: [lib/filterable-by.rb] diff --git a/Gemfile.lock b/Gemfile.lock index 4787536..9818515 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,86 +1,77 @@ PATH remote: . specs: - filterable-by (0.5.2) + filterable-by (0.5.3) activerecord activesupport GEM remote: http://rubygems.org/ specs: - activemodel (6.1.3.1) - activesupport (= 6.1.3.1) - activerecord (6.1.3.1) - activemodel (= 6.1.3.1) - activesupport (= 6.1.3.1) - activesupport (6.1.3.1) + activemodel (7.0.2.2) + activesupport (= 7.0.2.2) + activerecord (7.0.2.2) + activemodel (= 7.0.2.2) + activesupport (= 7.0.2.2) + activesupport (7.0.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) ast (2.4.2) - concurrent-ruby (1.1.8) - diff-lcs (1.4.4) - i18n (1.8.10) + concurrent-ruby (1.1.9) + diff-lcs (1.5.0) + i18n (1.10.0) concurrent-ruby (~> 1.0) - minitest (5.14.4) - parallel (1.20.1) - parser (3.0.1.1) + minitest (5.15.0) + parallel (1.21.0) + parser (3.1.1.0) ast (~> 2.4.1) - rack (2.2.3) - rainbow (3.0.0) - rake (13.0.3) - regexp_parser (2.1.1) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.2.1) rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.13.0) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) + rubocop (1.25.1) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.5.0) - parser (>= 3.0.1.1) - rubocop-bsm (0.5.9) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-bsm (0.6.0) rubocop (~> 1.0) rubocop-performance - rubocop-rails rubocop-rake rubocop-rspec - rubocop-performance (1.11.1) + rubocop-performance (1.13.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.9.1) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) - rubocop-rake (0.5.1) - rubocop - rubocop-rspec (2.3.0) + rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) + rubocop-rspec (2.9.0) + rubocop (~> 1.19) ruby-progressbar (1.11.0) sqlite3 (1.4.2) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - unicode-display_width (2.0.0) - zeitwerk (2.4.2) + unicode-display_width (2.1.0) PLATFORMS ruby @@ -94,4 +85,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 2.1.4 + 2.3.6 diff --git a/filterable-by.gemspec b/filterable-by.gemspec index 1a6c836..9035cf7 100644 --- a/filterable-by.gemspec +++ b/filterable-by.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'filterable-by' - s.version = '0.5.2' + s.version = '0.5.3' s.authors = ['Dimitrij Denissenko'] s.email = ['dimitrij@blacksquaremedia.com'] s.summary = 'Generate white-listed filter scopes from URL parameter values' @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) } s.test_files = `git ls-files -z -- spec/*`.split("\x0") s.require_paths = ['lib'] - s.required_ruby_version = '>= 2.6' + s.required_ruby_version = '>= 2.7' s.add_dependency 'activerecord' s.add_dependency 'activesupport' @@ -21,4 +21,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec' s.add_development_dependency 'rubocop-bsm' s.add_development_dependency 'sqlite3' + s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/filterable_by.rb b/lib/filterable_by.rb index 2e6b3b0..51e08ec 100644 --- a/lib/filterable_by.rb +++ b/lib/filterable_by.rb @@ -31,7 +31,7 @@ def filterable_by(*names, &block) end end - # @param [Hash] hash the filter params + # @param [Hash|ActionController::Parameters] the filter params # @return [ActiveRecord::Relation] the scoped relation def filter_by(hash = nil, **opts) if hash.nil? @@ -39,7 +39,7 @@ def filter_by(hash = nil, **opts) opts = {} end scope = all - return scope unless hash.is_a?(Hash) + return scope unless hash.respond_to?(:key?) && hash.respond_to?(:[]) _filterable_by_config.each do |name, block| next unless hash.key?(name)