alephant-cache 0.0.2 → 0.0.3

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: 0fa689407335c2d994630c3cbaca964969339253
4
- data.tar.gz: c6b2b9c052f1cb655761ba1c88bcff9aa8dc8594
3
+ metadata.gz: 9bffd87081f54072fa6fc2d529398aac88e09661
4
+ data.tar.gz: bff957d2d404bfb09aca76c16354a5da4b7fbfc2
5
5
  SHA512:
6
- metadata.gz: 1ef2734b256448e73850d1ff191416bd34987faa666b1bfe2fb39e358c424a004a0fb9c55f1aeb7cfcb005ecaac372e1eacc0152b08dfa438008ccb4c3ae7748
7
- data.tar.gz: f2a7d41c205a86df6ac284d85bae926b385fa1a1bcf62198355e67cc7d6e640cebaf0b24569836014e73a32833c947ed9dc287204bac3ee0ffb740faadfd5f38
6
+ metadata.gz: c1d433f7652ff3561a4b29b5631d72335496bfb24cf78493d2e20d531c2206fbda63a2aa2d03e29c196dd8561d5d9e29b980fb534b2a08b059e763c757df07d0
7
+ data.tar.gz: 031990a6cffb28cb84bb3cfa84212b78f9bbe4c86e429ad622166649a8f13c767e32266dab919a1519073ae4414e8230eda6a9f81b5f9af023252130e5bbabfe
@@ -11,19 +11,23 @@ module Alephant
11
11
  @id = id
12
12
  @path = path
13
13
 
14
- s3 = AWS::S3.new
15
- @bucket = s3.buckets[id]
14
+ @bucket = AWS::S3.new.buckets[id]
16
15
  logger.info("Cache.initialize: end with id #{id} and path #{path}")
17
16
  end
18
17
 
18
+ def clear
19
+ bucket.objects.with_prefix(path).delete_all
20
+ logger.info("Cache.clear: #{path}")
21
+ end
22
+
19
23
  def put(id, data)
20
- @bucket.objects["#{@path}/#{id}"].write(data)
21
- logger.info("Cache.put: #{@path}/#{id}")
24
+ bucket.objects["#{path}/#{id}"].write(data)
25
+ logger.info("Cache.put: #{path}/#{id}")
22
26
  end
23
27
 
24
28
  def get(id)
25
- logger.info("Cache.get: #{@path}/#{id}")
26
- @bucket.objects["#{@path}/#{id}"].read
29
+ logger.info("Cache.get: #{path}/#{id}")
30
+ bucket.objects["#{path}/#{id}"].read
27
31
  end
28
32
  end
29
33
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  class Cache
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -22,6 +22,29 @@ describe Alephant::Cache do
22
22
  end
23
23
  end
24
24
 
25
+ describe "clear" do
26
+ let(:num_object_in_path) { 100 }
27
+ it "deletes all objects for a path" do
28
+ filtered_object_collection = double()
29
+ filtered_object_collection
30
+ .should_receive(:delete_all)
31
+
32
+ s3_object_collection = double()
33
+ s3_object_collection
34
+ .should_receive(:with_prefix)
35
+ .with(path)
36
+ .and_return(filtered_object_collection)
37
+
38
+ s3_bucket = double()
39
+ s3_bucket.should_receive(:objects).and_return(s3_object_collection)
40
+
41
+ AWS::S3.any_instance.stub(:buckets).and_return({ id => s3_bucket })
42
+
43
+ instance = subject.new(id, path)
44
+ instance.clear
45
+ end
46
+ end
47
+
25
48
  describe "put(id, data)" do
26
49
  it "sets bucket path/id content data" do
27
50
  s3_object_collection = double()
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.2
4
+ version: 0.0.3
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-02-13 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec