Skip to content

Commit 098b0b5

Browse files
authored
Merge pull request #20 from splitwise/ar/housekeeping
Update Ruby >= 3.3, RuboCop, and CI
2 parents 06f1556 + 8fa5a13 commit 098b0b5

File tree

13 files changed

+121
-73
lines changed

13 files changed

+121
-73
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby: ['3.3', '3.4', '4.0']
16+
17+
name: Ruby ${{ matrix.ruby }}
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
27+
- run: bundle exec rake

.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

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Cacheable
22

3+
[![CI](https://github.com/splitwise/cacheable/actions/workflows/ci.yml/badge.svg)](https://github.com/splitwise/cacheable/actions/workflows/ci.yml)
4+
35
By [Splitwise](https://www.splitwise.com)
46

7+
Requires Ruby >= 3.3
8+
59
Cacheable is a gem which adds method caching in Ruby following an [aspect-oriented programming (AOP)](https://en.wikipedia.org/wiki/Aspect-oriented_programming) paradigm. Its core goals are:
610

711
* ease of use (method annotation)
@@ -131,7 +135,7 @@ Fetching data from GitHub
131135

132136
#### Default
133137

134-
By default, Cacheable will construct key a key in the format `[cache_key || class_name, method_name]` without using method arguments.
138+
By default, Cacheable will construct a key in the format `[cache_key || class_name, method_name]` without using method arguments.
135139

136140
If the object responds to `cache_key` its return value will be the first element in the array. `ActiveRecord` provides [`cache_key`](https://api.rubyonrails.org/classes/ActiveRecord/Integration.html#method-i-cache_key) but it can be added to any Ruby object or overwritten. If the object does not respond to it, the name of the class will be used instead. The second element will be the name of the method as a symbol.
137141

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

0 commit comments

Comments
 (0)