mince_dynamo_db 2.0.0.pre.2 → 2.0.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,9 @@ module MinceDynamoDb # :nodoc:
7
7
 
8
8
  module Interface
9
9
  # Not yet implemented
10
- def self.update_field_with_value(*args)
11
- raise %(The method `MinceDynamoDb::DataStore.singleton.update_field_with_value` is not implemented, you should implement it for us!)
10
+ def self.update_field_with_value(collection_name, primary_key_value, field_name, new_value)
11
+ item = find(collection_name, primary_key_identifier, primary_key_value)
12
+ item.set(field_name => new_value)
12
13
  end
13
14
 
14
15
  def self.delete_field(collection_name, field)
@@ -23,7 +24,13 @@ module MinceDynamoDb # :nodoc:
23
24
  raise %(The method `MinceDynamoDb::DataStore.singleton.increment_field_by_amount` is not implemented, you should implement it for us!)
24
25
  end
25
26
 
27
+ def self.create_collection(collection_name, read_rate=10, write_rate=5)
28
+ collections.create(collection_name, read_rate, write_rate)
29
+ end
26
30
 
31
+ def self.collection_status(collection_name)
32
+ collection(collection_name).status
33
+ end
27
34
 
28
35
  # Returns the primary key identifier for records. This is necessary because not all databases use the same
29
36
  # primary key.
@@ -9,7 +9,7 @@ module MinceDynamoDb
9
9
  end
10
10
 
11
11
  def self.patch
12
- "0.pre.2"
12
+ "0.pre.3"
13
13
  end
14
14
  end
15
15
 
@@ -13,6 +13,14 @@ describe 'Mince Interface with DynamoDb' do
13
13
  Mince::Config.interface = MinceDynamoDb::Interface
14
14
  end
15
15
 
16
+ before(:all) do
17
+ # Create collection to use for test
18
+ end
19
+
20
+ after(:all) do
21
+ # Remove collection to use for test
22
+ end
23
+
16
24
  it_behaves_like 'a mince interface'
17
25
  end
18
26
  end
@@ -23,6 +23,40 @@ describe MinceDynamoDb::Interface do
23
23
  MinceDynamoDb::DataSanitizer.stub(:prepare_hash_for_storage).with(data).and_return(sanitized_data)
24
24
  end
25
25
 
26
+ it 'can create a collection' do
27
+ collections.should_receive(:create).with(collection_name, 10, 5)
28
+ described_class.create_collection(collection_name)
29
+
30
+ collections.should_receive(:create).with(collection_name, 100, 50)
31
+ described_class.create_collection(collection_name, 100, 50)
32
+ end
33
+
34
+ it 'can update a field with a value' do
35
+ primary_key_value = mock("id of record")
36
+ field_name = mock 'field name'
37
+ new_value = mock 'new value'
38
+ items.stub(:where).with(described_class.primary_key_identifier.to_s => primary_key_value).and_return([return_data])
39
+
40
+ attributes.should_receive(:set).with(field_name => new_value)
41
+
42
+ described_class.update_field_with_value(collection_name, primary_key_value, field_name, new_value)
43
+ end
44
+
45
+ it 'can delete a field from a collection' do
46
+ pending
47
+ primary_key_value = mock("id of record")
48
+ field_name = mock 'field name'
49
+ new_value = mock 'new value'
50
+ items.stub(:where).with(described_class.primary_key_identifier.to_s => primary_key_value).and_return([return_data])
51
+
52
+ attributes.should_receive(:set).with(field_name => new_value)
53
+
54
+ described_class.delete_field(collection_name, field_name)
55
+ end
56
+
57
+ it 'can delete a collection'
58
+ it 'can increment a field by a specific amount'
59
+
26
60
  describe "Generating a primary key" do
27
61
  let(:unique_id) { '123456789012345' }
28
62
  let(:time) { mock 'time' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mince_dynamo_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.2
4
+ version: 2.0.0.pre.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: -471291814637283281
176
+ hash: -2546190668435705286
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements: