basiccache 0.0.25 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -13
- data/Rakefile +6 -0
- data/basiccache.gemspec +5 -4
- data/lib/basiccache.rb +1 -1
- data/lib/caches/cache.rb +3 -3
- data/lib/caches/timecache.rb +2 -2
- data/spec/basiccache_spec.rb +2 -2
- data/vendor/cache/docile-1.1.1.gem +0 -0
- data/vendor/cache/fuubar-1.3.2.gem +0 -0
- data/vendor/cache/parser-2.1.1.gem +0 -0
- data/vendor/cache/rake-10.1.1.gem +0 -0
- data/vendor/cache/rubocop-0.16.0.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.3.2.gem +0 -0
- metadata +12 -13
- data/vendor/cache/docile-1.1.0.gem +0 -0
- data/vendor/cache/fuubar-1.2.1.gem +0 -0
- data/vendor/cache/parser-2.1.0.pre1.gem +0 -0
- data/vendor/cache/rake-10.1.0.gem +0 -0
- data/vendor/cache/rspec-instafail-0.2.4.gem +0 -0
- data/vendor/cache/rubocop-0.15.0.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.2.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a810da737dd6cc8cf4019fc39d17ba359073a447
|
4
|
+
data.tar.gz: 313e818b1a3afcc03d68715ffd40a1ae00df5462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cda0382bb25719157c8d3fefff6015db5af7e3631a6fff6a940e2853ccf13aea75d7a5ae5498f0de6d3ebc6b99a2a97d2e6dbc3f65228110fa69fd642ccba57
|
7
|
+
data.tar.gz: 6d337ffe7e861b60b6375e6a9167154dde614a7a06d170b83ed84648f21f2f6bff740ef53031a3722b30ef1e5bc0f46de0fc2302525375f94aedd1a90d1edae4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
basiccache (0.0.
|
4
|
+
basiccache (0.0.27)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -14,20 +14,19 @@ GEM
|
|
14
14
|
term-ansicolor
|
15
15
|
thor
|
16
16
|
diff-lcs (1.2.5)
|
17
|
-
docile (1.1.
|
18
|
-
fuubar (1.2
|
19
|
-
rspec (
|
20
|
-
|
21
|
-
ruby-progressbar (~> 1.0)
|
17
|
+
docile (1.1.1)
|
18
|
+
fuubar (1.3.2)
|
19
|
+
rspec (>= 2.14.0, < 3.1.0)
|
20
|
+
ruby-progressbar (~> 1.3)
|
22
21
|
hashr (0.0.22)
|
23
22
|
mime-types (2.0)
|
24
23
|
multi_json (1.8.2)
|
25
|
-
parser (2.1.
|
24
|
+
parser (2.1.1)
|
26
25
|
ast (~> 1.1)
|
27
26
|
slop (~> 3.4, >= 3.4.5)
|
28
27
|
powerpack (0.0.9)
|
29
28
|
rainbow (1.1.4)
|
30
|
-
rake (10.1.
|
29
|
+
rake (10.1.1)
|
31
30
|
rest-client (1.6.7)
|
32
31
|
mime-types (>= 1.16)
|
33
32
|
rspec (2.14.1)
|
@@ -37,13 +36,12 @@ GEM
|
|
37
36
|
rspec-core (2.14.7)
|
38
37
|
rspec-expectations (2.14.4)
|
39
38
|
diff-lcs (>= 1.1.3, < 2.0)
|
40
|
-
rspec-instafail (0.2.4)
|
41
39
|
rspec-mocks (2.14.4)
|
42
|
-
rubocop (0.
|
43
|
-
parser (~> 2.
|
40
|
+
rubocop (0.16.0)
|
41
|
+
parser (~> 2.1)
|
44
42
|
powerpack (~> 0.0.6)
|
45
43
|
rainbow (>= 1.1.4)
|
46
|
-
ruby-progressbar (1.2
|
44
|
+
ruby-progressbar (1.3.2)
|
47
45
|
simplecov (0.8.2)
|
48
46
|
docile (~> 1.1.0)
|
49
47
|
multi_json
|
@@ -64,7 +62,7 @@ DEPENDENCIES
|
|
64
62
|
basiccache!
|
65
63
|
coveralls
|
66
64
|
fuubar
|
67
|
-
parser
|
65
|
+
parser
|
68
66
|
rake
|
69
67
|
rspec
|
70
68
|
rubocop
|
data/Rakefile
CHANGED
@@ -2,6 +2,11 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'rubocop/rake_task'
|
4
4
|
|
5
|
+
desc 'Update bundle'
|
6
|
+
task :bundle do
|
7
|
+
`bundle update`
|
8
|
+
end
|
9
|
+
|
5
10
|
desc 'Run tests'
|
6
11
|
RSpec::Core::RakeTask.new(:spec)
|
7
12
|
|
@@ -17,3 +22,4 @@ task :travislint do
|
|
17
22
|
end
|
18
23
|
|
19
24
|
task default: [:spec, :travislint, :rubocop, :build, :install]
|
25
|
+
task release: [:bundle]
|
data/basiccache.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'basiccache'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.27'
|
4
4
|
s.date = Time.now.strftime("%Y-%m-%d")
|
5
5
|
s.summary = 'Provides a minimal key/value caching layer'
|
6
6
|
s.description = "Allows an application to dynamically cache values and retrieve them later"
|
7
7
|
s.authors = ['Les Aker']
|
8
8
|
s.email = 'me@lesaker.org'
|
9
|
-
s.files = `git ls-files`.split
|
10
|
-
s.test_files = `git ls-files spec/*`.split
|
11
9
|
s.homepage = 'https://github.com/akerl/basiccache'
|
12
10
|
s.license = 'MIT'
|
13
11
|
|
12
|
+
s.files = `git ls-files`.split
|
13
|
+
s.test_files = `git ls-files spec/*`.split
|
14
|
+
|
14
15
|
s.add_development_dependency 'rubocop'
|
15
16
|
s.add_development_dependency 'travis-lint'
|
16
17
|
s.add_development_dependency 'rake'
|
17
18
|
s.add_development_dependency 'coveralls'
|
18
19
|
s.add_development_dependency 'rspec'
|
19
20
|
s.add_development_dependency 'fuubar'
|
20
|
-
s.add_development_dependency 'parser'
|
21
|
+
s.add_development_dependency 'parser'
|
21
22
|
end
|
22
23
|
|
data/lib/basiccache.rb
CHANGED
@@ -20,7 +20,7 @@ module BasicCache
|
|
20
20
|
# These methods return the name of the calling function 2 levels up
|
21
21
|
# This allows them to return the name of whatever called Cache.cache()
|
22
22
|
|
23
|
-
def
|
23
|
+
def caller_name
|
24
24
|
NEW_CALL ? caller_locations(2, 1).first.label : caller[1][/`([^']*)'/, 1]
|
25
25
|
end
|
26
26
|
end
|
data/lib/caches/cache.rb
CHANGED
@@ -24,7 +24,7 @@ module BasicCache
|
|
24
24
|
# If not, run the code, cache the result, and return it
|
25
25
|
|
26
26
|
def cache(key = nil, &code)
|
27
|
-
key ||= BasicCache.
|
27
|
+
key ||= BasicCache.caller_name
|
28
28
|
@store[key.to_sym] ||= code.call
|
29
29
|
end
|
30
30
|
|
@@ -40,7 +40,7 @@ module BasicCache
|
|
40
40
|
# (just a wrapper, designed to be redefined by subclasses)
|
41
41
|
|
42
42
|
def include?(key = nil)
|
43
|
-
key ||= BasicCache.
|
43
|
+
key ||= BasicCache.caller_name
|
44
44
|
@store.include? key.to_sym
|
45
45
|
end
|
46
46
|
|
@@ -48,7 +48,7 @@ module BasicCache
|
|
48
48
|
# Retrieve cached value
|
49
49
|
|
50
50
|
def [](key = nil)
|
51
|
-
key ||= BasicCache.
|
51
|
+
key ||= BasicCache.caller_name
|
52
52
|
fail KeyError, 'Key not cached' unless include? key.to_sym
|
53
53
|
@store[key.to_sym]
|
54
54
|
end
|
data/lib/caches/timecache.rb
CHANGED
@@ -18,7 +18,7 @@ module BasicCache
|
|
18
18
|
# If the key is cached but expired, clear it
|
19
19
|
|
20
20
|
def cache(key = nil, &code)
|
21
|
-
key ||= BasicCache.
|
21
|
+
key ||= BasicCache.caller_name
|
22
22
|
key = key.to_sym
|
23
23
|
# rubocop:disable AndOr
|
24
24
|
unless @store.include? key and Time.now - @store[key].stamp < @lifetime
|
@@ -32,7 +32,7 @@ module BasicCache
|
|
32
32
|
# Check if a value is cached and not expired
|
33
33
|
|
34
34
|
def include?(key = nil)
|
35
|
-
key ||= BasicCache.
|
35
|
+
key ||= BasicCache.caller_name
|
36
36
|
key = key.to_sym
|
37
37
|
# rubocop:disable AndOr
|
38
38
|
@store.include? key and Time.now - @store[key].stamp < @lifetime
|
data/spec/basiccache_spec.rb
CHANGED
@@ -7,9 +7,9 @@ describe BasicCache do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe '.
|
10
|
+
describe '.caller_name' do
|
11
11
|
it "returns the calling function's name" do
|
12
|
-
expect(BasicCache.
|
12
|
+
expect(BasicCache.caller_name).to eql 'instance_eval'
|
13
13
|
end
|
14
14
|
it 'uses caller_locations on Ruby 2.0.0+' do
|
15
15
|
expect(BasicCache::NEW_CALL).to be_true if RUBY_VERSION.to_i >= 2
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basiccache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: parser
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '0'
|
111
111
|
description: Allows an application to dynamically cache values and retrieve them later
|
112
112
|
email: me@lesaker.org
|
113
113
|
executables: []
|
@@ -136,23 +136,22 @@ files:
|
|
136
136
|
- vendor/cache/ast-1.1.0.gem
|
137
137
|
- vendor/cache/coveralls-0.7.0.gem
|
138
138
|
- vendor/cache/diff-lcs-1.2.5.gem
|
139
|
-
- vendor/cache/docile-1.1.
|
140
|
-
- vendor/cache/fuubar-1.2.
|
139
|
+
- vendor/cache/docile-1.1.1.gem
|
140
|
+
- vendor/cache/fuubar-1.3.2.gem
|
141
141
|
- vendor/cache/hashr-0.0.22.gem
|
142
142
|
- vendor/cache/mime-types-2.0.gem
|
143
143
|
- vendor/cache/multi_json-1.8.2.gem
|
144
|
-
- vendor/cache/parser-2.1.
|
144
|
+
- vendor/cache/parser-2.1.1.gem
|
145
145
|
- vendor/cache/powerpack-0.0.9.gem
|
146
146
|
- vendor/cache/rainbow-1.1.4.gem
|
147
|
-
- vendor/cache/rake-10.1.
|
147
|
+
- vendor/cache/rake-10.1.1.gem
|
148
148
|
- vendor/cache/rest-client-1.6.7.gem
|
149
149
|
- vendor/cache/rspec-2.14.1.gem
|
150
150
|
- vendor/cache/rspec-core-2.14.7.gem
|
151
151
|
- vendor/cache/rspec-expectations-2.14.4.gem
|
152
|
-
- vendor/cache/rspec-instafail-0.2.4.gem
|
153
152
|
- vendor/cache/rspec-mocks-2.14.4.gem
|
154
|
-
- vendor/cache/rubocop-0.
|
155
|
-
- vendor/cache/ruby-progressbar-1.2.
|
153
|
+
- vendor/cache/rubocop-0.16.0.gem
|
154
|
+
- vendor/cache/ruby-progressbar-1.3.2.gem
|
156
155
|
- vendor/cache/simplecov-0.8.2.gem
|
157
156
|
- vendor/cache/simplecov-html-0.8.0.gem
|
158
157
|
- vendor/cache/slop-3.4.7.gem
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|