Skip to content

Commit 776487e

Browse files
agrbergclaude
andcommitted
Update Ruby >= 3.3, RuboCop 1.85, and rubocop-rspec 3.9
- Bump required_ruby_version from >= 3.1.6 to >= 3.3 - Update TargetRubyVersion from 2.6 to 3.3 - Update RuboCop 1.65 -> 1.85 and rubocop-rspec 3.0 -> 3.9 - Migrate rubocop-rspec from require to plugins - Rename deprecated IgnoredPatterns to AllowedPatterns - Update all development dependencies and Bundler to latest - Add rake to Gemfile (no longer a default gem in newer Rubies) - Gitignore Ruby version manager tool files - Fix new cop offenses: Style/RedundantRegexpArgument, RSpec/BeEq, Style/HashSyntax, Layout/LineContinuationSpacing, Lint/RedundantCopDisableDirective Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 06f1556 commit 776487e

10 files changed

Lines changed: 89 additions & 66 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Used by dotenv library to load environment variables.
66
.env
77
.rvmrc
8+
.ruby-version
9+
.tool-versions
10+
.mise.toml
811

912
# Because macs
1013
.DS_Store

.rubocop.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
require: 'rubocop-rspec'
1+
plugins:
2+
- rubocop-rspec
23

34
AllCops:
45
NewCops: enable
5-
TargetRubyVersion: 2.6
6+
TargetRubyVersion: 3.3
67

78
Layout/LineLength:
89
Max: 120
9-
IgnoredPatterns: ['#.*']
10+
AllowedPatterns: ['#.*']
1011
Layout/SpaceInsideHashLiteralBraces:
1112
EnforcedStyle: no_space
1213

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ group :development, :test do
55
gem 'guard-rspec'
66
gem 'guard-rubocop'
77
gem 'pry-byebug'
8+
gem 'rake'
89
gem 'rspec'
910
gem 'rubocop'
1011
gem 'rubocop-rspec'

Gemfile.lock

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9-
ast (2.4.2)
10-
byebug (11.1.3)
9+
addressable (2.8.8)
10+
public_suffix (>= 2.0.2, < 8.0)
11+
ast (2.4.3)
12+
bigdecimal (4.0.1)
13+
byebug (13.0.0)
14+
reline (>= 0.6.0)
1115
coderay (1.1.3)
12-
diff-lcs (1.5.1)
13-
ffi (1.17.0-arm64-darwin)
14-
ffi (1.17.0-x86_64-darwin)
15-
ffi (1.17.0-x86_64-linux-gnu)
16-
formatador (1.1.0)
17-
guard (2.18.1)
16+
diff-lcs (1.6.2)
17+
ffi (1.17.3-arm64-darwin)
18+
ffi (1.17.3-x86_64-darwin)
19+
ffi (1.17.3-x86_64-linux-gnu)
20+
formatador (1.2.3)
21+
reline
22+
guard (2.20.1)
1823
formatador (>= 0.2.4)
1924
listen (>= 2.7, < 4.0)
25+
logger (~> 1.6)
2026
lumberjack (>= 1.0.12, < 2.0)
2127
nenv (~> 0.1)
2228
notiffany (~> 0.0)
@@ -31,66 +37,85 @@ GEM
3137
guard-rubocop (1.5.0)
3238
guard (~> 2.0)
3339
rubocop (< 2.0)
34-
json (2.7.2)
35-
language_server-protocol (3.17.0.3)
36-
listen (3.9.0)
40+
io-console (0.8.2)
41+
json (2.18.1)
42+
json-schema (6.1.0)
43+
addressable (~> 2.8)
44+
bigdecimal (>= 3.1, < 5)
45+
language_server-protocol (3.17.0.5)
46+
lint_roller (1.1.0)
47+
listen (3.10.0)
48+
logger
3749
rb-fsevent (~> 0.10, >= 0.10.3)
3850
rb-inotify (~> 0.9, >= 0.9.10)
39-
lumberjack (1.2.10)
51+
logger (1.7.0)
52+
lumberjack (1.4.2)
53+
mcp (0.7.1)
54+
json-schema (>= 4.1)
4055
method_source (1.1.0)
4156
nenv (0.3.0)
4257
notiffany (0.1.3)
4358
nenv (~> 0.1)
4459
shellany (~> 0.0)
45-
parallel (1.25.1)
46-
parser (3.3.4.0)
60+
parallel (1.27.0)
61+
parser (3.3.10.2)
4762
ast (~> 2.4.1)
4863
racc
49-
pry (0.14.2)
64+
prism (1.9.0)
65+
pry (0.16.0)
5066
coderay (~> 1.1)
5167
method_source (~> 1.0)
52-
pry-byebug (3.10.1)
53-
byebug (~> 11.0)
54-
pry (>= 0.13, < 0.15)
68+
reline (>= 0.6.0)
69+
pry-byebug (3.12.0)
70+
byebug (~> 13.0)
71+
pry (>= 0.13, < 0.17)
72+
public_suffix (7.0.2)
5573
racc (1.8.1)
5674
rainbow (3.1.1)
75+
rake (13.3.1)
5776
rb-fsevent (0.11.2)
5877
rb-inotify (0.11.1)
5978
ffi (~> 1.0)
60-
regexp_parser (2.9.2)
61-
rexml (3.4.4)
62-
rspec (3.13.0)
79+
regexp_parser (2.11.3)
80+
reline (0.6.3)
81+
io-console (~> 0.5)
82+
rspec (3.13.2)
6383
rspec-core (~> 3.13.0)
6484
rspec-expectations (~> 3.13.0)
6585
rspec-mocks (~> 3.13.0)
66-
rspec-core (3.13.0)
86+
rspec-core (3.13.6)
6787
rspec-support (~> 3.13.0)
68-
rspec-expectations (3.13.1)
88+
rspec-expectations (3.13.5)
6989
diff-lcs (>= 1.2.0, < 2.0)
7090
rspec-support (~> 3.13.0)
71-
rspec-mocks (3.13.1)
91+
rspec-mocks (3.13.7)
7292
diff-lcs (>= 1.2.0, < 2.0)
7393
rspec-support (~> 3.13.0)
74-
rspec-support (3.13.1)
75-
rubocop (1.65.1)
94+
rspec-support (3.13.7)
95+
rubocop (1.85.0)
7696
json (~> 2.3)
77-
language_server-protocol (>= 3.17.0)
97+
language_server-protocol (~> 3.17.0.2)
98+
lint_roller (~> 1.1.0)
99+
mcp (~> 0.6)
78100
parallel (~> 1.10)
79101
parser (>= 3.3.0.2)
80102
rainbow (>= 2.2.2, < 4.0)
81-
regexp_parser (>= 2.4, < 3.0)
82-
rexml (>= 3.2.5, < 4.0)
83-
rubocop-ast (>= 1.31.1, < 2.0)
103+
regexp_parser (>= 2.9.3, < 3.0)
104+
rubocop-ast (>= 1.49.0, < 2.0)
84105
ruby-progressbar (~> 1.7)
85-
unicode-display_width (>= 2.4.0, < 3.0)
86-
rubocop-ast (1.31.3)
87-
parser (>= 3.3.1.0)
88-
rubocop-rspec (3.0.3)
89-
rubocop (~> 1.61)
106+
unicode-display_width (>= 2.4.0, < 4.0)
107+
rubocop-ast (1.49.0)
108+
parser (>= 3.3.7.2)
109+
prism (~> 1.7)
110+
rubocop-rspec (3.9.0)
111+
lint_roller (~> 1.1)
112+
rubocop (~> 1.81)
90113
ruby-progressbar (1.13.0)
91114
shellany (0.0.1)
92-
thor (1.3.1)
93-
unicode-display_width (2.5.0)
115+
thor (1.5.0)
116+
unicode-display_width (3.2.0)
117+
unicode-emoji (~> 4.1)
118+
unicode-emoji (4.2.0)
94119

95120
PLATFORMS
96121
arm64-darwin-23
@@ -104,9 +129,10 @@ DEPENDENCIES
104129
guard-rspec
105130
guard-rubocop
106131
pry-byebug
132+
rake
107133
rspec
108134
rubocop
109135
rubocop-rspec
110136

111137
BUNDLED WITH
112-
2.5.17
138+
4.0.7

cacheable.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Gem::Specification.new do |s|
77
s.name = 'cacheable'
88
s.version = Cacheable::VERSION
99
s.summary = 'Add caching to any Ruby method in a aspect orientated programming approach.'
10-
s.description = 'Add caching simply without modifying your existing code. '\
11-
'Includes configurable options for simple cache invalidation. '\
10+
s.description = 'Add caching simply without modifying your existing code. ' \
11+
'Includes configurable options for simple cache invalidation. ' \
1212
'See README on github for more information.'
1313
s.authors = ['Jess Hottenstein', 'Ryan Laughlin', 'Aaron Rosenberg']
1414
s.email = 'support@splitwise.com'
1515
s.files = Dir['lib/**/*', 'README.md', 'cache-adapters.md']
1616
s.homepage = 'https://github.com/splitwise/cacheable'
1717
s.licenses = 'MIT'
18-
s.required_ruby_version = '>= 3.1.6'
18+
s.required_ruby_version = '>= 3.3'
1919
s.metadata = {'rubygems_mfa_required' => 'true'}
2020
end

lib/cacheable/cache_adapters/memory_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def fetch(key, _options = {})
2323
write(key, yield)
2424
end
2525

26-
def delete(key)
26+
def delete(key) # rubocop:disable Naming/PredicateMethod -- mimics the ActiveSupport::Cache::Store#delete interface and isn't a predicate
2727
return false unless exist?(key)
2828

2929
cache.delete key

lib/cacheable/method_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def cacheable(*original_method_names, **opts)
1111
private
1212

1313
def method_interceptor_module_name
14-
class_name = name&.gsub(/:/, '') || to_s.gsub(/[^a-zA-Z_0-9]/, '')
14+
class_name = name&.gsub(':', '') || to_s.gsub(/[^a-zA-Z_0-9]/, '')
1515
"#{class_name}Cacher"
1616
end
1717

@@ -35,7 +35,7 @@ def create_cacheable_methods(original_method_name, opts = {})
3535
end
3636

3737
define_method(method_names[:with_cache_method_name]) do |*args|
38-
Cacheable.cache_adapter.fetch(__send__(method_names[:key_format_method_name], *args), opts[:cache_options]) do
38+
Cacheable.cache_adapter.fetch(__send__(method_names[:key_format_method_name], *args), opts[:cache_options]) do # rubocop:disable Lint/UselessDefaultValueArgument -- not Hash#fetch; second arg is cache options (e.g. expires_in) passed to the adapter
3939
__send__(method_names[:without_cache_method_name], *args)
4040
end
4141
end

spec/.rubocop.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,12 @@ inherit_from: ../.rubocop.yml
33
Layout/LineLength:
44
Max: 170
55

6-
# This cop does not like rspec dsl syntax https://github.com/bbatsov/rubocop/pull/4237#issuecomment-291408032
7-
Lint/AmbiguousBlockAssociation:
8-
Enabled: false
9-
106
Metrics/BlockLength:
117
Enabled: false
128

13-
RSpec/AnyInstance:
14-
Enabled: false
15-
169
RSpec/ExampleLength:
1710
Max: 100
1811

19-
# Disabling the ExpectInHook cop can make testing similar preconditions with only slightly test differences easier
20-
RSpec/ExpectInHook:
21-
Enabled: false
22-
2312
RSpec/MessageSpies:
2413
Enabled: false
2514

spec/cacheable/cache_adapters/memory_adapter_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
describe '#delete' do
2222
it 'returns false if the value was not found' do
23-
expect(cache.delete(key)).to eq(false)
23+
expect(cache.delete(key)).to be(false)
2424
end
2525

2626
it 'returns true if the value was found' do
2727
cache.fetch(key) { true }
28-
expect(cache.delete(key)).to eq(true)
28+
expect(cache.delete(key)).to be(true)
2929
end
3030

3131
it 'removes the value from the cache' do

spec/cacheable/cacheable_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
let(:class_definition) do
99
cacheable_method_name = cacheable_method
1010
cacheable_method_inner_name = cacheable_method_inner
11+
# Capture described_class here because class_exec changes self to
12+
# the anonymous class, where the RSpec helper is not available.
13+
mod = described_class
1114
proc do
12-
include Cacheable # rubocop:disable RSpec/DescribedClass
15+
include mod
1316

1417
define_method(cacheable_method_name) do |arg = nil|
1518
send cacheable_method_inner_name, arg
@@ -65,8 +68,8 @@
6568
cacheable_object.send(cacheable_method)
6669

6770
expect { cacheable_object.send("clear_#{cacheable_method}_cache") }
68-
.to change { described_class.cache_adapter.read(cacheable_object.cacheable_method_key_format) }.to(nil)
69-
.and not_change { described_class.cache_adapter.read(any_other_cached_value) } # rubocop:disable Layout/MultilineMethodCallIndentation
71+
.to change { described_class.cache_adapter.read(cacheable_object.cacheable_method_key_format) }.to(nil) # rubocop:disable Lint/AmbiguousBlockAssociation
72+
.and not_change { described_class.cache_adapter.read(any_other_cached_value) }
7073
end
7174

7275
it 'allows access to `super` via a module interceptor' do
@@ -230,7 +233,7 @@
230233

231234
attr_accessor :secret
232235

233-
cacheable custom_key_object_access_cacheable_method, key_format: proc { |c| c.secret }
236+
cacheable custom_key_object_access_cacheable_method, key_format: proc { |obj, _method_name, _args| obj.secret }
234237
end
235238
cacheable_object.secret = 'some_state_on_the_object'
236239

@@ -376,7 +379,7 @@
376379
cacheable symbol_unless_cache_method, unless: :cache_control_method
377380

378381
def cache_control_method(*_args)
379-
true
382+
'a truthy value skips caching with :unless'
380383
end
381384
end
382385

@@ -455,7 +458,7 @@ def cache_control_method
455458
calculate_hard_value
456459
end
457460

458-
cacheable :cache_method_with_cache_options, cache_options: cache_options
461+
cacheable :cache_method_with_cache_options, cache_options:
459462
end
460463

461464
expect(described_class.cache_adapter).to receive(:fetch).with(anything, hash_including(cache_options))

0 commit comments

Comments
 (0)