Skip to content

Commit

Permalink
Update Gemfile, test and code for rubocop and psych
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jan 2, 2025
1 parent 3da8656 commit 24d977f
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5.3.1
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'never'
skip_after_successful_duplicate: 'true'
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require:

# trying to be good O:)
AllCops:
TargetRubyVersion: 3.1
TargetRubyVersion: 3.2
NewCops: enable
Exclude:
- ___*/**/*
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ source 'https://rubygems.org'
gemspec path: './gem'

gem 'http' # used by the scripts/contributor-list.rb
gem 'irb'
gem 'rake'
gem 'reline'
gem 'uri'

group :test do
gem 'activesupport'
Expand Down
8 changes: 7 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ GEM
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pstore (0.1.4)
psych (5.2.2)
date
stringio
Expand Down Expand Up @@ -247,7 +248,9 @@ GEM
regexp_parser (2.10.0)
reline (0.6.0)
io-console (~> 0.5)
rematch (3.1.0)
rematch (3.2.0)
logger
pstore
rerun (0.14.0)
listen (~> 3.0)
rouge (4.5.1)
Expand Down Expand Up @@ -337,6 +340,7 @@ DEPENDENCIES
groupdate
http
i18n
irb
minitest
minitest-reporters
mutex_m
Expand All @@ -347,6 +351,7 @@ DEPENDENCIES
rackup
rails (~> 8.0)
rake
reline
rematch
rerun
rouge
Expand All @@ -359,6 +364,7 @@ DEPENDENCIES
simplecov
sinatra
sqlite3
uri

BUNDLED WITH
2.6.2
2 changes: 1 addition & 1 deletion gem/lib/pagy/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class << self
def create(unit, **vars)
raise InternalError, "unit must be in #{UNITS.inspect}; got #{unit}" unless UNITS.include?(unit)

name = unit.to_s
name = +unit.to_s
name[0] = name[0].capitalize
Object.const_get("Pagy::Calendar::#{name}").new(**vars)
end
Expand Down
4 changes: 2 additions & 2 deletions gem/lib/pagy/extras/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def pagy_anchor(pagy, anchor_string: nil)
# Additions for the Frontend module
module UrlHelperAddOn
# Return the url for the calendar page at time
def pagy_calendar_url_at(calendar, time, **opts)
pagy_url_for(calendar.send(:calendar_at, time, **opts), 1, **opts)
def pagy_calendar_url_at(calendar, time, **)
pagy_url_for(calendar.send(:calendar_at, time, **), 1, **)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions gem/lib/pagy/extras/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Pagy # :nodoc:
module I18nExtra
# Frontend overriding for translation
module FrontendOverride
def pagy_t(key, **opts)
::I18n.t(key, **opts)
def pagy_t(key, **)
::I18n.t(key, **)
end
end
Frontend.prepend I18nExtra::FrontendOverride
Expand Down
14 changes: 7 additions & 7 deletions gem/lib/pagy/extras/jsonapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ module BackendOverride
include UrlHelpers

# Return the jsonapi links
def pagy_jsonapi_links(pagy, **opts)
def pagy_jsonapi_links(pagy, **)
if defined?(::Pagy::Keyset) && pagy.is_a?(Keyset)
{ first: pagy_url_for(pagy, nil, **opts),
{ first: pagy_url_for(pagy, nil, **),
last: nil,
prev: nil,
next: pagy.next ? pagy_url_for(pagy, pagy.next, **opts) : nil }
next: pagy.next ? pagy_url_for(pagy, pagy.next, **) : nil }
else
{ first: pagy_url_for(pagy, 1, **opts),
last: pagy_url_for(pagy, pagy.last, **opts),
prev: pagy.prev ? pagy_url_for(pagy, pagy.prev, **opts) : nil,
next: pagy.next ? pagy_url_for(pagy, pagy.next, **opts) : nil }
{ first: pagy_url_for(pagy, 1, **),
last: pagy_url_for(pagy, pagy.last, **),
prev: pagy.prev ? pagy_url_for(pagy, pagy.prev, **) : nil,
next: pagy.next ? pagy_url_for(pagy, pagy.next, **) : nil }
end
end

Expand Down
4 changes: 2 additions & 2 deletions gem/lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def pagy_nav(pagy, id: nil, aria_label: nil, **vars)

# Similar to I18n.t: just ~18x faster using ~10x less memory
# (@pagy_locale explicitly initialized in order to avoid warning)
def pagy_t(key, **opts)
Pagy::I18n.translate(@pagy_locale ||= nil, key, **opts)
def pagy_t(key, **)
Pagy::I18n.translate(@pagy_locale ||= nil, key, **)
end

private
Expand Down
2 changes: 2 additions & 0 deletions gem/lib/pagy/url_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'uri'

class Pagy
# Provide the helpers to handle the url in frontend and backend
module UrlHelpers
Expand Down
2 changes: 1 addition & 1 deletion gem/pagy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Gem::Specification.new do |s|
'changelog_uri' => 'https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md',
'support' => 'https://github.com/ddnexus/pagy/discussions/categories/q-a' }
s.executables << 'pagy'
s.required_ruby_version = '>= 3.1'
s.required_ruby_version = '>= 3.2'
end
12 changes: 6 additions & 6 deletions test/mock_helpers/elasticsearch_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def records
end

class Model
def self.search(*args)
Response.new(*args)
def self.search(*)
Response.new(*)
end

extend Pagy::ElasticsearchRails
Expand All @@ -49,8 +49,8 @@ def initialize(query, options = {})
end

class ModelES7 < Model
def self.search(*args)
ResponseES7.new(*args)
def self.search(*)
ResponseES7.new(*)
end
end

Expand All @@ -73,8 +73,8 @@ def initialize(query, options = {})
end

class ModelES5 < Model
def self.search(*args)
ResponseES5.new(*args)
def self.search(*)
ResponseES5.new(*)
end
end
end
4 changes: 2 additions & 2 deletions test/mock_helpers/meilisearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def raw_answer
end

class Model
def self.ms_search(*args)
Results.new(*args)
def self.ms_search(*)
Results.new(*)
end

extend Pagy::Meilisearch
Expand Down
4 changes: 2 additions & 2 deletions test/pagy/extras/calendar_extra_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Time.zone = 'GMT'
Date.beginning_of_week = :sunday

def app(**opts)
MockApp::Calendar.new(**opts)
def app(**)
MockApp::Calendar.new(**)
end

describe 'pagy/extras/calendar' do
Expand Down
10 changes: 0 additions & 10 deletions test/pagy/extras/standalone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,3 @@ def params
end
end
end

describe 'pagy/extras/standalone/query_utils' do
it 'handles nested hashes' do
_(Pagy::UrlHelpers::QueryUtils.build_nested_query({ a: { b: 2 } })).must_equal "a%5Bb%5D=2" # "a[b]=2"
_(Pagy::UrlHelpers::QueryUtils.build_nested_query({ a: { b: { c: 3 } } })).must_equal "a%5Bb%5D%5Bc%5D=3" # "a[b][c]=3"
end
it 'raises ArgumentError for wrong params' do
_ { Pagy::UrlHelpers::QueryUtils.build_nested_query('just a string') }.must_raise ArgumentError
end
end
10 changes: 10 additions & 0 deletions test/pagy/url_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@
_(app.pagy_url_for(pagy, 5, fragment: '#fragment')).must_equal "/foo?a=5&page=5&b=4&add_me=add_me#fragment"
end
end

describe 'pagy/extras/standalone/query_utils' do
it 'handles nested hashes' do
_(Pagy::UrlHelpers::QueryUtils.build_nested_query({ a: { b: 2 } })).must_equal "a%5Bb%5D=2" # "a[b]=2"
_(Pagy::UrlHelpers::QueryUtils.build_nested_query({ a: { b: { c: 3 } } })).must_equal "a%5Bb%5D%5Bc%5D=3" # "a[b][c]=3"
end
it 'raises ArgumentError for wrong params' do
_ { Pagy::UrlHelpers::QueryUtils.build_nested_query('just a string') }.must_raise ArgumentError
end
end
end

0 comments on commit 24d977f

Please sign in to comment.