hungryblank-dead_simple_db 0.0.1 → 0.0.2
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.
- data/VERSION.yml +1 -1
- data/lib/dead_simple_db/dead_simple_db.rb +13 -8
- data/test/dead_simple_db_test.rb +5 -5
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -59,7 +59,8 @@ module DeadSimpleDb
|
|
59
59
|
#please note the query syntax is SimpleDB custom syntax, refer to SimpleDB docs for details
|
60
60
|
#
|
61
61
|
def find(how_many, query, opts={})
|
62
|
-
results =
|
62
|
+
results, token = service.query_with_attributes(@domain, query, parse_limit(how_many))
|
63
|
+
results.map! { |hash| new(hash) }
|
63
64
|
return results.first if how_many == :first
|
64
65
|
results
|
65
66
|
end
|
@@ -68,13 +69,8 @@ module DeadSimpleDb
|
|
68
69
|
#the object ids satisfyng the query
|
69
70
|
#
|
70
71
|
def find_ids(how_many, query, opts={})
|
71
|
-
|
72
|
-
|
73
|
-
when :first : 1
|
74
|
-
else
|
75
|
-
how_many
|
76
|
-
end
|
77
|
-
service.query(@domain, query, limit).first
|
72
|
+
ids, token = service.query(@domain, query, parse_limit(how_many))
|
73
|
+
ids
|
78
74
|
end
|
79
75
|
|
80
76
|
def attr_definitions
|
@@ -93,6 +89,15 @@ module DeadSimpleDb
|
|
93
89
|
attr_definitions << AttributeDefinition.new(name, klass, opts)
|
94
90
|
end
|
95
91
|
|
92
|
+
def parse_limit(how_many)
|
93
|
+
limit = case how_many
|
94
|
+
when :all : nil
|
95
|
+
when :first : 1
|
96
|
+
else
|
97
|
+
how_many
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
96
101
|
end
|
97
102
|
|
98
103
|
#Instantiates a new object passing an hash
|
data/test/dead_simple_db_test.rb
CHANGED
@@ -52,14 +52,14 @@ class DeadSimpleDbTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
should "issue a query when finding ids" do
|
55
|
-
@service.expects(:query).with('test_domain', "['name' = 'Arturo']", nil).returns(['e34979d4dc7b5b949fa67916acb63743'])
|
55
|
+
@service.expects(:query).with('test_domain', "['name' = 'Arturo']", nil).returns([['e34979d4dc7b5b949fa67916acb63743'], ''])
|
56
56
|
Employee.find_ids(:all, "['name' = 'Arturo']")
|
57
57
|
end
|
58
58
|
|
59
|
-
should "
|
60
|
-
|
61
|
-
Employee.
|
62
|
-
|
59
|
+
should "issue a query with attributes when finding" do
|
60
|
+
@service.expects(:query_with_attributes).with('test_domain', "['name' = 'Arturo']", nil).returns([[{'name' => 'Arturo'}], ''])
|
61
|
+
results = Employee.find(:all, "['name' = 'Arturo']")
|
62
|
+
assert_equal 'Arturo', results.first.name
|
63
63
|
end
|
64
64
|
|
65
65
|
should "instantiate an attribute definition when sdb_attr is called" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hungryblank-dead_simple_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Negri
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 0.4.0
|
23
23
|
version:
|
24
24
|
description: TODO
|
25
25
|
email: hungryblank@gmail.com
|