dynameek 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynameek (0.3.7)
4
+ dynameek (0.3.8)
5
5
  aws-sdk
6
6
 
7
7
  GEM
@@ -14,32 +14,41 @@ module Dynameek
14
14
  memo
15
15
  end
16
16
  self.class.before_save_callbacks.each{|method| self.send method}
17
+ #puts "---------\nDYNAMEEK DEBUG [SAVE]:"
17
18
  if self.class.index_table?
18
19
  rng = self.class.convert_to_dynamodb(
19
20
  self.class.range_info.type,
20
21
  attributes[self.class.range_info.field]
21
22
  )
22
23
  curr_range = self.class.current_range(hash_key, rng) + 1
24
+ index_attribs = {
25
+ self.class.hash_key_info.field.to_s =>attribs[self.class.hash_key_info.field],
26
+ self.class.range_info.field.to_s => attribs[self.class.range_info.field],
27
+ "current_range_val"=> curr_range
28
+ }
29
+ #puts "INDEX:"
30
+ #puts index_attribs
23
31
  self.class.index_table.batch_write(
24
32
  :put => [
25
- {
26
- self.class.hash_key_info.field => attribs[self.class.hash_key_info.field],
27
- self.class.range_info.field => attribs[self.class.range_info.field],
28
- current_range_val: curr_range
29
- }
33
+ index_attribs
30
34
  ]
31
35
  )
36
+ #puts "-!-"
32
37
  attribs[self.class.hash_key_info.field.to_s+"_"+self.class.range_info.field.to_s] =
33
38
  attribs[self.class.hash_key_info.field].to_s +
34
39
  self.class.multi_column_join +
35
40
  attribs[self.class.range_info.field].to_s
36
41
  attribs[:dynameek_index] = curr_range
42
+ #puts "DATA:"
43
+ #puts attribs
37
44
  self.class.table.batch_write(
38
45
  :put => [
39
46
  attribs
40
47
  ]
41
48
  )
42
49
  else
50
+ #puts "DATA:"
51
+ #puts attribs
43
52
  self.class.table.batch_write(
44
53
  :put => [
45
54
  attribs
@@ -12,8 +12,15 @@ module Dynameek
12
12
  value.to_s
13
13
  when :datetime
14
14
  Time.at(value).to_datetime
15
+ when :boolean
16
+ value.to_i == 1
15
17
  when :binary
16
- Marshal.load(value)
18
+ begin
19
+ Marshal.load(value)
20
+ rescue => e
21
+ puts "[WARNING] Failed to load value #{value}"
22
+
23
+ end
17
24
  else
18
25
  value
19
26
  end
@@ -26,6 +33,8 @@ module Dynameek
26
33
  when :binary
27
34
  dump_safe(value)
28
35
  Marshal.dump(value)
36
+ when :boolean
37
+ value ? 1 : 0
29
38
  else
30
39
  value
31
40
  end
@@ -116,6 +116,7 @@ module Dynameek
116
116
 
117
117
  def current_range(key, range_val)
118
118
  return nil if !index_table?
119
+ index_table.load_schema
119
120
  key.join!(multi_column_join) if key.is_a?(Array)
120
121
  item = index_table.items.query(
121
122
  {
@@ -125,6 +126,7 @@ module Dynameek
125
126
  }).first
126
127
  return 0 if item.nil?
127
128
  item_hsh = aws_item_to_hash(item)
129
+
128
130
  item_hsh['current_range_val'].to_i
129
131
  end
130
132
 
@@ -1,3 +1,3 @@
1
1
  module Dynameek
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -4,6 +4,7 @@ class Simple
4
4
 
5
5
  field :my_id, :integer
6
6
  field :some_value, :string
7
+ field :boolean_value, :boolean
7
8
  field :binary_value, :binary
8
9
 
9
10
  hash_key :my_id
@@ -9,6 +9,18 @@ describe Simple do
9
9
  simple.delete if(!simple.nil?)
10
10
  end
11
11
 
12
+ it "should allow you to store and retrieve boolean values" do
13
+ con = nil
14
+ lambda{
15
+ con = Simple.create(:my_id => 1, :some_value => "hello", :boolean_value => false)
16
+ }.should_not raise_error
17
+ con.hash_key.should == 1
18
+ con.boolean_value.should == false
19
+ con = Simple.find(1)
20
+ con.boolean_value.should == false
21
+ end
22
+
23
+
12
24
  it "should allow you to store binary data" do
13
25
  con = nil
14
26
  lambda{
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dynameek
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.8
5
+ version: 0.3.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Max Dupenois
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-05-03 00:00:00 Z
13
+ date: 2013-05-13 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk