alephant-cache 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/cache.rb +10 -3
- data/lib/alephant/cache/version.rb +1 -1
- data/spec/cache_spec.rb +12 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5befc55adc71cd49d5ec1786756af138c366a5
|
4
|
+
data.tar.gz: 2d216ecdba497e169db7e304c09a30201786ea0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 956ba6abd6f43b25ae0dca5d328e486550424d1ee620d23d99cce59e17f4eba2061a6e561aa90492e40c0b98b8253fd0e5812e6e70155b78d4fe3c517d475f58
|
7
|
+
data.tar.gz: f6550f9b26e28398a8176ac68458a33200accc75b8c6af61c9096b078cc8a0f53740481b371e96703114b1c692a1b61423fdfdb936f50f1325a63c794acad652
|
data/lib/alephant/cache.rb
CHANGED
@@ -20,11 +20,12 @@ module Alephant
|
|
20
20
|
logger.info("Cache.clear: #{path}")
|
21
21
|
end
|
22
22
|
|
23
|
-
def put(id, data, meta = {})
|
23
|
+
def put(id, data, content_type = 'text/plain', meta = {})
|
24
24
|
bucket.objects["#{path}/#{id}"].write(
|
25
25
|
data,
|
26
26
|
{
|
27
|
-
:
|
27
|
+
:content_type => content_type,
|
28
|
+
:metadata => meta
|
28
29
|
}
|
29
30
|
)
|
30
31
|
|
@@ -33,7 +34,13 @@ module Alephant
|
|
33
34
|
|
34
35
|
def get(id)
|
35
36
|
logger.info("Cache.get: #{path}/#{id}")
|
36
|
-
bucket.objects["#{path}/#{id}"]
|
37
|
+
object = bucket.objects["#{path}/#{id}"]
|
38
|
+
|
39
|
+
{
|
40
|
+
:content => object.read,
|
41
|
+
:content_type => object.content_type
|
42
|
+
}
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
46
|
+
|
data/spec/cache_spec.rb
CHANGED
@@ -48,7 +48,7 @@ describe Alephant::Cache do
|
|
48
48
|
describe "put(id, data)" do
|
49
49
|
it "sets bucket path/id content data" do
|
50
50
|
s3_object_collection = double()
|
51
|
-
s3_object_collection.should_receive(:write).with(:data
|
51
|
+
s3_object_collection.should_receive(:write).with(:data, { :content_type => 'foo/bar', :metadata=>{} })
|
52
52
|
|
53
53
|
s3_bucket = double()
|
54
54
|
s3_bucket.should_receive(:objects).and_return(
|
@@ -60,14 +60,15 @@ describe Alephant::Cache do
|
|
60
60
|
AWS::S3.any_instance.stub(:buckets).and_return({ id => s3_bucket })
|
61
61
|
instance = subject.new(id, path)
|
62
62
|
|
63
|
-
instance.put(id, data)
|
63
|
+
instance.put(id, data, 'foo/bar')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "get(id)" do
|
68
68
|
it "gets bucket path/id content data" do
|
69
69
|
s3_object_collection = double()
|
70
|
-
s3_object_collection.should_receive(:read)
|
70
|
+
s3_object_collection.should_receive(:read).and_return("content")
|
71
|
+
s3_object_collection.should_receive(:content_type).and_return("foo/bar")
|
71
72
|
|
72
73
|
s3_bucket = double()
|
73
74
|
s3_bucket.should_receive(:objects).and_return(
|
@@ -79,7 +80,14 @@ describe Alephant::Cache do
|
|
79
80
|
AWS::S3.any_instance.stub(:buckets).and_return({ id => s3_bucket })
|
80
81
|
|
81
82
|
instance = subject.new(id, path)
|
82
|
-
instance.get(id)
|
83
|
+
object_hash = instance.get(id)
|
84
|
+
|
85
|
+
expected_hash = {
|
86
|
+
:content => "content",
|
87
|
+
:content_type => "foo/bar"
|
88
|
+
}
|
89
|
+
|
90
|
+
expect(object_hash).to eq(expected_hash)
|
83
91
|
end
|
84
92
|
end
|
85
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|