Skip to content

Commit 6deea5d

Browse files
authored
Merge pull request #14 from splitwise/ar/mondernize
Update code and conventions
2 parents a1eb2e8 + 798a2f5 commit 6deea5d

12 files changed

Lines changed: 124 additions & 130 deletions

File tree

.rubocop.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
require: 'rubocop-rspec'
22

33
AllCops:
4-
TargetRubyVersion: 2.3
4+
NewCops: enable
5+
TargetRubyVersion: 2.6
56

7+
Layout/LineLength:
8+
Max: 120
9+
IgnoredPatterns: ['#.*']
610
Layout/SpaceInsideHashLiteralBraces:
711
EnforcedStyle: no_space
812

9-
Metrics/LineLength:
10-
Max: 120
11-
IgnoredPatterns: ['#.*']
1213
Metrics/MethodLength:
1314
Max: 25
1415

Gemfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
source 'https://rubygems.org'
22

33
group :development, :test do
4-
gem 'guard', '~> 2.15'
5-
gem 'guard-rspec', '~> 4.7'
6-
gem 'guard-rubocop', '~> 1.3'
7-
gem 'pry-byebug', '~> 3.6'
8-
gem 'rspec', '~> 3.8'
9-
gem 'rubocop', '~> 0.63'
10-
gem 'rubocop-rspec', '~> 1.31'
4+
gem 'guard'
5+
gem 'guard-rspec'
6+
gem 'guard-rubocop'
7+
gem 'pry-byebug'
8+
gem 'rspec'
9+
gem 'rubocop'
10+
gem 'rubocop-rspec'
1111
end
1212

1313
gemspec

Gemfile.lock

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
11
PATH
22
remote: .
33
specs:
4-
cacheable (1.0.4)
4+
cacheable (2.0.0)
55

66
GEM
77
remote: https://rubygems.org/
88
specs:
9-
ast (2.4.0)
10-
byebug (10.0.2)
11-
coderay (1.1.2)
12-
diff-lcs (1.3)
13-
ffi (1.10.0)
14-
formatador (0.2.5)
15-
guard (2.15.0)
9+
ast (2.4.2)
10+
byebug (11.1.3)
11+
coderay (1.1.3)
12+
diff-lcs (1.5.0)
13+
ffi (1.15.5)
14+
formatador (1.1.0)
15+
guard (2.18.0)
1616
formatador (>= 0.2.4)
1717
listen (>= 2.7, < 4.0)
1818
lumberjack (>= 1.0.12, < 2.0)
1919
nenv (~> 0.1)
2020
notiffany (~> 0.0)
21-
pry (>= 0.9.12)
21+
pry (>= 0.13.0)
2222
shellany (~> 0.0)
2323
thor (>= 0.18.1)
2424
guard-compat (1.2.1)
2525
guard-rspec (4.7.3)
2626
guard (~> 2.1)
2727
guard-compat (~> 1.1)
2828
rspec (>= 2.99.0, < 4.0)
29-
guard-rubocop (1.3.0)
29+
guard-rubocop (1.5.0)
3030
guard (~> 2.0)
31-
rubocop (~> 0.20)
32-
jaro_winkler (1.5.2)
33-
listen (3.1.5)
34-
rb-fsevent (~> 0.9, >= 0.9.4)
35-
rb-inotify (~> 0.9, >= 0.9.7)
36-
ruby_dep (~> 1.2)
37-
lumberjack (1.0.13)
38-
method_source (0.9.2)
31+
rubocop (< 2.0)
32+
listen (3.7.1)
33+
rb-fsevent (~> 0.10, >= 0.10.3)
34+
rb-inotify (~> 0.9, >= 0.9.10)
35+
lumberjack (1.2.8)
36+
method_source (1.0.0)
3937
nenv (0.3.0)
40-
notiffany (0.1.1)
38+
notiffany (0.1.3)
4139
nenv (~> 0.1)
4240
shellany (~> 0.0)
43-
parallel (1.13.0)
44-
parser (2.6.0.0)
45-
ast (~> 2.4.0)
46-
powerpack (0.1.2)
47-
pry (0.12.2)
48-
coderay (~> 1.1.0)
49-
method_source (~> 0.9.0)
50-
pry-byebug (3.6.0)
51-
byebug (~> 10.0)
52-
pry (~> 0.10)
53-
rainbow (3.0.0)
54-
rb-fsevent (0.10.3)
55-
rb-inotify (0.10.0)
41+
parallel (1.21.0)
42+
parser (3.1.0.0)
43+
ast (~> 2.4.1)
44+
pry (0.13.1)
45+
coderay (~> 1.1)
46+
method_source (~> 1.0)
47+
pry-byebug (3.9.0)
48+
byebug (~> 11.0)
49+
pry (~> 0.13.0)
50+
rainbow (3.1.1)
51+
rb-fsevent (0.11.1)
52+
rb-inotify (0.10.1)
5653
ffi (~> 1.0)
57-
rspec (3.8.0)
58-
rspec-core (~> 3.8.0)
59-
rspec-expectations (~> 3.8.0)
60-
rspec-mocks (~> 3.8.0)
61-
rspec-core (3.8.0)
62-
rspec-support (~> 3.8.0)
63-
rspec-expectations (3.8.2)
54+
regexp_parser (2.2.0)
55+
rexml (3.2.5)
56+
rspec (3.10.0)
57+
rspec-core (~> 3.10.0)
58+
rspec-expectations (~> 3.10.0)
59+
rspec-mocks (~> 3.10.0)
60+
rspec-core (3.10.2)
61+
rspec-support (~> 3.10.0)
62+
rspec-expectations (3.10.2)
6463
diff-lcs (>= 1.2.0, < 2.0)
65-
rspec-support (~> 3.8.0)
66-
rspec-mocks (3.8.0)
64+
rspec-support (~> 3.10.0)
65+
rspec-mocks (3.10.3)
6766
diff-lcs (>= 1.2.0, < 2.0)
68-
rspec-support (~> 3.8.0)
69-
rspec-support (3.8.0)
70-
rubocop (0.63.1)
71-
jaro_winkler (~> 1.5.1)
67+
rspec-support (~> 3.10.0)
68+
rspec-support (3.10.3)
69+
rubocop (1.25.1)
7270
parallel (~> 1.10)
73-
parser (>= 2.5, != 2.5.1.1)
74-
powerpack (~> 0.1)
71+
parser (>= 3.1.0.0)
7572
rainbow (>= 2.2.2, < 4.0)
73+
regexp_parser (>= 1.8, < 3.0)
74+
rexml
75+
rubocop-ast (>= 1.15.1, < 2.0)
7676
ruby-progressbar (~> 1.7)
77-
unicode-display_width (~> 1.4.0)
78-
rubocop-rspec (1.31.0)
79-
rubocop (>= 0.60.0)
80-
ruby-progressbar (1.10.0)
81-
ruby_dep (1.5.0)
77+
unicode-display_width (>= 1.4.0, < 3.0)
78+
rubocop-ast (1.15.1)
79+
parser (>= 3.0.1.1)
80+
rubocop-rspec (2.8.0)
81+
rubocop (~> 1.19)
82+
ruby-progressbar (1.11.0)
8283
shellany (0.0.1)
83-
thor (0.20.3)
84-
unicode-display_width (1.4.1)
84+
thor (1.2.1)
85+
unicode-display_width (2.1.0)
8586

8687
PLATFORMS
87-
ruby
88+
x86_64-darwin-20
89+
x86_64-darwin-21
8890

8991
DEPENDENCIES
9092
cacheable!
91-
guard (~> 2.15)
92-
guard-rspec (~> 4.7)
93-
guard-rubocop (~> 1.3)
94-
pry-byebug (~> 3.6)
95-
rspec (~> 3.8)
96-
rubocop (~> 0.63)
97-
rubocop-rspec (~> 1.31)
93+
guard
94+
guard-rspec
95+
guard-rubocop
96+
pry-byebug
97+
rspec
98+
rubocop
99+
rubocop-rspec
98100

99101
BUNDLED WITH
100-
1.16.6
102+
2.3.6

Guardfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
1919

20-
# Note: The cmd option is now required due to the increasing number of ways
20+
# NOTE: The cmd option is now required due to the increasing number of ways
2121
# rspec may be run, below are examples of the most common uses.
2222
# * bundler: 'bundle exec rspec'
2323
# * bundler binstubs: 'bin/rspec'
@@ -43,7 +43,7 @@ guard :rspec, cmd: 'bundle exec rspec' do
4343
dsl.watch_spec_files_for(ruby.lib_files)
4444
end
4545

46-
guard :rubocop, cli: '-RD' do
46+
guard :rubocop, cli: '-D' do
4747
watch(/.+\.rb$/)
4848
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
4949
end

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'rspec/core/rake_task'
2+
require 'rubocop/rake_task'
3+
4+
RSpec::Core::RakeTask.new(:spec)
5+
RuboCop::RakeTask.new
6+
7+
task default: %i[rubocop spec]

cacheable.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require 'cacheable/version'
66
Gem::Specification.new do |s|
77
s.name = 'cacheable'
88
s.version = Cacheable::VERSION
9-
s.date = '2018-07-31'
109
s.summary = 'Add caching to any Ruby method in a aspect orientated programming approach.'
1110
s.description = 'Add caching simply without modifying your existing code. '\
1211
'Includes configurable options for simple cache invalidation. '\
@@ -16,5 +15,6 @@ Gem::Specification.new do |s|
1615
s.files = Dir['lib/**/*', 'README.md', 'cache-adapters.md']
1716
s.homepage = 'https://github.com/splitwise/cacheable'
1817
s.licenses = 'MIT'
19-
s.required_ruby_version = '>= 2.3.0'
18+
s.required_ruby_version = '>= 2.6.0'
19+
s.metadata = {'rubygems_mfa_required' => 'true'}
2020
end

lib/cacheable/cache_adapters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def lookup(adapter_name)
1414
private
1515

1616
def class_name_for(string)
17-
string.split('_').map { |name_part| "#{name_part[0].upcase}#{name_part[1..-1].downcase}" }.join
17+
string.split('_').map { |name_part| "#{name_part[0].upcase}#{name_part[1..].downcase}" }.join
1818
end
1919
end
2020
end

lib/cacheable/cache_adapters/memory_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def exist?(key)
2020
def fetch(key, _options = {})
2121
return read(key) if exist?(key)
2222

23-
write(key, Proc.new.call)
23+
write(key, yield)
2424
end
2525

2626
def delete(key)

lib/cacheable/method_generator.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'English'
4-
53
module Cacheable
64
module MethodGenerator
75
def cacheable(*original_method_names, **opts)
@@ -66,7 +64,7 @@ def default_key_format
6664

6765
def create_method_names(original_method_name)
6866
method_name_without_punctuation = original_method_name.to_s.sub(/([?!=])$/, '')
69-
punctuation = $LAST_PAREN_MATCH
67+
punctuation = Regexp.last_match(-1)
7068

7169
{
7270
with_cache_method_name: "#{method_name_without_punctuation}_with_cache#{punctuation}",

lib/cacheable/version.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
module Cacheable
44
module VERSION
5-
MAJOR = 1
5+
MAJOR = 2
66
MINOR = 0
7-
TINY = 4
7+
TINY = 0
88
PRE = nil
99

10-
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.').freeze
11-
1210
def self.to_s
13-
STRING
11+
[MAJOR, MINOR, TINY, PRE].compact.join('.').freeze
1412
end
1513
end
1614
end

0 commit comments

Comments
 (0)