coffee_table 0.2.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +32 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +52 -40
- data/README.textile +0 -1
- data/coffee_table.gemspec +2 -0
- data/lib/coffee_table.rb +11 -5
- data/lib/coffee_table/key.rb +16 -15
- data/lib/coffee_table/version.rb +1 -1
- data/spec/lib/coffee_table_spec.rb +60 -63
- data/spec/lib/key_spec.rb +43 -43
- data/spec/spec_helper.rb +9 -10
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8331d649faef4d9b5ba700f8ac93cad2a263bd293e5535c721ed57a170140c7f
|
|
4
|
+
data.tar.gz: a26ffaba10d13a680e611aa39ba5d3b217acb4c786269b7435d05a354e4ae00c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4a5cfdda959a00ea4e79bc41b296771f2eb44cb0dbae1db5f1daf638a6995b7f19b1f678cdfa64139424cd9cf639e92130dbfc1e8fb35f38f5cf2f31331861b
|
|
7
|
+
data.tar.gz: 9228a6f6c205dfaca58386cf08777818a8e57ceb48726dcb705625dec76cabcb3aa9d2da43bd7645bd6cb06b7782e24c484432bb1a550033c165e028afb44276
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
orbs:
|
|
4
|
+
ruby: circleci/ruby@1.0
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
docker:
|
|
9
|
+
- image: cimg/ruby:2.5
|
|
10
|
+
steps:
|
|
11
|
+
- checkout
|
|
12
|
+
- ruby/install-deps
|
|
13
|
+
test:
|
|
14
|
+
parallelism: 3
|
|
15
|
+
docker:
|
|
16
|
+
- image: cimg/ruby:2.5
|
|
17
|
+
environment:
|
|
18
|
+
BUNDLE_JOBS: "3"
|
|
19
|
+
BUNDLE_RETRY: "3"
|
|
20
|
+
steps:
|
|
21
|
+
- checkout
|
|
22
|
+
- ruby/install-deps
|
|
23
|
+
- ruby/rspec-test
|
|
24
|
+
|
|
25
|
+
workflows:
|
|
26
|
+
version: 2
|
|
27
|
+
build_and_test:
|
|
28
|
+
jobs:
|
|
29
|
+
- build
|
|
30
|
+
- test:
|
|
31
|
+
requires:
|
|
32
|
+
- build
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.
|
|
1
|
+
ruby-2.5.0
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
coffee_table (0.
|
|
4
|
+
coffee_table (0.3.0)
|
|
5
5
|
activesupport
|
|
6
6
|
gzip
|
|
7
7
|
redis
|
|
@@ -11,63 +11,74 @@ PATH
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: http://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
activesupport (
|
|
14
|
+
activesupport (6.0.3.1)
|
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
16
|
-
i18n (
|
|
16
|
+
i18n (>= 0.7, < 2)
|
|
17
17
|
minitest (~> 5.1)
|
|
18
18
|
tzinfo (~> 1.1)
|
|
19
|
-
|
|
20
|
-
concurrent-ruby (1.
|
|
21
|
-
coveralls (0.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
diff-lcs (1.
|
|
19
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
20
|
+
concurrent-ruby (1.1.6)
|
|
21
|
+
coveralls (0.8.23)
|
|
22
|
+
json (>= 1.8, < 3)
|
|
23
|
+
simplecov (~> 0.16.1)
|
|
24
|
+
term-ansicolor (~> 1.3)
|
|
25
|
+
thor (>= 0.19.4, < 2.0)
|
|
26
|
+
tins (~> 1.6)
|
|
27
|
+
diff-lcs (1.3)
|
|
28
|
+
docile (1.3.2)
|
|
28
29
|
file-tail (1.2.0)
|
|
29
30
|
tins (~> 1.0)
|
|
30
31
|
gzip (1.0)
|
|
31
|
-
i18n (
|
|
32
|
+
i18n (1.8.3)
|
|
32
33
|
concurrent-ruby (~> 1.0)
|
|
33
|
-
|
|
34
|
-
minitest (5.
|
|
35
|
-
mock_redis (0.
|
|
36
|
-
|
|
37
|
-
redis (
|
|
38
|
-
redis-namespace (1.6.0)
|
|
34
|
+
json (2.3.0)
|
|
35
|
+
minitest (5.14.1)
|
|
36
|
+
mock_redis (0.23.0)
|
|
37
|
+
redis (4.2.1)
|
|
38
|
+
redis-namespace (1.7.0)
|
|
39
39
|
redis (>= 3.0.4)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
rspec-
|
|
44
|
-
|
|
45
|
-
rspec-
|
|
46
|
-
rspec-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
rspec-mocks (
|
|
50
|
-
|
|
40
|
+
rspec (3.9.0)
|
|
41
|
+
rspec-core (~> 3.9.0)
|
|
42
|
+
rspec-expectations (~> 3.9.0)
|
|
43
|
+
rspec-mocks (~> 3.9.0)
|
|
44
|
+
rspec-core (3.9.2)
|
|
45
|
+
rspec-support (~> 3.9.3)
|
|
46
|
+
rspec-expectations (3.9.2)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.9.0)
|
|
49
|
+
rspec-mocks (3.9.1)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.9.0)
|
|
52
|
+
rspec-support (3.9.3)
|
|
53
|
+
rspec_junit_formatter (0.4.1)
|
|
54
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
55
|
+
ruby2ruby (2.4.4)
|
|
51
56
|
ruby_parser (~> 3.1)
|
|
52
57
|
sexp_processor (~> 4.6)
|
|
53
|
-
ruby_parser (3.
|
|
58
|
+
ruby_parser (3.14.2)
|
|
54
59
|
sexp_processor (~> 4.9)
|
|
55
|
-
sexp_processor (4.
|
|
56
|
-
simplecov (0.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
sexp_processor (4.15.0)
|
|
61
|
+
simplecov (0.16.1)
|
|
62
|
+
docile (~> 1.1)
|
|
63
|
+
json (>= 1.8, < 3)
|
|
64
|
+
simplecov-html (~> 0.10.0)
|
|
65
|
+
simplecov-html (0.10.2)
|
|
60
66
|
sourcify (0.5.0)
|
|
61
67
|
file-tail (>= 1.0.5)
|
|
62
68
|
ruby2ruby (>= 1.2.5)
|
|
63
69
|
ruby_parser (>= 2.0.5)
|
|
64
70
|
sexp_processor (>= 3.0.5)
|
|
65
71
|
spork (0.9.2)
|
|
66
|
-
|
|
72
|
+
sync (0.5.0)
|
|
73
|
+
term-ansicolor (1.7.1)
|
|
74
|
+
tins (~> 1.0)
|
|
75
|
+
thor (1.0.1)
|
|
67
76
|
thread_safe (0.3.6)
|
|
68
|
-
tins (1.
|
|
69
|
-
|
|
77
|
+
tins (1.25.0)
|
|
78
|
+
sync
|
|
79
|
+
tzinfo (1.2.7)
|
|
70
80
|
thread_safe (~> 0.1)
|
|
81
|
+
zeitwerk (2.3.0)
|
|
71
82
|
|
|
72
83
|
PLATFORMS
|
|
73
84
|
ruby
|
|
@@ -77,7 +88,8 @@ DEPENDENCIES
|
|
|
77
88
|
coveralls
|
|
78
89
|
mock_redis
|
|
79
90
|
rspec
|
|
91
|
+
rspec_junit_formatter
|
|
80
92
|
spork
|
|
81
93
|
|
|
82
94
|
BUNDLED WITH
|
|
83
|
-
1.
|
|
95
|
+
2.1.4
|
data/README.textile
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
h1. CoffeeTable v0.2.8
|
|
3
3
|
|
|
4
4
|
!https://badge.fury.io/rb/coffee_table.png!:http://badge.fury.io/rb/coffee_table
|
|
5
|
-
!https://gemnasium.com/stewartmckee/coffee_table.png!
|
|
6
5
|
!https://coveralls.io/repos/stewartmckee/coffee_table/badge.png?branch=master(Coverage Status)!:https://coveralls.io/r/stewartmckee/coffee_table
|
|
7
6
|
|
|
8
7
|
h2. Intro
|
data/coffee_table.gemspec
CHANGED
|
@@ -23,6 +23,8 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_development_dependency "mock_redis"
|
|
24
24
|
s.add_development_dependency "spork"
|
|
25
25
|
s.add_development_dependency "coveralls"
|
|
26
|
+
s.add_development_dependency "rspec_junit_formatter"
|
|
27
|
+
|
|
26
28
|
s.add_dependency "redis"
|
|
27
29
|
s.add_dependency "redis-namespace"
|
|
28
30
|
s.add_dependency "activesupport"
|
data/lib/coffee_table.rb
CHANGED
|
@@ -5,7 +5,7 @@ require "coffee_table/invalid_object_error"
|
|
|
5
5
|
require "coffee_table/block_missing_error"
|
|
6
6
|
require "coffee_table/object_definition"
|
|
7
7
|
require "redis"
|
|
8
|
-
require
|
|
8
|
+
require "redis-namespace"
|
|
9
9
|
require 'active_support/inflector'
|
|
10
10
|
require 'digest/md5'
|
|
11
11
|
require 'gzip'
|
|
@@ -16,6 +16,8 @@ module CoffeeTable
|
|
|
16
16
|
|
|
17
17
|
include CoffeeTable::Utility
|
|
18
18
|
|
|
19
|
+
attr_reader :redis
|
|
20
|
+
|
|
19
21
|
# initialize for coffee_table. takes options to setup behaviour of cache
|
|
20
22
|
def initialize(options={})
|
|
21
23
|
@options = options.symbolize_keys
|
|
@@ -39,6 +41,7 @@ module CoffeeTable
|
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
@redis = Redis::Namespace.new(@options[:redis_namespace], :redis => redis_client)
|
|
44
|
+
@real_redis = redis_client
|
|
42
45
|
|
|
43
46
|
self
|
|
44
47
|
|
|
@@ -64,22 +67,21 @@ module CoffeeTable
|
|
|
64
67
|
block_source = RubyVM::InstructionSequence.disasm(block.to_proc).to_s.gsub(/\(\s*\d+\)/, "").gsub(/^== disasm.*?$/, "")
|
|
65
68
|
block_key = Digest::MD5.hexdigest(block_source)
|
|
66
69
|
end
|
|
67
|
-
|
|
68
70
|
flags = {}
|
|
69
71
|
|
|
70
72
|
# if first related_object is integer or fixnum it is used as an expiry time for the cache object
|
|
71
|
-
key = CoffeeTable::Key.new(initial_key, block_key, flags, related_objects)
|
|
73
|
+
key = CoffeeTable::Key.new({name: initial_key, block_key: block_key, options: @options, flags: flags}, related_objects)
|
|
72
74
|
if @options[:enable_cache]
|
|
73
75
|
if options.has_key?(:expiry)
|
|
74
76
|
expiry = options[:expiry]
|
|
75
77
|
else
|
|
76
78
|
expiry = nil
|
|
77
79
|
end
|
|
78
|
-
if
|
|
80
|
+
if keys.include?(key.to_s)
|
|
79
81
|
result = marshal_value(@redis.get(key.to_s))
|
|
80
82
|
else
|
|
81
83
|
key.add_flag(:compressed => true)
|
|
82
|
-
if
|
|
84
|
+
if keys.include?(key.to_s)
|
|
83
85
|
result = marshal_value(@redis.get(key.to_s)).gunzip
|
|
84
86
|
else
|
|
85
87
|
key.remove_flag(:compressed)
|
|
@@ -164,7 +166,11 @@ module CoffeeTable
|
|
|
164
166
|
|
|
165
167
|
private
|
|
166
168
|
def marshal_value(value)
|
|
169
|
+
return nil if value.nil?
|
|
167
170
|
begin
|
|
171
|
+
# io = StringIO.new
|
|
172
|
+
# io.write(value)
|
|
173
|
+
# io.rewind
|
|
168
174
|
result = Marshal.load(value)
|
|
169
175
|
rescue ArgumentError => e
|
|
170
176
|
puts "Attempting to load class/module #{e.message.split(" ")[-1]}"
|
data/lib/coffee_table/key.rb
CHANGED
|
@@ -6,15 +6,16 @@ module CoffeeTable
|
|
|
6
6
|
|
|
7
7
|
def self.parse(string)
|
|
8
8
|
elements = string.split("|", -1).map{|e| decode_element(e) }
|
|
9
|
-
key = Key.new(elements[0], elements[1], Hash[elements.last.split("&").map{|kv| [kv.split("=")[0].to_sym, kv.split("=")[1]]}])
|
|
9
|
+
key = Key.new(name: elements[0], block_key: elements[1], flags: Hash[elements.last.split("&").map{|kv| [kv.split("=")[0].to_sym, kv.split("=")[1]]}])
|
|
10
10
|
key.elements = elements[2..-2]
|
|
11
11
|
key
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def initialize(
|
|
15
|
-
@
|
|
16
|
-
@
|
|
17
|
-
@options = options
|
|
14
|
+
def initialize(params = {}, *objects)
|
|
15
|
+
@block_key = params[:block_key] || ""
|
|
16
|
+
@flags = params[:flags] || {}
|
|
17
|
+
@options = params[:options] || {}
|
|
18
|
+
@name = "#{params[:name]}"
|
|
18
19
|
@elements = objects.flatten.map{|o| key_for_object(o)}
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -34,15 +35,15 @@ module CoffeeTable
|
|
|
34
35
|
@block_key
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
def
|
|
38
|
-
@
|
|
38
|
+
def flags
|
|
39
|
+
@flags
|
|
39
40
|
end
|
|
40
41
|
|
|
41
|
-
def add_flag(
|
|
42
|
-
@
|
|
42
|
+
def add_flag(flags)
|
|
43
|
+
@flags.merge!(flags)
|
|
43
44
|
end
|
|
44
45
|
def remove_flag(key)
|
|
45
|
-
@
|
|
46
|
+
@flags.delete key
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def elements
|
|
@@ -50,7 +51,7 @@ module CoffeeTable
|
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
def elements=(elements)
|
|
53
|
-
@elements = elements
|
|
54
|
+
@elements = Array(elements)
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
def <=>(o)
|
|
@@ -58,16 +59,16 @@ module CoffeeTable
|
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def to_s
|
|
61
|
-
[encode_element(@name), encode_element(@block_key), @elements.map{|e| encode_element(e) }, encode_element(@
|
|
62
|
+
[encode_element(@name), encode_element(@block_key), @elements.map{|e| encode_element(e) }, encode_element(@flags.map{|k,v| "#{k}=#{v}"}.join("&"))].flatten.join("|")
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
private
|
|
65
66
|
|
|
66
|
-
def matches?(fragment,
|
|
67
|
-
if
|
|
67
|
+
def matches?(fragment, flags={})
|
|
68
|
+
if flags[:match] == :start
|
|
68
69
|
@name == fragment || !@elements.select{|e| e =~ /^#{Regexp.escape(fragment)}/ }.empty?
|
|
69
70
|
else
|
|
70
|
-
@name == fragment || @elements.include?(fragment)
|
|
71
|
+
@name == fragment || Array(@elements).include?(fragment)
|
|
71
72
|
end
|
|
72
73
|
end
|
|
73
74
|
|
data/lib/coffee_table/version.rb
CHANGED
|
@@ -6,12 +6,12 @@ describe CoffeeTable::Cache do
|
|
|
6
6
|
@coffee_table = CoffeeTable::Cache.new
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
specify { CoffeeTable::Cache.
|
|
10
|
-
specify { @coffee_table.
|
|
11
|
-
specify { @coffee_table.
|
|
12
|
-
specify { @coffee_table.
|
|
13
|
-
specify { @coffee_table.
|
|
14
|
-
specify { @coffee_table.
|
|
9
|
+
specify { expect(CoffeeTable::Cache).to respond_to :new}
|
|
10
|
+
specify { expect(@coffee_table).to respond_to :fetch}
|
|
11
|
+
specify { expect(@coffee_table).to respond_to :expire_key}
|
|
12
|
+
specify { expect(@coffee_table).to respond_to :expire_all}
|
|
13
|
+
specify { expect(@coffee_table).to respond_to :keys}
|
|
14
|
+
specify { expect(@coffee_table).to respond_to :expire_for}
|
|
15
15
|
|
|
16
16
|
describe "config" do
|
|
17
17
|
it "should take a hash for config" do
|
|
@@ -31,7 +31,7 @@ describe CoffeeTable::Cache do
|
|
|
31
31
|
"this is a value"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
result.
|
|
34
|
+
expect(result).to eq "this is a value"
|
|
35
35
|
end
|
|
36
36
|
it "should return cached value when cache available" do
|
|
37
37
|
value = "this is a value"
|
|
@@ -43,7 +43,7 @@ describe CoffeeTable::Cache do
|
|
|
43
43
|
value
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
result.
|
|
46
|
+
expect(result).to eq "this is a value"
|
|
47
47
|
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -59,16 +59,16 @@ describe CoffeeTable::Cache do
|
|
|
59
59
|
result = @coffee_table.fetch(:test_key) do
|
|
60
60
|
"this string should be long"
|
|
61
61
|
end
|
|
62
|
-
result.
|
|
63
|
-
@redis.get("test_key|
|
|
62
|
+
expect(result).to eql "this string should be long"
|
|
63
|
+
@redis.get("test_key|90a52c9dc8646bf66e93ce76578306c6|compressed=true").should start_with "\u0004"
|
|
64
64
|
end
|
|
65
65
|
it "does not compress on non strings" do
|
|
66
66
|
@coffee_table = CoffeeTable::Cache.new(:server => "127.0.0.1", :port => 6379, :compress_min_size => 20)
|
|
67
67
|
result = @coffee_table.fetch(:test_key) do
|
|
68
68
|
{:test => "this value is a decent length to trigger compress"}
|
|
69
69
|
end
|
|
70
|
-
result.
|
|
71
|
-
Base64.encode64(@redis.get("test_key|
|
|
70
|
+
expect(result).to eql ({:test => "this value is a decent length to trigger compress"})
|
|
71
|
+
Base64.encode64(@redis.get("test_key|0402899032596ee850d5271ab2312906|")).should eql "BAh7BjoJdGVzdEkiNnRoaXMgdmFsdWUgaXMgYSBkZWNlbnQgbGVuZ3RoIHRv\nIHRyaWdnZXIgY29tcHJlc3MGOgZFVA==\n"
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "does not compress when turned off" do
|
|
@@ -76,16 +76,16 @@ describe CoffeeTable::Cache do
|
|
|
76
76
|
result = @coffee_table.fetch(:test_key) do
|
|
77
77
|
"this string should be long"
|
|
78
78
|
end
|
|
79
|
-
result.
|
|
80
|
-
@redis.get("test_key|
|
|
79
|
+
expect(result).to eql "this string should be long"
|
|
80
|
+
@redis.get("test_key|90a52c9dc8646bf66e93ce76578306c6|").should eql Marshal.dump("this string should be long")
|
|
81
81
|
end
|
|
82
82
|
it "does not compress on strings below limit" do
|
|
83
83
|
@coffee_table = CoffeeTable::Cache.new(:server => "127.0.0.1", :port => 6379, :compress_min_size => 20)
|
|
84
84
|
result = @coffee_table.fetch(:test_key) do
|
|
85
85
|
"short"
|
|
86
86
|
end
|
|
87
|
-
result.
|
|
88
|
-
@redis.get("test_key|
|
|
87
|
+
expect(result).to eql "short"
|
|
88
|
+
@redis.get("test_key|55d2ae66967c26b2fef23e5ed6bd3930|").should eql Marshal.dump("short")
|
|
89
89
|
end
|
|
90
90
|
it "decompresses compressed value" do
|
|
91
91
|
@coffee_table = CoffeeTable::Cache.new(:redis => @redis, :compress_min_size => 20)
|
|
@@ -95,8 +95,8 @@ describe CoffeeTable::Cache do
|
|
|
95
95
|
result = @coffee_table.fetch(:test_key) do
|
|
96
96
|
"this string should be long"
|
|
97
97
|
end
|
|
98
|
-
result.class.
|
|
99
|
-
result.
|
|
98
|
+
expect(result.class).to eql String
|
|
99
|
+
expect(result).to eql "this string should be long"
|
|
100
100
|
|
|
101
101
|
end
|
|
102
102
|
it "does not decompress a non compressed value" do
|
|
@@ -107,7 +107,7 @@ describe CoffeeTable::Cache do
|
|
|
107
107
|
result = @coffee_table.fetch(:test_key) do
|
|
108
108
|
"short"
|
|
109
109
|
end
|
|
110
|
-
result.
|
|
110
|
+
expect(result).to eql "short"
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
|
|
@@ -121,7 +121,7 @@ describe CoffeeTable::Cache do
|
|
|
121
121
|
result = @coffee_table.fetch(:test_key) do
|
|
122
122
|
"this is a changed value"
|
|
123
123
|
end
|
|
124
|
-
@coffee_table.keys.
|
|
124
|
+
expect(@coffee_table.keys).to eq ["test_key|#{md5}|"]
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it "should create key from class" do
|
|
@@ -131,7 +131,7 @@ describe CoffeeTable::Cache do
|
|
|
131
131
|
result = @coffee_table.fetch(:test_key, SampleClass) do
|
|
132
132
|
"this is a changed value"
|
|
133
133
|
end
|
|
134
|
-
@coffee_table.keys.
|
|
134
|
+
expect(@coffee_table.keys).to eq ["test_key|#{md5}|sample_classes|"]
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "should use class name for keys" do
|
|
@@ -141,7 +141,7 @@ describe CoffeeTable::Cache do
|
|
|
141
141
|
result = @coffee_table.fetch(:test_key, SampleClass.new(2)) do
|
|
142
142
|
"this is a changed value"
|
|
143
143
|
end
|
|
144
|
-
@coffee_table.keys.
|
|
144
|
+
expect(@coffee_table.keys).to eq ["test_key|#{md5}|sample_class[2]|"]
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "should use id from class in key" do
|
|
@@ -151,7 +151,7 @@ describe CoffeeTable::Cache do
|
|
|
151
151
|
result = @coffee_table.fetch(:test_key, SampleClass.new(2)) do
|
|
152
152
|
"this is a changed value"
|
|
153
153
|
end
|
|
154
|
-
@coffee_table.keys.
|
|
154
|
+
expect(@coffee_table.keys).to eq ["test_key|#{md5}|sample_class[2]|"]
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
end
|
|
@@ -167,7 +167,7 @@ describe CoffeeTable::Cache do
|
|
|
167
167
|
"this is a changed value"
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
-
@coffee_table.keys.
|
|
170
|
+
expect(@coffee_table.keys).to include "test_key|#{md5}|sample_class[9938]|"
|
|
171
171
|
|
|
172
172
|
end
|
|
173
173
|
it "should raise an exception if a related object does not respond_to id" do
|
|
@@ -190,7 +190,7 @@ describe CoffeeTable::Cache do
|
|
|
190
190
|
"this is a changed value"
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
-
@coffee_table.keys.
|
|
193
|
+
expect(@coffee_table.keys).to include "test_key|#{md5}|sample_classes|"
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
end
|
|
@@ -199,9 +199,9 @@ describe CoffeeTable::Cache do
|
|
|
199
199
|
@coffee_table.fetch(:test_key, :expiry => 1) do
|
|
200
200
|
"object1"
|
|
201
201
|
end
|
|
202
|
-
@coffee_table.keys.count.
|
|
202
|
+
expect(@coffee_table.keys.count).to eq 1
|
|
203
203
|
sleep 1
|
|
204
|
-
@coffee_table.keys.count.
|
|
204
|
+
expect(@coffee_table.keys.count).to eq 0
|
|
205
205
|
end
|
|
206
206
|
it "should not execute block during cache period" do
|
|
207
207
|
value = 'this is a value'
|
|
@@ -212,8 +212,7 @@ describe CoffeeTable::Cache do
|
|
|
212
212
|
result = @coffee_table.fetch("asdf") do
|
|
213
213
|
value
|
|
214
214
|
end
|
|
215
|
-
result.
|
|
216
|
-
|
|
215
|
+
expect(result).to eq "this is a value"
|
|
217
216
|
end
|
|
218
217
|
it "should execute block and return value when cache has expired" do
|
|
219
218
|
@coffee_table.fetch("asdf", :expiry => 1) do
|
|
@@ -223,7 +222,7 @@ describe CoffeeTable::Cache do
|
|
|
223
222
|
result = @coffee_table.fetch("asdf") do
|
|
224
223
|
"this is a changed value"
|
|
225
224
|
end
|
|
226
|
-
result.
|
|
225
|
+
expect(result).to eq "this is a changed value"
|
|
227
226
|
end
|
|
228
227
|
end
|
|
229
228
|
|
|
@@ -237,7 +236,7 @@ describe CoffeeTable::Cache do
|
|
|
237
236
|
result = @coffee_table.get_cache(:test_key) do
|
|
238
237
|
object
|
|
239
238
|
end
|
|
240
|
-
result.
|
|
239
|
+
expect(result).to eq "object1"
|
|
241
240
|
end
|
|
242
241
|
it "should change key with changed code" do
|
|
243
242
|
@coffee_table.get_cache(:test_key) do
|
|
@@ -246,7 +245,7 @@ describe CoffeeTable::Cache do
|
|
|
246
245
|
result = @coffee_table.get_cache(:test_key) do
|
|
247
246
|
"object2"
|
|
248
247
|
end
|
|
249
|
-
result.
|
|
248
|
+
expect(result).to eq "object2"
|
|
250
249
|
end
|
|
251
250
|
end
|
|
252
251
|
end
|
|
@@ -276,9 +275,9 @@ describe CoffeeTable::Cache do
|
|
|
276
275
|
"object3"
|
|
277
276
|
end
|
|
278
277
|
|
|
279
|
-
@coffee_table.keys.sort.
|
|
278
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|", "second_key|#{@proc_md52}|", "third_key|#{@proc_md53}|"].sort
|
|
280
279
|
@coffee_table.expire_key("second_key")
|
|
281
|
-
@coffee_table.keys.sort.
|
|
280
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|", "third_key|#{@proc_md53}|"].sort
|
|
282
281
|
|
|
283
282
|
end
|
|
284
283
|
it "should not expire anything if no matches" do
|
|
@@ -302,9 +301,9 @@ describe CoffeeTable::Cache do
|
|
|
302
301
|
"object3"
|
|
303
302
|
end
|
|
304
303
|
|
|
305
|
-
@coffee_table.keys.sort.
|
|
304
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|", "second_key|#{@proc_md52}|", "third_key|#{@proc_md53}|"].sort
|
|
306
305
|
@coffee_table.expire_key("fourth_key")
|
|
307
|
-
@coffee_table.keys.sort.
|
|
306
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|", "second_key|#{@proc_md52}|", "third_key|#{@proc_md53}|"].sort
|
|
308
307
|
|
|
309
308
|
end
|
|
310
309
|
|
|
@@ -322,7 +321,7 @@ describe CoffeeTable::Cache do
|
|
|
322
321
|
"object2"
|
|
323
322
|
end
|
|
324
323
|
|
|
325
|
-
result.
|
|
324
|
+
expect(result).to eq "object2"
|
|
326
325
|
end
|
|
327
326
|
|
|
328
327
|
it "should not invalidate block when block has not changed" do
|
|
@@ -336,7 +335,7 @@ describe CoffeeTable::Cache do
|
|
|
336
335
|
object
|
|
337
336
|
end
|
|
338
337
|
|
|
339
|
-
result.
|
|
338
|
+
expect(result).to eq "object1"
|
|
340
339
|
end
|
|
341
340
|
|
|
342
341
|
it "should not be affected by whitespace only changes" do
|
|
@@ -347,12 +346,10 @@ describe CoffeeTable::Cache do
|
|
|
347
346
|
|
|
348
347
|
object = "object2"
|
|
349
348
|
result = @coffee_table.fetch(:test_key) do
|
|
350
|
-
|
|
351
349
|
object
|
|
352
|
-
|
|
353
350
|
end
|
|
354
351
|
|
|
355
|
-
result.
|
|
352
|
+
expect(result).to eq "object1"
|
|
356
353
|
end
|
|
357
354
|
|
|
358
355
|
end
|
|
@@ -372,7 +369,7 @@ describe CoffeeTable::Cache do
|
|
|
372
369
|
"object2"
|
|
373
370
|
end
|
|
374
371
|
|
|
375
|
-
result.
|
|
372
|
+
expect(result).to eq "object1"
|
|
376
373
|
end
|
|
377
374
|
end
|
|
378
375
|
end
|
|
@@ -396,15 +393,15 @@ describe CoffeeTable::Cache do
|
|
|
396
393
|
end
|
|
397
394
|
|
|
398
395
|
it "should delete all keys" do
|
|
399
|
-
@coffee_table.keys.count.
|
|
396
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
400
397
|
@coffee_table.expire_all
|
|
401
|
-
@coffee_table.keys.count.
|
|
398
|
+
expect(@coffee_table.keys.count).to eq 0
|
|
402
399
|
|
|
403
400
|
result = @coffee_table.fetch(:first_key) do
|
|
404
401
|
"changed value"
|
|
405
402
|
end
|
|
406
403
|
|
|
407
|
-
result.
|
|
404
|
+
expect(result).to eq "changed value"
|
|
408
405
|
|
|
409
406
|
end
|
|
410
407
|
end
|
|
@@ -428,8 +425,8 @@ describe CoffeeTable::Cache do
|
|
|
428
425
|
end
|
|
429
426
|
|
|
430
427
|
it "should return an array of string" do
|
|
431
|
-
@coffee_table.keys.
|
|
432
|
-
@coffee_table.keys.map{|key| key.
|
|
428
|
+
expect(@coffee_table.keys).to be_an_instance_of Array
|
|
429
|
+
@coffee_table.keys.map{|key| expect(key).to be_an_instance_of String}
|
|
433
430
|
end
|
|
434
431
|
it "should return key created without objects" do
|
|
435
432
|
@coffee_table.fetch(:first_key) do
|
|
@@ -442,7 +439,7 @@ describe CoffeeTable::Cache do
|
|
|
442
439
|
"object3"
|
|
443
440
|
end
|
|
444
441
|
|
|
445
|
-
@coffee_table.keys.sort.
|
|
442
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|",
|
|
446
443
|
"second_key|#{@proc_md52}|",
|
|
447
444
|
"third_key|#{@proc_md53}|"].sort
|
|
448
445
|
|
|
@@ -457,7 +454,7 @@ describe CoffeeTable::Cache do
|
|
|
457
454
|
@coffee_table.fetch(:third_key, @object3) do
|
|
458
455
|
"object3"
|
|
459
456
|
end
|
|
460
|
-
@coffee_table.keys.sort.
|
|
457
|
+
expect(@coffee_table.keys.sort).to eq ["first_key|#{@proc_md51}|sample_class[1]|sample_class[2]|sample_class[3]|",
|
|
461
458
|
"second_key|#{@proc_md52}|sample_class[4]|sample_class[2]|sample_class[5]|",
|
|
462
459
|
"third_key|#{@proc_md53}|sample_class[7]|sample_class[2]|sample_class[8]|"].sort
|
|
463
460
|
end
|
|
@@ -482,47 +479,47 @@ describe CoffeeTable::Cache do
|
|
|
482
479
|
end
|
|
483
480
|
|
|
484
481
|
it "should expire based on the initial key" do
|
|
485
|
-
@coffee_table.keys.count.
|
|
482
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
486
483
|
@coffee_table.expire_for(:second_key)
|
|
487
|
-
@coffee_table.keys.count.
|
|
484
|
+
expect(@coffee_table.keys.count).to eq 2
|
|
488
485
|
end
|
|
489
486
|
|
|
490
487
|
it "should expire based on a simple string" do
|
|
491
|
-
@coffee_table.keys.count.
|
|
488
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
492
489
|
@coffee_table.expire_for("sample_class[4]")
|
|
493
|
-
@coffee_table.keys.count.
|
|
490
|
+
expect(@coffee_table.keys.count).to eq 2
|
|
494
491
|
end
|
|
495
492
|
|
|
496
493
|
it "should not expire based on a part match" do
|
|
497
|
-
@coffee_table.keys.count.
|
|
494
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
498
495
|
@coffee_table.expire_for("impl")
|
|
499
|
-
@coffee_table.keys.count.
|
|
496
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
500
497
|
end
|
|
501
498
|
|
|
502
499
|
it "should not delete any keys if object is not present" do
|
|
503
|
-
@coffee_table.keys.count.
|
|
500
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
504
501
|
@coffee_table.expire_for(SampleClass.new(18))
|
|
505
|
-
@coffee_table.keys.count.
|
|
502
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
506
503
|
end
|
|
507
504
|
it "should only delete keys that object is present in" do
|
|
508
|
-
@coffee_table.keys.count.
|
|
505
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
509
506
|
@coffee_table.expire_for(SampleClass.new(1))
|
|
510
|
-
@coffee_table.keys.count.
|
|
507
|
+
expect(@coffee_table.keys.count).to eq 2
|
|
511
508
|
end
|
|
512
509
|
|
|
513
510
|
it "should delete a key if the object is at the end of they key" do
|
|
514
|
-
@coffee_table.keys.count.
|
|
511
|
+
expect(@coffee_table.keys.count).to eq 3
|
|
515
512
|
@coffee_table.expire_for(SampleClass.new(3))
|
|
516
|
-
@coffee_table.keys.count.
|
|
513
|
+
expect(@coffee_table.keys.count).to eq 2
|
|
517
514
|
end
|
|
518
515
|
|
|
519
516
|
it "should expire all keys relating to a class if uninitialised class is passed in" do
|
|
520
517
|
@coffee_table.fetch(:fourth_key) do
|
|
521
518
|
"object4"
|
|
522
519
|
end
|
|
523
|
-
@coffee_table.keys.count.
|
|
520
|
+
expect(@coffee_table.keys.count).to eq 4
|
|
524
521
|
@coffee_table.expire_for(SampleClass)
|
|
525
|
-
@coffee_table.keys.count.
|
|
522
|
+
expect(@coffee_table.keys.count).to eq 1
|
|
526
523
|
end
|
|
527
524
|
end
|
|
528
525
|
|
data/spec/lib/key_spec.rb
CHANGED
|
@@ -4,13 +4,13 @@ describe CoffeeTable::Key do
|
|
|
4
4
|
|
|
5
5
|
context "has correct methods" do
|
|
6
6
|
it "should have a parse class method" do
|
|
7
|
-
CoffeeTable::Key.
|
|
7
|
+
expect(CoffeeTable::Key).to respond_to :parse
|
|
8
8
|
end
|
|
9
9
|
it "should have a has_element? instance method" do
|
|
10
|
-
CoffeeTable::Key.new("name", "key"
|
|
10
|
+
expect(CoffeeTable::Key.new(name: "name", block_key: "key")).to respond_to :has_element?
|
|
11
11
|
end
|
|
12
12
|
it "should have a has_element_type? instance method" do
|
|
13
|
-
CoffeeTable::Key.new("name", "key"
|
|
13
|
+
expect(CoffeeTable::Key.new(name: "name", block_key: "key")).to respond_to :has_element_type?
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -19,51 +19,51 @@ describe CoffeeTable::Key do
|
|
|
19
19
|
key = CoffeeTable::Key.parse("test|asdf|sample_class|")
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
key.elements.count.
|
|
23
|
-
key.name.
|
|
24
|
-
key.code_hash.
|
|
25
|
-
key.elements[0].
|
|
22
|
+
expect(key.elements.count).to eq 1
|
|
23
|
+
expect(key.name).to eq "test"
|
|
24
|
+
expect(key.code_hash).to eq "asdf"
|
|
25
|
+
expect(key.elements[0]).to eq "sample_class"
|
|
26
26
|
|
|
27
27
|
end
|
|
28
28
|
it "should decode encoded elements" do
|
|
29
29
|
key = CoffeeTable::Key.parse("te|s&t|asdf|s&|sample_|s&class|")
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
key.elements.count.
|
|
33
|
-
key.name.
|
|
34
|
-
key.code_hash.
|
|
35
|
-
key.elements[0].
|
|
32
|
+
expect(key.elements.count).to eq 1
|
|
33
|
+
expect(key.name).to eq "te|s&t"
|
|
34
|
+
expect(key.code_hash).to eq "asdf|s&"
|
|
35
|
+
expect(key.elements[0]).to eq "sample_|s&class"
|
|
36
36
|
end
|
|
37
37
|
it "should encode the key data" do
|
|
38
38
|
|
|
39
|
-
key = CoffeeTable::Key.new("te|s&t", "asdf|s&"
|
|
39
|
+
key = CoffeeTable::Key.new({name: "te|s&t", block_key: "asdf|s&"}, "sample_|s&class")
|
|
40
40
|
|
|
41
|
-
key.name.
|
|
42
|
-
key.code_hash.
|
|
43
|
-
key.elements[0].
|
|
41
|
+
expect(key.name).to eq "te|s&t"
|
|
42
|
+
expect(key.code_hash).to eq "asdf|s&"
|
|
43
|
+
expect(key.elements[0]).to eq "sample_|s&class"
|
|
44
44
|
|
|
45
|
-
key.to_s.
|
|
45
|
+
expect(key.to_s).to eq "te|s&t|asdf|s&|sample_|s&class|"
|
|
46
46
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
context "matching keys" do
|
|
51
51
|
it "should match a key on its name" do
|
|
52
|
-
key = CoffeeTable::Key.new("name", "key"
|
|
53
|
-
key.has_element?("name").
|
|
54
|
-
key.has_element?("key").
|
|
52
|
+
key = CoffeeTable::Key.new({name: "name", block_key: "key"}, "value", ["value1", "value2"])
|
|
53
|
+
expect(key.has_element?("name")).to be_truthy
|
|
54
|
+
expect(key.has_element?("key")).to be_falsey
|
|
55
55
|
end
|
|
56
56
|
it "should match a key on its data" do
|
|
57
|
-
key = CoffeeTable::Key.new("name", "key"
|
|
58
|
-
key.has_element?("key").
|
|
59
|
-
key.has_element?("value").
|
|
60
|
-
key.has_element?("value1").
|
|
61
|
-
key.has_element?("value2").
|
|
57
|
+
key = CoffeeTable::Key.new({name: "name", block_key: "key"}, "value", ["value1", "value2"])
|
|
58
|
+
expect(key.has_element?("key")).to be_falsey
|
|
59
|
+
expect(key.has_element?("value")).to be_truthy
|
|
60
|
+
expect(key.has_element?("value1")).to be_truthy
|
|
61
|
+
expect(key.has_element?("value2")).to be_truthy
|
|
62
62
|
end
|
|
63
63
|
it "should match a key on a class type" do
|
|
64
|
-
key = CoffeeTable::Key.new("name", "key"
|
|
65
|
-
key.has_element?("key").
|
|
66
|
-
key.has_element_type?("sample_class").
|
|
64
|
+
key = CoffeeTable::Key.new({name: "name", block_key: "key"}, "sample_class[3]", ["value1", "value2"])
|
|
65
|
+
expect(key.has_element?("key")).to be_falsey
|
|
66
|
+
expect(key.has_element_type?("sample_class")).to be_truthy
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -76,39 +76,39 @@ describe CoffeeTable::Key do
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should encode options into key" do
|
|
79
|
-
key = CoffeeTable::Key.new("name", "key", {:option => "value", :option2 => "value2"})
|
|
80
|
-
key.to_s.
|
|
79
|
+
key = CoffeeTable::Key.new(name: "name", block_key: "key", flags: {:option => "value", :option2 => "value2"})
|
|
80
|
+
expect(key.to_s).to eql "name|key|option=value&option2=value2"
|
|
81
81
|
end
|
|
82
82
|
it "should parse back options out of key" do
|
|
83
83
|
key = CoffeeTable::Key.parse("name|block|key=value")
|
|
84
|
-
key.
|
|
84
|
+
expect(key.flags).to eql ({:key => "value"})
|
|
85
85
|
|
|
86
86
|
end
|
|
87
87
|
it "should handle no options" do
|
|
88
|
-
key = CoffeeTable::Key.new("name", "key"
|
|
89
|
-
key.to_s.
|
|
88
|
+
key = CoffeeTable::Key.new(name: "name", block_key: "key")
|
|
89
|
+
expect(key.to_s).to eql "name|key|"
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "should handle one option" do
|
|
93
|
-
key = CoffeeTable::Key.new("name", "key", {:option => "value"})
|
|
94
|
-
key.to_s.
|
|
93
|
+
key = CoffeeTable::Key.new(name: "name", block_key: "key", flags: {:option => "value"})
|
|
94
|
+
expect(key.to_s).to eql "name|key|option=value"
|
|
95
95
|
end
|
|
96
96
|
it "should handle multiple options" do
|
|
97
|
-
key = CoffeeTable::Key.new("name", "key", {:option => "value", :option2 => "value2"})
|
|
98
|
-
key.to_s.
|
|
97
|
+
key = CoffeeTable::Key.new(name: "name", block_key: "key", flags: {:option => "value", :option2 => "value2"})
|
|
98
|
+
expect(key.to_s).to eql "name|key|option=value&option2=value2"
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "matches regardless of flags" do
|
|
102
|
-
key = CoffeeTable::Key.new("name", "key", {:option => "value", :option2 => "value2"}, @obj1, @obj2, @obj3)
|
|
103
|
-
key.has_element?("test[1]").
|
|
104
|
-
key.has_element?("test[2]").
|
|
105
|
-
key.has_element?("test[3]").
|
|
106
|
-
key.has_element?("test[4]").
|
|
102
|
+
key = CoffeeTable::Key.new({name: "name", block_key: "key", flgas: {:option => "value", :option2 => "value2"}}, @obj1, @obj2, @obj3)
|
|
103
|
+
expect(key.has_element?("test[1]")).to be_truthy
|
|
104
|
+
expect(key.has_element?("test[2]")).to be_truthy
|
|
105
|
+
expect(key.has_element?("test[3]")).to be_truthy
|
|
106
|
+
expect(key.has_element?("test[4]")).to be_falsey
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it "does not match on flag values" do
|
|
110
|
-
key = CoffeeTable::Key.new("name", "key", {:option => "value", :option2 => "value2"}, @obj1, @obj2, @obj3)
|
|
111
|
-
key.has_element?("option=value&option2=value2").
|
|
110
|
+
key = CoffeeTable::Key.new({name: "name", block_key: "key", flags: {:option => "value", :option2 => "value2"}}, @obj1, @obj2, @obj3)
|
|
111
|
+
expect(key.has_element?("option=value&option2=value2")).to be_falsey
|
|
112
112
|
|
|
113
113
|
end
|
|
114
114
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -7,29 +7,28 @@ Coveralls.wear!
|
|
|
7
7
|
require 'digest/md5'
|
|
8
8
|
require 'spork'
|
|
9
9
|
# require 'mock_redis'
|
|
10
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
11
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec/lib/sample_class.rb')
|
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec/lib/sample_class_without_id.rb')
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
Spork.prefork do
|
|
15
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
16
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
17
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/coffee_table.rb')
|
|
16
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/coffee_table/block_missing_error.rb')
|
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/coffee_table/invalid_object_error.rb')
|
|
18
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/coffee_table/key.rb')
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
Spork.each_run do
|
|
22
22
|
RSpec.configure do |config|
|
|
23
23
|
config.before(:each) {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# Redis.stub(:new).and_return(MockRedis.new)
|
|
28
|
-
CoffeeTable::Cache.new.expire_all
|
|
25
|
+
redis = CoffeeTable::Cache.new.redis
|
|
26
|
+
redis.keys.map{|k| redis.del k }
|
|
29
27
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
config.after(:each) {
|
|
31
|
+
# CoffeeTable::Cache.new.expire_all
|
|
33
32
|
}
|
|
34
33
|
end
|
|
35
34
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: coffee_table
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stewart McKee
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec_junit_formatter
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: redis
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -143,6 +157,7 @@ executables: []
|
|
|
143
157
|
extensions: []
|
|
144
158
|
extra_rdoc_files: []
|
|
145
159
|
files:
|
|
160
|
+
- ".circleci/config.yml"
|
|
146
161
|
- ".gitignore"
|
|
147
162
|
- ".rspec"
|
|
148
163
|
- ".ruby-gemset"
|
|
@@ -185,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
185
200
|
version: '0'
|
|
186
201
|
requirements: []
|
|
187
202
|
rubyforge_project: coffee_table
|
|
188
|
-
rubygems_version: 2.
|
|
203
|
+
rubygems_version: 2.7.8
|
|
189
204
|
signing_key:
|
|
190
205
|
specification_version: 4
|
|
191
206
|
summary: Gem to manage cache stored in redis
|