alephant-cache 0.0.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b5bf5c741587aefd5d88398fb5ec9412194f566
4
- data.tar.gz: 831200ba65814a06a4993d3a6cae93bee54423cd
3
+ metadata.gz: 3e5befc55adc71cd49d5ec1786756af138c366a5
4
+ data.tar.gz: 2d216ecdba497e169db7e304c09a30201786ea0d
5
5
  SHA512:
6
- metadata.gz: fbfce75cc5f65da0f6bf4d83a38c8835c6b6ae9d1d4d6448af565926044d21ce74e51853fdd13a9263310c1ee099cdf60ea9d28f27c5ef4e2b19c2b395ef602f
7
- data.tar.gz: 0360a92c0a490b9cc3bd798b58dfd31e08f8ec68307ac77e92da0e155f096706b575dd8074a3fbd99839f80c6001aeadb1520a3a12961ddf5525cde62f8e5253
6
+ metadata.gz: 956ba6abd6f43b25ae0dca5d328e486550424d1ee620d23d99cce59e17f4eba2061a6e561aa90492e40c0b98b8253fd0e5812e6e70155b78d4fe3c517d475f58
7
+ data.tar.gz: f6550f9b26e28398a8176ac68458a33200accc75b8c6af61c9096b078cc8a0f53740481b371e96703114b1c692a1b61423fdfdb936f50f1325a63c794acad652
@@ -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
- :metadata => meta
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}"].read
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
+
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  class Cache
3
- VERSION = "0.0.4"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -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,:metadata=>{})
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
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-05-14 00:00:00.000000000 Z
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec