Skip to content

Commit e5e3fed

Browse files
authored
Merge pull request #6 from splitwise/ar/update_gems
Update gems and code compliance
2 parents 33452f4 + 7b37e38 commit e5e3fed

8 files changed

Lines changed: 84 additions & 80 deletions

File tree

Gemfile

Lines changed: 4 additions & 4 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.14'
4+
gem 'guard', '~> 2.15'
55
gem 'guard-rspec', '~> 4.7'
66
gem 'guard-rubocop', '~> 1.3'
77
gem 'pry-byebug', '~> 3.6'
8-
gem 'rspec', '~> 3.7'
9-
gem 'rubocop', '~> 0.58'
10-
gem 'rubocop-rspec', '~> 1.27'
8+
gem 'rspec', '~> 3.8'
9+
gem 'rubocop', '~> 0.63'
10+
gem 'rubocop-rspec', '~> 1.31'
1111
end
1212

1313
gemspec

Gemfile.lock

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ GEM
1010
byebug (10.0.2)
1111
coderay (1.1.2)
1212
diff-lcs (1.3)
13-
ffi (1.9.25)
13+
ffi (1.10.0)
1414
formatador (0.2.5)
15-
guard (2.14.2)
15+
guard (2.15.0)
1616
formatador (>= 0.2.4)
1717
listen (>= 2.7, < 4.0)
1818
lumberjack (>= 1.0.12, < 2.0)
@@ -29,72 +29,72 @@ GEM
2929
guard-rubocop (1.3.0)
3030
guard (~> 2.0)
3131
rubocop (~> 0.20)
32-
jaro_winkler (1.5.1)
32+
jaro_winkler (1.5.2)
3333
listen (3.1.5)
3434
rb-fsevent (~> 0.9, >= 0.9.4)
3535
rb-inotify (~> 0.9, >= 0.9.7)
3636
ruby_dep (~> 1.2)
3737
lumberjack (1.0.13)
38-
method_source (0.9.0)
38+
method_source (0.9.2)
3939
nenv (0.3.0)
4040
notiffany (0.1.1)
4141
nenv (~> 0.1)
4242
shellany (~> 0.0)
43-
parallel (1.12.1)
44-
parser (2.5.1.2)
43+
parallel (1.13.0)
44+
parser (2.6.0.0)
4545
ast (~> 2.4.0)
4646
powerpack (0.1.2)
47-
pry (0.11.3)
47+
pry (0.12.2)
4848
coderay (~> 1.1.0)
4949
method_source (~> 0.9.0)
5050
pry-byebug (3.6.0)
5151
byebug (~> 10.0)
5252
pry (~> 0.10)
5353
rainbow (3.0.0)
5454
rb-fsevent (0.10.3)
55-
rb-inotify (0.9.10)
56-
ffi (>= 0.5.0, < 2)
57-
rspec (3.7.0)
58-
rspec-core (~> 3.7.0)
59-
rspec-expectations (~> 3.7.0)
60-
rspec-mocks (~> 3.7.0)
61-
rspec-core (3.7.1)
62-
rspec-support (~> 3.7.0)
63-
rspec-expectations (3.7.0)
55+
rb-inotify (0.10.0)
56+
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)
6464
diff-lcs (>= 1.2.0, < 2.0)
65-
rspec-support (~> 3.7.0)
66-
rspec-mocks (3.7.0)
65+
rspec-support (~> 3.8.0)
66+
rspec-mocks (3.8.0)
6767
diff-lcs (>= 1.2.0, < 2.0)
68-
rspec-support (~> 3.7.0)
69-
rspec-support (3.7.1)
70-
rubocop (0.58.2)
68+
rspec-support (~> 3.8.0)
69+
rspec-support (3.8.0)
70+
rubocop (0.63.1)
7171
jaro_winkler (~> 1.5.1)
7272
parallel (~> 1.10)
7373
parser (>= 2.5, != 2.5.1.1)
7474
powerpack (~> 0.1)
7575
rainbow (>= 2.2.2, < 4.0)
7676
ruby-progressbar (~> 1.7)
77-
unicode-display_width (~> 1.0, >= 1.0.1)
78-
rubocop-rspec (1.27.0)
79-
rubocop (>= 0.56.0)
80-
ruby-progressbar (1.9.0)
77+
unicode-display_width (~> 1.4.0)
78+
rubocop-rspec (1.31.0)
79+
rubocop (>= 0.60.0)
80+
ruby-progressbar (1.10.0)
8181
ruby_dep (1.5.0)
8282
shellany (0.0.1)
83-
thor (0.20.0)
84-
unicode-display_width (1.4.0)
83+
thor (0.20.3)
84+
unicode-display_width (1.4.1)
8585

8686
PLATFORMS
8787
ruby
8888

8989
DEPENDENCIES
9090
cacheable!
91-
guard (~> 2.14)
91+
guard (~> 2.15)
9292
guard-rspec (~> 4.7)
9393
guard-rubocop (~> 1.3)
9494
pry-byebug (~> 3.6)
95-
rspec (~> 3.7)
96-
rubocop (~> 0.58)
97-
rubocop-rspec (~> 1.27)
95+
rspec (~> 3.8)
96+
rubocop (~> 0.63)
97+
rubocop-rspec (~> 1.31)
9898

9999
BUNDLED WITH
100-
1.16.3
100+
1.16.6

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require 'net/http'
4040

4141
class GitHubApiAdapter
4242
def star_count
43-
puts "Fetching data from GitHub"
43+
puts 'Fetching data from GitHub'
4444
url = 'https://api.github.com/repos/splitwise/cacheable'
4545

4646
JSON.parse(Net::HTTP.get(URI.parse(url)))['stargazers_count']
@@ -63,7 +63,7 @@ class GitHubApiAdapter
6363
cacheable :star_count
6464

6565
def star_count
66-
puts "Fetching data from GitHub"
66+
puts 'Fetching data from GitHub'
6767
url = 'https://api.github.com/repos/splitwise/cacheable'
6868

6969

@@ -78,9 +78,9 @@ end
7878
> a = GitHubApiAdapter.new
7979
> a.star_count
8080
Fetching data from GitHub
81-
=> 2
81+
=> 19
8282
> a.star_count
83-
=> 2
83+
=> 19
8484
8585
# Notice that "Fetching data from GitHub" was not output the 2nd time the method was invoked.
8686
# The network call and result parsing would also not be performed again.
@@ -98,12 +98,12 @@ The cache can intentionally be skipped by appending `_without_cache` to the meth
9898
> a = GitHubApiAdapter.new
9999
> a.star_count
100100
Fetching data from GitHub
101-
=> 2
101+
=> 19
102102
> a.star_count_without_cache
103103
Fetching data from GitHub
104-
=> 2
104+
=> 19
105105
> a.star_count
106-
=> 2
106+
=> 19
107107
```
108108

109109
#### Remove the Value via `clear_#{method}_cache`
@@ -114,15 +114,15 @@ The cached value can be cleared at any time by calling `clear_#{your_method_name
114114
> a = GitHubApiAdapter.new
115115
> a.star_count
116116
Fetching data from GitHub
117-
=> 2
117+
=> 19
118118
> a.star_count
119-
=> 2
119+
=> 19
120120
121121
> a.clear_star_count_cache
122122
=> true
123123
> a.star_count
124124
Fetching data from GitHub
125-
=> 2
125+
=> 19
126126
```
127127

128128
## Additional Configuration
@@ -151,7 +151,7 @@ require 'net/http'
151151
class GitHubApiAdapter
152152
include Cacheable
153153

154-
cacheable :star_count, key_format: -> (target, method_name, method_args) do
154+
cacheable :star_count, key_format: ->(target, method_name, method_args) do
155155
[target.class, method_name, method_args.first, Time.now.strftime('%Y-%m-%d')].join('/')
156156
end
157157

@@ -176,14 +176,14 @@ In addition, we're including the current date in the cache key so calling this m
176176
> a = GitHubApiAdapter.new
177177
> a.star_count('cacheable')
178178
Fetching data from GitHub for cacheable
179-
=> 2
179+
=> 19
180180
> a.star_count('cacheable')
181-
=> 2
181+
=> 19
182182
> a.star_count('tokenautocomplete')
183183
Fetching data from GitHub for tokenautocomplete
184-
=> 1142
184+
=> 1164
185185
> a.star_count('tokenautocomplete')
186-
=> 1142
186+
=> 1164
187187
188188
# In this example the follow cache keys are generated:
189189
# GitHubApiAdapter/star_count/cacheable/2018-09-21
@@ -204,7 +204,7 @@ require 'net/http'
204204
class GitHubApiAdapter
205205
include Cacheable
206206

207-
cacheable :star_count, unless: :growing_fast?, key_format: -> (target, method_name, method_args) do
207+
cacheable :star_count, unless: :growing_fast?, key_format: ->(target, method_name, method_args) do
208208
[target.class, method_name, method_args.first].join('/')
209209
end
210210

@@ -227,16 +227,16 @@ Cacheable is new so we don't want to cache the number of stars it has as we expe
227227
> a = GitHubApiAdapter.new
228228
> a.star_count('tokenautocomplete')
229229
Fetching data from GitHub for tokenautocomplete
230-
=> 1142
230+
=> 1164
231231
a.star_count('tokenautocomplete')
232-
=> 1142
232+
=> 1164
233233
234234
> a.star_count('cacheable')
235235
Fetching data from GitHub for cacheable
236-
=> 2
236+
=> 19
237237
> a.star_count('cacheable')
238238
Fetching data from GitHub for cacheable
239-
=> 2
239+
=> 19
240240
```
241241

242242
### Cache Options
@@ -298,15 +298,15 @@ end
298298
```irb
299299
> GitHubApiAdapter.star_count_for_cacheable
300300
Fetching data from GitHub for cacheable
301-
=> 2
301+
=> 19
302302
> GitHubApiAdapter.star_count_for_cacheable
303-
=> 2
303+
=> 19
304304
305305
> GitHubApiAdapter.star_count_for_tokenautocomplete
306306
Fetching data from GitHub for tokenautocomplete
307-
=> 1142
307+
=> 1164
308308
> GitHubApiAdapter.star_count_for_tokenautocomplete
309-
=> 1142
309+
=> 1164
310310
```
311311

312312
### Other Notes / Frequently Asked Questions

examples/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
inherit_from: ../.rubocop.yml
2+
3+
Style/Lambda:
4+
EnforcedStyle: literal

examples/class_method_example.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def self.star_count_for_tokenautocomplete
2929

3030
GitHubApiAdapter.star_count_for_cacheable
3131
# Fetching data from GitHub for cacheable
32-
# => 2
32+
# => 19
3333
GitHubApiAdapter.star_count_for_cacheable
34-
# => 2
34+
# => 19
3535

3636
GitHubApiAdapter.star_count_for_tokenautocomplete
3737
# Fetching data from GitHub for tokenautocomplete
38-
# => 1142
38+
# => 1164
3939
GitHubApiAdapter.star_count_for_tokenautocomplete
40-
# => 1142
40+
# => 1164

examples/conditional_example.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class GitHubApiAdapter
66
include Cacheable
77

8-
cacheable :star_count, unless: :growing_fast?, key_format: -> (target, method_name, method_args) do
8+
cacheable :star_count, unless: :growing_fast?, key_format: ->(target, method_name, method_args) do
99
[target.class, method_name, method_args.first].join('/')
1010
end
1111

@@ -24,13 +24,13 @@ def growing_fast?(_method_name, method_args)
2424
a = GitHubApiAdapter.new
2525
a.star_count('tokenautocomplete')
2626
# Fetching data from GitHub for tokenautocomplete
27-
# => 1142
27+
# => 1164
2828
a.star_count('tokenautocomplete')
29-
# => 1142
29+
# => 1164
3030

3131
a.star_count('cacheable')
3232
# Fetching data from GitHub for cacheable
33-
# => 2
33+
# => 19
3434
a.star_count('cacheable')
3535
# Fetching data from GitHub for cacheable
36-
# => 2
36+
# => 19

examples/custom_key_example.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class GitHubApiAdapter
66
include Cacheable
77

8-
cacheable :star_count, key_format: -> (target, method_name, method_args) do
8+
cacheable :star_count, key_format: ->(target, method_name, method_args) do
99
[target.class, method_name, method_args.first, Time.now.strftime('%Y-%m-%d')].join('/')
1010
end
1111

@@ -20,11 +20,11 @@ def star_count(repo)
2020
a = GitHubApiAdapter.new
2121
a.star_count('cacheable')
2222
# Fetching data from GitHub for cacheable
23-
# => 2
23+
# => 19
2424
a.star_count('cacheable')
25-
# => 2
25+
# => 19
2626
a.star_count('tokenautocomplete')
2727
# Fetching data from GitHub for tokenautocomplete
28-
# => 1142
28+
# => 1164
2929
a.star_count('tokenautocomplete')
30-
# => 1142
30+
# => 1164

examples/simple_example.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GitHubApiAdapter
88
cacheable :star_count
99

1010
def star_count
11-
puts "Fetching data from GitHub"
11+
puts 'Fetching data from GitHub'
1212
url = 'https://api.github.com/repos/splitwise/cacheable'
1313

1414
JSON.parse(Net::HTTP.get(URI.parse(url)))['stargazers_count']
@@ -18,18 +18,18 @@ def star_count
1818
a = GitHubApiAdapter.new
1919
a.star_count
2020
# Fetching data from GitHub
21-
# => 2
21+
# => 19
2222
a.star_count
23-
# => 2
23+
# => 19
2424

2525
a.star_count_without_cache
2626
# Fetching data from GitHub
27-
# => 2
27+
# => 19
2828
a.star_count
29-
# => 2
29+
# => 19
3030

3131
a.clear_star_count_cache
3232
# => true
3333
a.star_count
3434
# Fetching data from GitHub
35-
# => 2
35+
# => 19

0 commit comments

Comments
 (0)