ocean-dynamo 0.5.8 → 0.6.0

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: a22735c29c5d86fdee39e4df6a952453bc2005e2
4
- data.tar.gz: 975e59447cc5671db3daf7e80f58b2940dc64671
3
+ metadata.gz: a2c4edf837d81606bd36e398ac37902c46e46244
4
+ data.tar.gz: 6edba057816d06a0e065e2f532c5136cb2bcf6d5
5
5
  SHA512:
6
- metadata.gz: 6590b4b1aa5ba1810ec1835f95a38c2db30125f9a70cc89e87971dd7ebca789d6e0eded17c7e7e1588b7d006679ef8b14f12f30ae37371ba2ae2c2da4ff47ddf
7
- data.tar.gz: d1664e362cf1018638e037d34a618edad903aa9fccf3a2cf9c34f96d0255f67912a344237aa892a7a981e88d3d1ba5fd7ec5694e2e2558828300876100e7b739
6
+ metadata.gz: 58638ca486e8e02fedd8c0cb12987721626be0054173e0a86e834076e0c296a314b91a8dcc5088ea7ffdaf3eb5984f3fe31ef77d5c92fc92370cc72655f76500
7
+ data.tar.gz: b12f97133c8d592525601ecb043ab97540ba5efceade64af9e8f53ec85105f8f74fe63e74986ed9720994946b6778e01dd49b0f8ed3e8c406a41b5ba83744e54
@@ -171,11 +171,11 @@ module OceanDynamo
171
171
  return value.collect(&:to_s) if value.is_a?(Array)
172
172
  value
173
173
  when :integer
174
- return nil if value == nil
174
+ return nil if value == nil || value == false || value.is_a?(String) && value.blank?
175
175
  return value.collect(&:to_i) if value.is_a?(Array)
176
176
  value.to_i
177
177
  when :float
178
- return nil if value == nil
178
+ return nil if value == nil || value == false || value.is_a?(String) && value.blank?
179
179
  return value.collect(&:to_f) if value.is_a?(Array)
180
180
  value.to_f
181
181
  when :boolean
@@ -39,6 +39,7 @@ module OceanDynamo
39
39
 
40
40
 
41
41
  def delete_all
42
+ return nil unless dynamo_items
42
43
  dynamo_items.each() do |item|
43
44
  item.delete
44
45
  end
@@ -47,6 +48,7 @@ module OceanDynamo
47
48
 
48
49
 
49
50
  def destroy_all
51
+ return nil unless dynamo_items
50
52
  dynamo_items.select() do |item_data|
51
53
  new._setup_from_dynamo(item_data).destroy
52
54
  end
@@ -11,6 +11,7 @@ module OceanDynamo
11
11
  return hash.collect {|elem| find elem, range, consistent: consistent } if hash.is_a?(Array)
12
12
  _late_connect?
13
13
  hash = hash.id if hash.kind_of?(Table) # TODO: We have (innocuous) leakage, fix!
14
+ range = range.to_i if range.is_a?(Time)
14
15
  item = dynamo_items[hash, range]
15
16
  unless item.exists?
16
17
  raise RecordNotFound, "can't find a #{self} with primary key ['#{hash}', #{range.inspect}]"
@@ -89,7 +89,7 @@ module OceanDynamo
89
89
  dynamo_table.hash_key = [table_hash_key, hash_key_type]
90
90
 
91
91
  if table_range_key
92
- range_key_type = fields[table_range_key][:type]
92
+ range_key_type = generalise_range_key_type
93
93
  dynamo_table.range_key = [table_range_key, range_key_type]
94
94
  end
95
95
  end
@@ -98,8 +98,7 @@ module OceanDynamo
98
98
  def create_table
99
99
  hash_key_type = fields[table_hash_key][:type]
100
100
  hash_key_type = :string if hash_key_type == :reference
101
-
102
- range_key_type = table_range_key && fields[table_range_key][:type]
101
+ range_key_type = generalise_range_key_type
103
102
 
104
103
  self.dynamo_table = dynamo_client.tables.create(table_full_name,
105
104
  table_read_capacity_units, table_write_capacity_units,
@@ -112,6 +111,17 @@ module OceanDynamo
112
111
  end
113
112
 
114
113
 
114
+ def generalise_range_key_type
115
+ return false unless table_range_key
116
+ t = fields[table_range_key][:type]
117
+ return :string if t == :string
118
+ return :number if t == :integer
119
+ return :number if t == :float
120
+ return :number if t == :datetime
121
+ raise "Unsupported range key type: #{t}"
122
+ end
123
+
124
+
115
125
  def delete_table
116
126
  return false unless dynamo_table.exists? && dynamo_table.status == :active
117
127
  dynamo_table.delete
@@ -1,3 +1,3 @@
1
1
  module OceanDynamo
2
- VERSION = "0.5.8"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk