sdbtools 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sdbtools.rb +9 -4
- data/spec/operation_spec.rb +20 -0
- data/spec/spec_helper.rb +9 -0
- metadata +6 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/sdbtools.rb
CHANGED
@@ -2,17 +2,22 @@ require 'fattr'
|
|
2
2
|
require 'right_aws'
|
3
3
|
|
4
4
|
module SDBTools
|
5
|
+
|
6
|
+
# An Operation represents a SimpleDB operation and handles the details of
|
7
|
+
# re-requesting "next tokens" until the operation is complete.
|
5
8
|
class Operation
|
6
9
|
include Enumerable
|
7
10
|
|
8
11
|
def initialize(sdb, method, *args)
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
+
@options = args.last.is_a?(Hash) ? args.pop : {}
|
13
|
+
@sdb = sdb
|
14
|
+
@method = method
|
15
|
+
@args = args
|
12
16
|
end
|
13
17
|
|
18
|
+
# Yields once for each result set, until there is no next token.
|
14
19
|
def each
|
15
|
-
next_token =
|
20
|
+
next_token = @options[:starting_token]
|
16
21
|
begin
|
17
22
|
args = @args.dup
|
18
23
|
args << next_token
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module SDBTools
|
4
|
+
describe Operation do
|
5
|
+
before :each do
|
6
|
+
@sdb = stub("SDB")
|
7
|
+
end
|
8
|
+
|
9
|
+
context "given a starting next token" do
|
10
|
+
before :each do
|
11
|
+
@it = Operation.new(@sdb, :select, "ARG", :starting_token => "TOKEN")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should pass the token to the first call" do
|
15
|
+
@sdb.should_receive(:select).with("ARG", "TOKEN")
|
16
|
+
@it.each do break; end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdbtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Avdi Grimm
|
@@ -98,6 +98,8 @@ files:
|
|
98
98
|
- VERSION
|
99
99
|
- bin/sdbtool
|
100
100
|
- lib/sdbtools.rb
|
101
|
+
- spec/operation_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
101
103
|
has_rdoc: true
|
102
104
|
homepage: http://github.com/devver/sdbtools
|
103
105
|
licenses: []
|
@@ -126,5 +128,6 @@ rubygems_version: 1.3.5
|
|
126
128
|
signing_key:
|
127
129
|
specification_version: 3
|
128
130
|
summary: A high-level OO interface to Amazon SimpleDB
|
129
|
-
test_files:
|
130
|
-
|
131
|
+
test_files:
|
132
|
+
- spec/operation_spec.rb
|
133
|
+
- spec/spec_helper.rb
|