dynamo_record 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5a7aacd7cf741404335e060193dca054ef994ba
4
- data.tar.gz: d4306cda8f6a72a196057d69879f723802d82436
3
+ metadata.gz: e118c8930837cde9e813d2c8aac61a5a791fd3c3
4
+ data.tar.gz: db7f2acda4ebebdc38e4b997d09dc83776005bb2
5
5
  SHA512:
6
- metadata.gz: 5603c12d1de45c7383077d3fe754f4902c59dfdfc5f5ad4dd8585779d76eec11368687e4756bf5ebf7e5b83e883dab672de701995c8fc2051d55e2c72bb93bcf
7
- data.tar.gz: f3b789c3431436630d0cfd3624ccc67e0fd4967537588af83d0ae415aa182bf6537af2061c20a193a87d79b47ac0633649f7f9fc56a5bdfed58b696e7ccc943f
6
+ metadata.gz: 585180c10b7d731fee3a3696c58316e7662873d48ce863a36d48cc61e050ff4356a520f32f5daa173e16ea79a2d9353fa290a0f9d94e143831d5d6c25c376eea
7
+ data.tar.gz: 3e9ecba3d1382a08f5869bac120bfece4668c8e55fef4952097274742338ba7c68c597a3347a0a908b5b30346a044b3991690a1051bf443f4a1a066dfb84d06f
@@ -7,7 +7,7 @@ module DynamoRecord
7
7
 
8
8
  self.attributes = {}
9
9
 
10
- field :id, :string # default primary key
10
+ field :id, :string # default hash key
11
11
  end
12
12
 
13
13
  module ClassMethods
@@ -69,6 +69,29 @@ module DynamoRecord
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ # def hash_key
74
+ # @hash_key ||= self.attributes.select { |k,v| v[:options][:hash_key] }.keys.first rescue nil
75
+ # end
76
+
77
+ def range_key
78
+ @range_key ||= self.attributes.select { |k,v| v[:options][:range_key] }.keys.first rescue nil
79
+ end
80
+
81
+ def secondary_indexes
82
+ @secondary_indexes ||= self.attributes.select { |k,v| v[:options][:index] }.keys rescue nil
83
+ end
84
+
85
+ def dynamodb_type(type)
86
+ case type
87
+ when :integer, :float
88
+ 'N'
89
+ when :string, :datetime
90
+ 'S'
91
+ # else
92
+ # 'S'
93
+ end
94
+ end
72
95
  end
73
96
 
74
97
  def write_attribute(name, value)
@@ -21,48 +21,60 @@ module DynamoRecord
21
21
  { table_name: self.table_name }
22
22
  end
23
23
 
24
+ def describe_table
25
+ self.client.describe_table(default_options)
26
+ end
27
+
24
28
  def create_table(opts = {})
25
29
  table_name = opts[:table_name] || self.table_name
26
30
  read_capacity = opts[:read_capacity] || DynamoRecord::Config.read_capacity_units
27
31
  write_capacity = opts[:write_capacity] || DynamoRecord::Config.write_capacity_units
28
32
 
29
- # Default id
30
- attribute_definitions = [{attribute_name: "id", attribute_type: "S"}]
33
+ attribute_definitions = []
34
+ key_schema = []
35
+
36
+ # Default id hash key
37
+ attribute_definitions << {attribute_name: 'id',
38
+ attribute_type: 'S'}
39
+ key_schema << {attribute_name: 'id',
40
+ key_type: "HASH"}
41
+
42
+ if range_key
43
+ attribute_definitions << {attribute_name: range_key.to_s,
44
+ attribute_type: dynamodb_type(attributes[range_key][:type])}
45
+ key_schema << {attribute_name: range_key.to_s,
46
+ key_type: "RANGE"}
47
+ end
31
48
 
32
- # Global indexes
49
+ # Local secondary indexes
33
50
  indexes = []
34
51
  attributes.each do |key, value|
35
52
  indexes << key if value[:options][:index]
36
53
  end
37
54
 
38
- global_secondary_indexes = []
55
+ local_secondary_indexes = []
39
56
  indexes.each do |index|
40
57
  index_definition = {}
41
58
  index_definition[:index_name] = "#{index}-index"
42
- index_definition[:key_schema] = [{ attribute_name: index, key_type: 'HASH' }]
59
+ index_definition[:key_schema] = [{ attribute_name: 'id', key_type: 'HASH' },
60
+ { attribute_name: index, key_type: 'RANGE' }]
43
61
  index_definition[:projection] = { projection_type: 'ALL'}
44
- index_definition[:provisioned_throughput] = { read_capacity_units: read_capacity, write_capacity_units: write_capacity }
45
- global_secondary_indexes << index_definition
62
+ local_secondary_indexes << index_definition
46
63
  attribute_definitions << {attribute_name: index.to_s,
47
- attribute_type: attributes[index][:type] == :string ? 'S' : 'N'} # only String and Number are supported. Not Binary
64
+ attribute_type: dynamodb_type(attributes[index][:type])}
48
65
  end
49
66
 
50
67
  options = {
51
68
  attribute_definitions: attribute_definitions,
52
69
  table_name: table_name,
53
- key_schema: [
54
- {
55
- attribute_name: "id",
56
- key_type: "HASH",
57
- },
58
- ],
70
+ key_schema: key_schema,
59
71
  provisioned_throughput: {
60
72
  read_capacity_units: read_capacity,
61
73
  write_capacity_units: write_capacity,
62
74
  }
63
75
  }
64
76
 
65
- options.merge!(global_secondary_indexes: global_secondary_indexes) unless global_secondary_indexes.empty?
77
+ options.merge!(local_secondary_indexes: local_secondary_indexes) unless local_secondary_indexes.empty?
66
78
 
67
79
  response = self.client.create_table(options)
68
80
  end
@@ -1,3 +1,3 @@
1
1
  module DynamoRecord
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -19,17 +19,6 @@ RSpec.describe DynamoRecord::Fields do
19
19
  last_name: {type: :string, options: {}}})
20
20
  end
21
21
 
22
- it 'accepts adding fields with index' do
23
- class City
24
- include DynamoRecord::Document
25
-
26
- field :name, :string, index: true
27
- end
28
-
29
- expect(City.attributes).to eq({id: {type: :string, options: {}},
30
- name: {type: :string, options: {index: true}}})
31
- end
32
-
33
22
  it 'accepts default value' do
34
23
  class City
35
24
  include DynamoRecord::Document
@@ -90,4 +79,29 @@ RSpec.describe DynamoRecord::Fields do
90
79
  expect(person.activated).to eq(true)
91
80
  end
92
81
  end
82
+
83
+ describe 'keys' do
84
+ it 'returns table\'s range key' do
85
+ class ThreadKey
86
+ include DynamoRecord::Document
87
+
88
+ field :subject, :string, range_key: true
89
+ end
90
+
91
+ expect(ThreadKey.range_key).to eq(:subject)
92
+ end
93
+ end
94
+
95
+ describe 'index' do
96
+ it 'returns table\'s secondary index' do
97
+ class ThreadKey
98
+ include DynamoRecord::Document
99
+
100
+ field :name, :string, hash_key: true
101
+ field :subject, :string, index: true
102
+ end
103
+
104
+ expect(ThreadKey.secondary_indexes).to eq([:subject])
105
+ end
106
+ end
93
107
  end
@@ -23,27 +23,51 @@ RSpec.describe DynamoRecord::Persistence, :vcr do
23
23
  end
24
24
 
25
25
  describe '#create_table' do
26
- context 'with index' do
27
- it 'creates table' do
28
- class IndexCity
26
+
27
+ context 'with default hash key' do
28
+ it 'creates table' do
29
+ class Thread
29
30
  include DynamoRecord::Document
30
31
 
31
- field :name, :string, index: true
32
+ field :subject, :string
32
33
  end
33
34
 
34
- IndexCity.create_table
35
+ Thread.create_table
36
+ key_schema = Thread.describe_table.table.key_schema.first
37
+ expect(key_schema.attribute_name).to eq('id')
38
+ expect(key_schema.key_type).to eq('HASH')
35
39
  end
36
40
  end
37
41
 
38
- context 'without index' do
42
+ context 'with range key' do
39
43
  it 'creates table' do
40
- class NoIndexCity
44
+ class ThreadRange
45
+ include DynamoRecord::Document
46
+
47
+ field :subject, :string, range_key: true
48
+ end
49
+
50
+ ThreadRange.create_table
51
+ key_schema = ThreadRange.describe_table.table.key_schema
52
+ expect(key_schema.first.attribute_name).to eq('id')
53
+ expect(key_schema.first.key_type).to eq('HASH')
54
+ expect(key_schema.second.attribute_name).to eq('subject')
55
+ expect(key_schema.second.key_type).to eq('RANGE')
56
+ end
57
+ end
58
+
59
+ context 'with index' do
60
+ it 'creates table' do
61
+ class ThreadIndex
41
62
  include DynamoRecord::Document
42
63
 
43
- field :name, :string
64
+ field :subject, :string, range_key: true
65
+ field :created_at, :datetime, index: true
44
66
  end
45
67
 
46
- NoIndexCity.create_table
68
+ ThreadIndex.create_table
69
+ index = ThreadIndex.describe_table.table.local_secondary_indexes.first
70
+ expect(index.index_name).to eq('created_at-index')
47
71
  end
48
72
  end
49
73
  end
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://dynamodb.us-east-1.amazonaws.com/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"TableName":"threads","KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20}}'
9
+ headers:
10
+ Content-Type:
11
+ - application/x-amz-json-1.0
12
+ Accept-Encoding:
13
+ - ''
14
+ User-Agent:
15
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
16
+ X-Amz-Target:
17
+ - DynamoDB_20120810.CreateTable
18
+ X-Amz-Date:
19
+ - 20150124T111418Z
20
+ Host:
21
+ - dynamodb.us-east-1.amazonaws.com
22
+ X-Amz-Content-Sha256:
23
+ - 0bf704b7d071252f685fe1ce9e08be1311c1535edb5bda3efed826fb06949419
24
+ Authorization:
25
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
26
+ SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
27
+ Signature=be559252fddfd54c11c62bb6188458b8963e0b8540912edabdd68571e5794b63
28
+ Content-Length:
29
+ - '218'
30
+ Accept:
31
+ - "*/*"
32
+ response:
33
+ status:
34
+ code: 200
35
+ message: OK
36
+ headers:
37
+ X-Amzn-Requestid:
38
+ - BVQ209B5P481EI2F7K6GSCQLSNVV4KQNSO5AEMVJF66Q9ASUAAJG
39
+ X-Amz-Crc32:
40
+ - '1561182549'
41
+ Content-Type:
42
+ - application/x-amz-json-1.0
43
+ Content-Length:
44
+ - '360'
45
+ Date:
46
+ - Sat, 24 Jan 2015 11:14:20 GMT
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"CreationDateTime":1.422098061332E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"threads","TableSizeBytes":0,"TableStatus":"CREATING"}}'
50
+ http_version:
51
+ recorded_at: Sat, 24 Jan 2015 11:14:20 GMT
52
+ - request:
53
+ method: post
54
+ uri: https://dynamodb.us-east-1.amazonaws.com/
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"TableName":"threads"}'
58
+ headers:
59
+ Content-Type:
60
+ - application/x-amz-json-1.0
61
+ Accept-Encoding:
62
+ - ''
63
+ User-Agent:
64
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.DescribeTable
67
+ X-Amz-Date:
68
+ - 20150124T111420Z
69
+ Host:
70
+ - dynamodb.us-east-1.amazonaws.com
71
+ X-Amz-Content-Sha256:
72
+ - 4741f2f58966ebef8de1e20fd90fde3a27d8376bcb610777773e35ade0f320cc
73
+ Authorization:
74
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
75
+ SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
76
+ Signature=7af925efe27fcb9ac1b10a82901cd2cc61d0b387465be9afee56069b36001ced
77
+ Content-Length:
78
+ - '23'
79
+ Accept:
80
+ - "*/*"
81
+ response:
82
+ status:
83
+ code: 200
84
+ message: OK
85
+ headers:
86
+ X-Amzn-Requestid:
87
+ - 1HG6QUTAQ7789RO3TPJO0BF98RVV4KQNSO5AEMVJF66Q9ASUAAJG
88
+ X-Amz-Crc32:
89
+ - '3334465804'
90
+ Content-Type:
91
+ - application/x-amz-json-1.0
92
+ Content-Length:
93
+ - '349'
94
+ Date:
95
+ - Sat, 24 Jan 2015 11:14:23 GMT
96
+ body:
97
+ encoding: UTF-8
98
+ string: '{"Table":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"CreationDateTime":1.422098061332E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"threads","TableSizeBytes":0,"TableStatus":"CREATING"}}'
99
+ http_version:
100
+ recorded_at: Sat, 24 Jan 2015 11:14:22 GMT
101
+ recorded_with: VCR 2.9.3
@@ -5,28 +5,28 @@ http_interactions:
5
5
  uri: https://dynamodb.us-east-1.amazonaws.com/
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"name","AttributeType":"S"}],"TableName":"index_cities","KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20},"GlobalSecondaryIndexes":[{"IndexName":"name-index","KeySchema":[{"AttributeName":"name","KeyType":"HASH"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20}}]}'
8
+ string: '{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"},{"AttributeName":"created_at","AttributeType":"S"}],"TableName":"thread_indices","KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20},"LocalSecondaryIndexes":[{"IndexName":"created_at-index","KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"created_at","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"}}]}'
9
9
  headers:
10
10
  Content-Type:
11
11
  - application/x-amz-json-1.0
12
12
  Accept-Encoding:
13
13
  - ''
14
14
  User-Agent:
15
- - aws-sdk-ruby2/2.0.17 ruby/2.1.2 x86_64-darwin14.0
15
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
16
16
  X-Amz-Target:
17
17
  - DynamoDB_20120810.CreateTable
18
18
  X-Amz-Date:
19
- - 20150101T055839Z
19
+ - 20150124T110934Z
20
20
  Host:
21
21
  - dynamodb.us-east-1.amazonaws.com
22
22
  X-Amz-Content-Sha256:
23
- - f367f93ea8d0dac13defca67311f4b956a18992bd453cadbd9718bb27e92a2f5
23
+ - 907908fb9e5f171267453ab9a0a1b7013694a5ac6dbe61cb2239331994acfbef
24
24
  Authorization:
25
- - AWS4-HMAC-SHA256 Credential=key/20150101/us-east-1/dynamodb/aws4_request,
25
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
26
26
  SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
27
- Signature=7a357b3cb933ddd629ea46417ee9467ff7148fcddd0531e29da515129d7093f8
27
+ Signature=3bfe9ecfccf778d7e288c9b6aab32b8c113e7f80d2781363b29775d6b8339960
28
28
  Content-Length:
29
- - '489'
29
+ - '570'
30
30
  Accept:
31
31
  - "*/*"
32
32
  response:
@@ -35,18 +35,67 @@ http_interactions:
35
35
  message: OK
36
36
  headers:
37
37
  X-Amzn-Requestid:
38
- - 1Q754MSUVVF6GECIADT5DRIPIVVV4KQNSO5AEMVJF66Q9ASUAAJG
38
+ - Q652I5VS2FGID189QR40DFF8LBVV4KQNSO5AEMVJF66Q9ASUAAJG
39
39
  X-Amz-Crc32:
40
- - '634016743'
40
+ - '3601382926'
41
41
  Content-Type:
42
42
  - application/x-amz-json-1.0
43
43
  Content-Length:
44
- - '716'
44
+ - '745'
45
45
  Date:
46
- - Thu, 01 Jan 2015 05:58:40 GMT
46
+ - Sat, 24 Jan 2015 11:09:38 GMT
47
47
  body:
48
48
  encoding: UTF-8
49
- string: '{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"name","AttributeType":"S"}],"CreationDateTime":1.420091921193E9,"GlobalSecondaryIndexes":[{"IndexName":"name-index","IndexSizeBytes":0,"IndexStatus":"CREATING","ItemCount":0,"KeySchema":[{"AttributeName":"name","KeyType":"HASH"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20}}],"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"index_cities","TableSizeBytes":0,"TableStatus":"CREATING"}}'
49
+ string: '{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"created_at","AttributeType":"S"},{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"}],"CreationDateTime":1.422097779164E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"LocalSecondaryIndexes":[{"IndexName":"created_at-index","IndexSizeBytes":0,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"created_at","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"}}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"thread_indices","TableSizeBytes":0,"TableStatus":"CREATING"}}'
50
50
  http_version:
51
- recorded_at: Thu, 01 Jan 2015 05:58:41 GMT
51
+ recorded_at: Sat, 24 Jan 2015 11:09:37 GMT
52
+ - request:
53
+ method: post
54
+ uri: https://dynamodb.us-east-1.amazonaws.com/
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"TableName":"thread_indices"}'
58
+ headers:
59
+ Content-Type:
60
+ - application/x-amz-json-1.0
61
+ Accept-Encoding:
62
+ - ''
63
+ User-Agent:
64
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.DescribeTable
67
+ X-Amz-Date:
68
+ - 20150124T110937Z
69
+ Host:
70
+ - dynamodb.us-east-1.amazonaws.com
71
+ X-Amz-Content-Sha256:
72
+ - a8f8f93d93e861a00ac6994f621264e471cee884ceb7b3786ec48f8cb99ac8d2
73
+ Authorization:
74
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
75
+ SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
76
+ Signature=e8be543a657bfbbc3f04fff5b486260ff4030b67439726ccb13d53fa315742a1
77
+ Content-Length:
78
+ - '30'
79
+ Accept:
80
+ - "*/*"
81
+ response:
82
+ status:
83
+ code: 200
84
+ message: OK
85
+ headers:
86
+ X-Amzn-Requestid:
87
+ - MALSOL31HA99VF0NG5EURHVSGNVV4KQNSO5AEMVJF66Q9ASUAAJG
88
+ X-Amz-Crc32:
89
+ - '1602081351'
90
+ Content-Type:
91
+ - application/x-amz-json-1.0
92
+ Content-Length:
93
+ - '734'
94
+ Date:
95
+ - Sat, 24 Jan 2015 11:09:39 GMT
96
+ body:
97
+ encoding: UTF-8
98
+ string: '{"Table":{"AttributeDefinitions":[{"AttributeName":"created_at","AttributeType":"S"},{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"}],"CreationDateTime":1.422097779164E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"LocalSecondaryIndexes":[{"IndexName":"created_at-index","IndexSizeBytes":0,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"created_at","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"}}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"thread_indices","TableSizeBytes":0,"TableStatus":"CREATING"}}'
99
+ http_version:
100
+ recorded_at: Sat, 24 Jan 2015 11:09:38 GMT
52
101
  recorded_with: VCR 2.9.3
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://dynamodb.us-east-1.amazonaws.com/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"}],"TableName":"thread_ranges","KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20}}'
9
+ headers:
10
+ Content-Type:
11
+ - application/x-amz-json-1.0
12
+ Accept-Encoding:
13
+ - ''
14
+ User-Agent:
15
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
16
+ X-Amz-Target:
17
+ - DynamoDB_20120810.CreateTable
18
+ X-Amz-Date:
19
+ - 20150124T110904Z
20
+ Host:
21
+ - dynamodb.us-east-1.amazonaws.com
22
+ X-Amz-Content-Sha256:
23
+ - 1549ae65e389bdb2885dbee28862b9229af7db3eead7fd794796a2b263bc3ea3
24
+ Authorization:
25
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
26
+ SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
27
+ Signature=028bd3f2ef91e502f167a415af319492144ce2c2c149255b8148c26eca97a757
28
+ Content-Length:
29
+ - '318'
30
+ Accept:
31
+ - "*/*"
32
+ response:
33
+ status:
34
+ code: 200
35
+ message: OK
36
+ headers:
37
+ X-Amzn-Requestid:
38
+ - 3ITDF8KQQS7D7R4TST6LO2ICSFVV4KQNSO5AEMVJF66Q9ASUAAJG
39
+ X-Amz-Crc32:
40
+ - '1190710576'
41
+ Content-Type:
42
+ - application/x-amz-json-1.0
43
+ Content-Length:
44
+ - '459'
45
+ Date:
46
+ - Sat, 24 Jan 2015 11:09:07 GMT
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"}],"CreationDateTime":1.42209774725E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"thread_ranges","TableSizeBytes":0,"TableStatus":"CREATING"}}'
50
+ http_version:
51
+ recorded_at: Sat, 24 Jan 2015 11:09:05 GMT
52
+ - request:
53
+ method: post
54
+ uri: https://dynamodb.us-east-1.amazonaws.com/
55
+ body:
56
+ encoding: UTF-8
57
+ string: '{"TableName":"thread_ranges"}'
58
+ headers:
59
+ Content-Type:
60
+ - application/x-amz-json-1.0
61
+ Accept-Encoding:
62
+ - ''
63
+ User-Agent:
64
+ - aws-sdk-ruby2/2.0.19 ruby/2.1.2 x86_64-darwin14.0
65
+ X-Amz-Target:
66
+ - DynamoDB_20120810.DescribeTable
67
+ X-Amz-Date:
68
+ - 20150124T110905Z
69
+ Host:
70
+ - dynamodb.us-east-1.amazonaws.com
71
+ X-Amz-Content-Sha256:
72
+ - 4205c006ddf44314b65f600c08e297dfcf966854b81659a488578473f953e7a2
73
+ Authorization:
74
+ - AWS4-HMAC-SHA256 Credential=key/20150124/us-east-1/dynamodb/aws4_request,
75
+ SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
76
+ Signature=d0dd05bd306a67b0e95ea329f5e83a4b0150a092ad688e2c052e11db334947a1
77
+ Content-Length:
78
+ - '29'
79
+ Accept:
80
+ - "*/*"
81
+ response:
82
+ status:
83
+ code: 200
84
+ message: OK
85
+ headers:
86
+ X-Amzn-Requestid:
87
+ - QIJL6QE6KFUO8E3R662E26MCJJVV4KQNSO5AEMVJF66Q9ASUAAJG
88
+ X-Amz-Crc32:
89
+ - '4070158827'
90
+ Content-Type:
91
+ - application/x-amz-json-1.0
92
+ Content-Length:
93
+ - '448'
94
+ Date:
95
+ - Sat, 24 Jan 2015 11:09:07 GMT
96
+ body:
97
+ encoding: UTF-8
98
+ string: '{"Table":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"},{"AttributeName":"subject","AttributeType":"S"}],"CreationDateTime":1.42209774725E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"},{"AttributeName":"subject","KeyType":"RANGE"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"thread_ranges","TableSizeBytes":0,"TableStatus":"CREATING"}}'
99
+ http_version:
100
+ recorded_at: Sat, 24 Jan 2015 11:09:06 GMT
101
+ recorded_with: VCR 2.9.3
data/spec/spec_helper.rb CHANGED
@@ -15,4 +15,9 @@ end
15
15
  DynamoRecord.configure do |config|
16
16
  config.access_key_id = 'key'
17
17
  config.secret_access_key = 'secret'
18
- end
18
+ end
19
+
20
+ # DynamoRecord.configure do |config|
21
+ # config.access_key_id = 'AKIAI6M4LBRLK4COUJ5Q'
22
+ # config.secret_access_key = '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'
23
+ # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamo_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nguyen Vu Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,8 +143,9 @@ files:
143
143
  - spec/fixtures/vcr_cassettes/DynamoRecord_Document/initializes_from_database.yml
144
144
  - spec/fixtures/vcr_cassettes/DynamoRecord_Fields/_find/finds_record.yml
145
145
  - spec/fixtures/vcr_cassettes/DynamoRecord_Fields/_find/when_record_doesn_t_exists/returns_empty_object.yml
146
+ - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_default_hash_key/creates_table.yml
146
147
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_index/creates_table.yml
147
- - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/without_index/creates_table.yml
148
+ - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_range_key/creates_table.yml
148
149
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/creates_record.yml
149
150
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/destroys_record.yml
150
151
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/does_not_overwrite_existing_record.yml
@@ -198,8 +199,9 @@ test_files:
198
199
  - spec/fixtures/vcr_cassettes/DynamoRecord_Document/initializes_from_database.yml
199
200
  - spec/fixtures/vcr_cassettes/DynamoRecord_Fields/_find/finds_record.yml
200
201
  - spec/fixtures/vcr_cassettes/DynamoRecord_Fields/_find/when_record_doesn_t_exists/returns_empty_object.yml
202
+ - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_default_hash_key/creates_table.yml
201
203
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_index/creates_table.yml
202
- - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/without_index/creates_table.yml
204
+ - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/_create_table/with_range_key/creates_table.yml
203
205
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/creates_record.yml
204
206
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/destroys_record.yml
205
207
  - spec/fixtures/vcr_cassettes/DynamoRecord_Persistence/does_not_overwrite_existing_record.yml
@@ -1,52 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://dynamodb.us-east-1.amazonaws.com/
6
- body:
7
- encoding: UTF-8
8
- string: '{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"TableName":"no_index_cities","KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"ReadCapacityUnits":20,"WriteCapacityUnits":20}}'
9
- headers:
10
- Content-Type:
11
- - application/x-amz-json-1.0
12
- Accept-Encoding:
13
- - ''
14
- User-Agent:
15
- - aws-sdk-ruby2/2.0.17 ruby/2.1.2 x86_64-darwin14.0
16
- X-Amz-Target:
17
- - DynamoDB_20120810.CreateTable
18
- X-Amz-Date:
19
- - 20150101T060008Z
20
- Host:
21
- - dynamodb.us-east-1.amazonaws.com
22
- X-Amz-Content-Sha256:
23
- - 225d46451c9fb8f4aecddfa640ada2ca8495691e578a716b763de9eff1f40463
24
- Authorization:
25
- - AWS4-HMAC-SHA256 Credential=key/20150101/us-east-1/dynamodb/aws4_request,
26
- SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-target,
27
- Signature=c04fc9e73792f7f1f16eb7cee2256dfbd9960ec2657e24bd562309873684dec3
28
- Content-Length:
29
- - '226'
30
- Accept:
31
- - "*/*"
32
- response:
33
- status:
34
- code: 200
35
- message: OK
36
- headers:
37
- X-Amzn-Requestid:
38
- - B1670HTESRN0V50E27FLRALVQJVV4KQNSO5AEMVJF66Q9ASUAAJG
39
- X-Amz-Crc32:
40
- - '3984556825'
41
- Content-Type:
42
- - application/x-amz-json-1.0
43
- Content-Length:
44
- - '368'
45
- Date:
46
- - Thu, 01 Jan 2015 06:00:09 GMT
47
- body:
48
- encoding: UTF-8
49
- string: '{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"CreationDateTime":1.420092009548E9,"ItemCount":0,"KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":20,"WriteCapacityUnits":20},"TableName":"no_index_cities","TableSizeBytes":0,"TableStatus":"CREATING"}}'
50
- http_version:
51
- recorded_at: Thu, 01 Jan 2015 06:00:09 GMT
52
- recorded_with: VCR 2.9.3