jedlik 0.0.5 → 0.1.0
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/README.mkd +6 -0
- data/jedlik.gemspec +1 -1
- data/lib/jedlik/connection.rb +8 -1
- data/spec/jedlik/connection_spec.rb +30 -10
- metadata +2 -2
data/README.mkd
CHANGED
@@ -24,6 +24,12 @@ request body.
|
|
24
24
|
conn.post :GetItem, {:TableName => "table1", :Key => {:S => "foo"}}
|
25
25
|
# => Hash
|
26
26
|
|
27
|
+
It is also possible to pass a string that will be used directly for the
|
28
|
+
request body:
|
29
|
+
|
30
|
+
conn.post :GetItem, '{"TableName": "table1", "Key": {"S": "foo"}}'
|
31
|
+
# => Hash
|
32
|
+
|
27
33
|
License
|
28
34
|
-------
|
29
35
|
|
data/jedlik.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'jedlik'
|
5
|
-
s.version = '0.0
|
5
|
+
s.version = '0.1.0'
|
6
6
|
s.summary = "Communicate with Amazon DynamoDB."
|
7
7
|
s.description = "Communicate with Amazon DynamoDB. Raw access to the full API without having to handle temporary credentials or HTTP requests by yourself."
|
8
8
|
s.authors = ["Hashmal", "Brandon Keene"]
|
data/lib/jedlik/connection.rb
CHANGED
@@ -31,7 +31,14 @@ module Jedlik
|
|
31
31
|
# http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide
|
32
32
|
#
|
33
33
|
def post operation, data={}
|
34
|
-
|
34
|
+
body = case data
|
35
|
+
when String
|
36
|
+
body = data
|
37
|
+
else
|
38
|
+
Yajl::Encoder.encode(data)
|
39
|
+
end
|
40
|
+
|
41
|
+
request = new_request operation, body
|
35
42
|
request.sign sts
|
36
43
|
hydra.queue request
|
37
44
|
hydra.run
|
@@ -3,17 +3,25 @@ require 'benchmark'
|
|
3
3
|
|
4
4
|
describe Jedlik::Connection do
|
5
5
|
describe "#post" do
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
it "signs and posts a request" do
|
11
|
-
mock_service = mock(Jedlik::SecurityTokenService,
|
6
|
+
let(:mock_service) {
|
7
|
+
mock(Jedlik::SecurityTokenService,
|
12
8
|
:session_token => "session_token",
|
13
9
|
:access_key_id => "access_key_id",
|
14
10
|
:secret_access_key => "secret_access_key"
|
15
11
|
)
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:connection) {
|
15
|
+
Jedlik::Connection.new("key_id", "secret")
|
16
|
+
}
|
17
|
+
|
18
|
+
before do
|
19
|
+
Time.stub!(:now).and_return(Time.at(1332635893)) # Sat Mar 24 20:38:13 -0400 2012
|
20
|
+
|
21
|
+
Jedlik::SecurityTokenService.stub!(:new).and_return(mock_service)
|
22
|
+
end
|
16
23
|
|
24
|
+
it "signs and posts a request" do
|
17
25
|
stub_request(:post, "https://dynamodb.us-east-1.amazonaws.com/").
|
18
26
|
with(
|
19
27
|
:body => "{}",
|
@@ -27,15 +35,27 @@ describe Jedlik::Connection do
|
|
27
35
|
}
|
28
36
|
).
|
29
37
|
to_return(
|
30
|
-
:status
|
31
|
-
:body
|
38
|
+
:status => 200,
|
39
|
+
:body => '{"TableNames":["example"]}',
|
32
40
|
:headers => {}
|
33
41
|
)
|
34
42
|
|
35
|
-
Jedlik::SecurityTokenService.stub!(:new).and_return(mock_service)
|
36
|
-
connection = Jedlik::Connection.new("key_id", "secret")
|
37
43
|
result = connection.post :ListTables
|
38
44
|
result.should == {"TableNames" => ["example"]}
|
39
45
|
end
|
46
|
+
|
47
|
+
it "converts a hash to JSON" do
|
48
|
+
stub_request(:post, "https://dynamodb.us-east-1.amazonaws.com/").
|
49
|
+
with(:body => %({"foo":"bar"}))
|
50
|
+
|
51
|
+
connection.post :Query, {:foo => "bar"}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sends a string as it is" do
|
55
|
+
stub_request(:post, "https://dynamodb.us-east-1.amazonaws.com/").
|
56
|
+
with(:body => %(hello world))
|
57
|
+
|
58
|
+
connection.post :Query, "hello world"
|
59
|
+
end
|
40
60
|
end
|
41
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jedlik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-29 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: typhoeus
|