raws 0.0.7
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/CHANGELOG +0 -0
- data/COPYING +18 -0
- data/README.rdoc +108 -0
- data/Rakefile +33 -0
- data/VERSION +1 -0
- data/lib/raws/s3/adapter.rb +123 -0
- data/lib/raws/s3.rb +21 -0
- data/lib/raws/sdb/adapter.rb +139 -0
- data/lib/raws/sdb/model.rb +121 -0
- data/lib/raws/sdb/select.rb +78 -0
- data/lib/raws/sdb.rb +119 -0
- data/lib/raws/sqs/adapter.rb +148 -0
- data/lib/raws/sqs.rb +158 -0
- data/lib/raws.rb +149 -0
- data/spec/raws/s3_spec.rb +28 -0
- data/spec/raws/sdb/model_spec.rb +43 -0
- data/spec/raws/sdb_spec.rb +364 -0
- data/spec/raws/sqs_spec.rb +168 -0
- data/spec/raws_spec.rb +75 -0
- metadata +101 -0
data/lib/raws/sdb.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
class RAWS::SDB
|
2
|
+
autoload :Adapter, 'raws/sdb/adapter'
|
3
|
+
autoload :Select, 'raws/sdb/select'
|
4
|
+
autoload :Model, 'raws/sdb/model'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def create_domain(domain_name)
|
8
|
+
Adapter.create_domain(domain_name)
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete_domain(domain_name)
|
12
|
+
Adapter.delete_domain(domain_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def metadata(domain_name)
|
16
|
+
Adapter.domain_metadata(
|
17
|
+
domain_name
|
18
|
+
)['DomainMetadataResponse']['DomainMetadataResult']
|
19
|
+
end
|
20
|
+
|
21
|
+
def list(next_token=nil, max_num=nil)
|
22
|
+
Adapter.list_domains(
|
23
|
+
next_token,
|
24
|
+
max_num
|
25
|
+
)['ListDomainsResponse']['ListDomainsResult']
|
26
|
+
end
|
27
|
+
|
28
|
+
def each(&block)
|
29
|
+
next_token = nil
|
30
|
+
begin
|
31
|
+
data = list(next_token)
|
32
|
+
if domain = data['DomainName']
|
33
|
+
domain.each do |val|
|
34
|
+
block.call(self.new(val))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end while next_token = data['NextToken']
|
38
|
+
end
|
39
|
+
|
40
|
+
def [](domain_name)
|
41
|
+
@cache ||= {}
|
42
|
+
@cache[domain_name] ||= self.new(domain_name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def select(expr, params=[], next_token=nil, &block)
|
46
|
+
begin
|
47
|
+
data = Adapter.select(
|
48
|
+
expr,
|
49
|
+
params,
|
50
|
+
next_token
|
51
|
+
)['SelectResponse']['SelectResult']
|
52
|
+
|
53
|
+
data['Item'].each do |val|
|
54
|
+
block.call([val['Name'], val['Attribute']])
|
55
|
+
end if data.key? 'Item'
|
56
|
+
end while next_token = data['NextToken']
|
57
|
+
end
|
58
|
+
alias :all :select
|
59
|
+
|
60
|
+
def get(domain_name, item_name, *attrs)
|
61
|
+
Adapter.get_attributes(
|
62
|
+
domain_name,
|
63
|
+
item_name,
|
64
|
+
*attrs
|
65
|
+
)['GetAttributesResponse']['GetAttributesResult']['Attribute']
|
66
|
+
end
|
67
|
+
|
68
|
+
def put(domain_name, item_name, attrs={}, *replaces)
|
69
|
+
Adapter.put_attributes(domain_name, item_name, attrs, *replaces)
|
70
|
+
end
|
71
|
+
|
72
|
+
def batch_put(domain_name, items={}, replaces={})
|
73
|
+
Adapter.batch_put_attributes(domain_name, items, replaces)
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete(domain_name, item_name, attrs={})
|
77
|
+
Adapter.delete_attributes(domain_name, item_name, attrs)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
attr_reader :domain_name
|
82
|
+
|
83
|
+
def initialize(domain_name)
|
84
|
+
@domain_name = domain_name
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_domain
|
88
|
+
self.class.create_domain(domain_name)
|
89
|
+
end
|
90
|
+
|
91
|
+
def delete_domain
|
92
|
+
self.class.delete_domain(domain_name)
|
93
|
+
end
|
94
|
+
|
95
|
+
def metadata
|
96
|
+
self.class.metadata(domain_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
def select(output_list='*', &block)
|
100
|
+
Select.new.columns(output_list).from(domain_name, &block)
|
101
|
+
end
|
102
|
+
alias :all :select
|
103
|
+
|
104
|
+
def get(item_name, *attrs)
|
105
|
+
self.class.get(domain_name, item_name, *attrs)
|
106
|
+
end
|
107
|
+
|
108
|
+
def put(item_name, attrs={}, *replaces)
|
109
|
+
self.class.put(domain_name, item_name, attrs, *replaces)
|
110
|
+
end
|
111
|
+
|
112
|
+
def batch_put(items={}, replaces={})
|
113
|
+
self.class.batch_put(domain_name, items, replaces)
|
114
|
+
end
|
115
|
+
|
116
|
+
def delete(item_name, attrs={})
|
117
|
+
self.class.delete(domain_name, item_name, attrs)
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
class RAWS::SQS::Adapter
|
2
|
+
module Adapter20090201
|
3
|
+
URI = 'https://queue.amazonaws.com/'
|
4
|
+
PARAMS = {'Version' => '2009-02-01'}
|
5
|
+
|
6
|
+
def create_queue(queue_name, timeout=nil)
|
7
|
+
params = {
|
8
|
+
'Action' => 'CreateQueue',
|
9
|
+
'QueueName' => queue_name
|
10
|
+
}
|
11
|
+
params['DefaultVisibilityTimeout'] = timeout if timeout
|
12
|
+
|
13
|
+
RAWS.fetch('GET', URI, PARAMS.merge(params))
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete_queue(queue_url)
|
17
|
+
params = {'Action' => 'DeleteQueue'}
|
18
|
+
|
19
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
20
|
+
end
|
21
|
+
|
22
|
+
def list_queues(prefix=nil)
|
23
|
+
params = {'Action' => 'ListQueues'}
|
24
|
+
params['QueueNamePrefix'] = prefix if prefix
|
25
|
+
|
26
|
+
RAWS.fetch('GET', URI, PARAMS.merge(params), 'QueueUrl')
|
27
|
+
end
|
28
|
+
|
29
|
+
def pack_attrs(attrs)
|
30
|
+
params = {}
|
31
|
+
|
32
|
+
if(attrs.size == 1)
|
33
|
+
params["AttributeName"] = attrs.first
|
34
|
+
else
|
35
|
+
i = 1
|
36
|
+
attrs.each do |val|
|
37
|
+
params["AttributeName.#{i}"] = val
|
38
|
+
i += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
params
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_queue_attributes(queue_url, *attrs)
|
46
|
+
params = {'Action' => 'GetQueueAttributes'}
|
47
|
+
if attrs.empty?
|
48
|
+
params.merge!(pack_attrs(['All']))
|
49
|
+
else
|
50
|
+
params.merge!(pack_attrs(attrs))
|
51
|
+
end
|
52
|
+
|
53
|
+
RAWS.fetch(
|
54
|
+
'GET',
|
55
|
+
queue_url,
|
56
|
+
PARAMS.merge(params),
|
57
|
+
:multiple => %w'Attribute',
|
58
|
+
:unpack => %w'Attribute'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_queue_attributes(queue_url, attrs={})
|
63
|
+
params = {'Action' => 'SetQueueAttributes'}
|
64
|
+
params.merge!(RAWS.pack_attrs(attrs))
|
65
|
+
|
66
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
67
|
+
end
|
68
|
+
|
69
|
+
def send_message(queue_url, msg)
|
70
|
+
params = {
|
71
|
+
'Action' => 'SendMessage',
|
72
|
+
'MessageBody' => msg
|
73
|
+
}
|
74
|
+
|
75
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
76
|
+
end
|
77
|
+
|
78
|
+
def receive_message(queue_url, limit=nil, timeout=nil, *attrs)
|
79
|
+
params = {'Action' => 'ReceiveMessage'}
|
80
|
+
params['MaxNumberOfMessages'] = limit if limit
|
81
|
+
params['VisibilityTimeout'] = timeout if timeout
|
82
|
+
params.merge!(pack_attrs(attrs))
|
83
|
+
|
84
|
+
RAWS.fetch(
|
85
|
+
'GET',
|
86
|
+
queue_url,
|
87
|
+
PARAMS.merge(params),
|
88
|
+
:multiple => %w'Message Attribute',
|
89
|
+
:unpack => %w'Attribute'
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
def change_message_visibility(queue_url, receipt_handle, timeout)
|
94
|
+
params = {
|
95
|
+
'Action' => 'ChangeMessageVisibility',
|
96
|
+
'ReceiptHandle' => receipt_handle,
|
97
|
+
'VisibilityTimeout' => timeout
|
98
|
+
}
|
99
|
+
|
100
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
101
|
+
end
|
102
|
+
|
103
|
+
def delete_message(queue_url, receipt_handle)
|
104
|
+
params = {
|
105
|
+
'Action' => 'DeleteMessage',
|
106
|
+
'ReceiptHandle' => receipt_handle
|
107
|
+
}
|
108
|
+
|
109
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
110
|
+
end
|
111
|
+
|
112
|
+
def pack_permission(params)
|
113
|
+
ret = {}
|
114
|
+
|
115
|
+
i = 1
|
116
|
+
params.each do |id, permissions|
|
117
|
+
permissions.each do |permission|
|
118
|
+
ret["AWSAccountId.#{i}"] = id
|
119
|
+
ret["ActionName.#{i}"] = permission
|
120
|
+
i += 1
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
ret
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_permission(queue_url, label, permission)
|
128
|
+
params = {
|
129
|
+
'Action' => 'AddPermission',
|
130
|
+
'Label' => label
|
131
|
+
}
|
132
|
+
params.merge!(pack_permission(permission))
|
133
|
+
|
134
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
135
|
+
end
|
136
|
+
|
137
|
+
def remove_permission(queue_url, label)
|
138
|
+
params = {
|
139
|
+
'Action' => 'RemovePermission',
|
140
|
+
'Label' => label
|
141
|
+
}
|
142
|
+
|
143
|
+
RAWS.fetch('GET', queue_url, PARAMS.merge(params))
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
extend Adapter20090201
|
148
|
+
end
|
data/lib/raws/sqs.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
class RAWS::SQS
|
2
|
+
autoload :Adapter, 'raws/sqs/adapter'
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def queue_url(queue_name)
|
6
|
+
data = Adapter.list_queues(
|
7
|
+
queue_name
|
8
|
+
)['ListQueuesResponse']['ListQueuesResult']
|
9
|
+
|
10
|
+
data['QueueUrl'].each do |url|
|
11
|
+
_queue_name = URI.parse(url).path.split('/').last
|
12
|
+
if _queue_name == queue_name
|
13
|
+
return url
|
14
|
+
end
|
15
|
+
end unless data.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_queue(queue_name, timeout=nil)
|
19
|
+
self.new(
|
20
|
+
Adapter.create_queue(
|
21
|
+
queue_name,
|
22
|
+
timeout
|
23
|
+
)['CreateQueueResponse']['CreateQueueResult']['QueueUrl']
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_queue(queue_url)
|
28
|
+
Adapter.delete_queue(queue_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
def list(prefix=nil)
|
32
|
+
(
|
33
|
+
Adapter.list_queues(
|
34
|
+
prefix
|
35
|
+
)['ListQueuesResponse']['ListQueuesResult']['QueueUrl'] || []
|
36
|
+
).map do |val|
|
37
|
+
self.new(val)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def each(&block)
|
42
|
+
list.each(&block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def [](queue_name)
|
46
|
+
if url = queue_url(queue_name)
|
47
|
+
self.new(queue_url(queue_name))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_attrs(queue_url, *attrs)
|
52
|
+
Adapter.get_queue_attributes(
|
53
|
+
queue_url,
|
54
|
+
*attrs
|
55
|
+
)['GetQueueAttributesResponse']['GetQueueAttributesResult']['Attribute']
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_attrs(queue_url, attrs={})
|
59
|
+
Adapter.set_queue_attributes(queue_url, attrs)
|
60
|
+
end
|
61
|
+
|
62
|
+
def send(queue_url, msg)
|
63
|
+
Adapter.send_message(queue_url, msg)
|
64
|
+
end
|
65
|
+
|
66
|
+
def receive(queue_url, params={}, *attrs)
|
67
|
+
Adapter.receive_message(
|
68
|
+
queue_url,
|
69
|
+
params[:limit],
|
70
|
+
params[:timeout],
|
71
|
+
*attrs
|
72
|
+
)['ReceiveMessageResponse']['ReceiveMessageResult']['Message'] || []
|
73
|
+
end
|
74
|
+
|
75
|
+
def change_message_visibility(queue_url, handle, timeout)
|
76
|
+
Adapter.change_message_visibility(queue_url, handle, timeout)
|
77
|
+
end
|
78
|
+
|
79
|
+
def delete_message(queue_url, handle)
|
80
|
+
Adapter.delete_message(queue_url, handle)
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_permission(queue_url, label, permission)
|
84
|
+
Adapter.add_permission(queue_url, label, permission)
|
85
|
+
end
|
86
|
+
|
87
|
+
def remove_permission(queue_url, label)
|
88
|
+
Adapter.remove_permission(queue_url, label)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Message
|
93
|
+
attr_reader :queue
|
94
|
+
attr_reader :data
|
95
|
+
|
96
|
+
def initialize(queue, data)
|
97
|
+
@queue, @data = queue, data
|
98
|
+
end
|
99
|
+
|
100
|
+
def body
|
101
|
+
data['Body']
|
102
|
+
end
|
103
|
+
|
104
|
+
def visibility=(timeout)
|
105
|
+
queue.change_message_visibility data['ReceiptHandle'], timeout
|
106
|
+
end
|
107
|
+
|
108
|
+
def delete
|
109
|
+
queue.delete_message data['ReceiptHandle']
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
attr_reader :queue_url
|
114
|
+
attr_reader :queue_name
|
115
|
+
|
116
|
+
def initialize(queue_url)
|
117
|
+
@queue_url = queue_url
|
118
|
+
@queue_name = URI.parse(@queue_url).path.split('/').last
|
119
|
+
end
|
120
|
+
|
121
|
+
def delete_queue
|
122
|
+
self.class.delete_queue(queue_url)
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_attrs(*attrs)
|
126
|
+
self.class.get_attrs(queue_url, *attrs)
|
127
|
+
end
|
128
|
+
|
129
|
+
def set_attrs(attrs={})
|
130
|
+
self.class.set_attrs(queue_url, attrs)
|
131
|
+
end
|
132
|
+
|
133
|
+
def send(msg)
|
134
|
+
self.class.send(queue_url, msg)
|
135
|
+
end
|
136
|
+
|
137
|
+
def receive(params={}, *attrs)
|
138
|
+
self.class.receive(queue_url, params, *attrs).map do |val|
|
139
|
+
Message.new(self, val)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def change_message_visibility(handle, timeout)
|
144
|
+
self.class.change_message_visibility(queue_url, handle, timeout)
|
145
|
+
end
|
146
|
+
|
147
|
+
def delete_message(handle)
|
148
|
+
self.class.delete_message(queue_url, handle)
|
149
|
+
end
|
150
|
+
|
151
|
+
def add_permission(label, permission)
|
152
|
+
self.class.add_permission(queue_url, label, permission)
|
153
|
+
end
|
154
|
+
|
155
|
+
def remove_permission(label)
|
156
|
+
self.class.remove_permission(queue_url, label)
|
157
|
+
end
|
158
|
+
end
|
data/lib/raws.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'time'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'typhoeus'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
module RAWS
|
10
|
+
include Typhoeus
|
11
|
+
|
12
|
+
class Error < StandardError
|
13
|
+
attr_reader :response
|
14
|
+
attr_reader :data
|
15
|
+
|
16
|
+
def initialize(response, data)
|
17
|
+
super()
|
18
|
+
@response, @data = response, data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
attr_accessor :aws_access_key_id
|
24
|
+
attr_accessor :aws_secret_access_key
|
25
|
+
|
26
|
+
def escape(val)
|
27
|
+
URI.escape(val.to_s, /([^a-zA-Z0-9\-_.~]+)/n)
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign(http_verb, base_uri, params)
|
31
|
+
path = {
|
32
|
+
'AWSAccessKeyId' => aws_access_key_id,
|
33
|
+
'SignatureMethod' => 'HmacSHA256',
|
34
|
+
'SignatureVersion' => '2',
|
35
|
+
'Timestamp' => Time.now.utc.iso8601
|
36
|
+
}.merge(params).map do |key, val|
|
37
|
+
"#{escape(key)}=#{escape(val)}"
|
38
|
+
end.sort.join('&')
|
39
|
+
|
40
|
+
uri = URI.parse(base_uri)
|
41
|
+
"#{path}&Signature=" + escape(
|
42
|
+
[
|
43
|
+
::OpenSSL::HMAC.digest(
|
44
|
+
::OpenSSL::Digest::SHA256.new,
|
45
|
+
aws_secret_access_key,
|
46
|
+
"#{http_verb.upcase}\n#{uri.host.downcase}\n#{uri.path}\n#{path}"
|
47
|
+
)
|
48
|
+
].pack('m').strip
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def pack_attrs(attrs, replaces=nil, prefix=nil)
|
53
|
+
params = {}
|
54
|
+
|
55
|
+
i = 1
|
56
|
+
attrs.each do |key, val|
|
57
|
+
if !replaces.nil? && replaces.include?(key)
|
58
|
+
params["#{prefix}Attribute.#{i}.Replace"] = 'true'
|
59
|
+
end
|
60
|
+
|
61
|
+
if val.is_a? Array
|
62
|
+
val.each do |v|
|
63
|
+
params["#{prefix}Attribute.#{i}.Name"] = key
|
64
|
+
params["#{prefix}Attribute.#{i}.Value"] = v
|
65
|
+
i += 1
|
66
|
+
end
|
67
|
+
else
|
68
|
+
params["#{prefix}Attribute.#{i}.Name"] = key
|
69
|
+
params["#{prefix}Attribute.#{i}.Value"] = val
|
70
|
+
i += 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
params
|
75
|
+
end
|
76
|
+
|
77
|
+
def unpack_attrs(attrs)
|
78
|
+
ret = {}
|
79
|
+
|
80
|
+
if attrs.is_a? Array
|
81
|
+
attrs
|
82
|
+
else
|
83
|
+
[attrs]
|
84
|
+
end.map do |val|
|
85
|
+
name, value = val['Name'], val['Value']
|
86
|
+
|
87
|
+
if ret.key? name
|
88
|
+
ret[name] = [ret[name]] unless ret[name].is_a? Array
|
89
|
+
ret[name] << value
|
90
|
+
else
|
91
|
+
ret[name] = value
|
92
|
+
end
|
93
|
+
end if attrs
|
94
|
+
|
95
|
+
ret
|
96
|
+
end
|
97
|
+
|
98
|
+
def parse(doc, params={}, ret={})
|
99
|
+
multiple = params[:multiple] || []
|
100
|
+
unpack = params[:unpack] || []
|
101
|
+
|
102
|
+
name = nil
|
103
|
+
doc.children.each do |tag|
|
104
|
+
name = tag.name #.gsub(/([A-Z])/, '_\1').gsub(/^_/, '').downcase.to_sym
|
105
|
+
|
106
|
+
unless ret[name].is_a? Array
|
107
|
+
if ret.key?(name)
|
108
|
+
ret[name] = [ret[name]]
|
109
|
+
elsif multiple.include? name
|
110
|
+
ret[name] = []
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if tag.child.is_a? Nokogiri::XML::Text
|
115
|
+
if ret.key? name
|
116
|
+
ret[name] << tag.content
|
117
|
+
else
|
118
|
+
ret[name] = tag.content
|
119
|
+
end
|
120
|
+
else
|
121
|
+
if ret.key? name
|
122
|
+
ret[name] << {}
|
123
|
+
parse(tag, params, ret[name].last)
|
124
|
+
else
|
125
|
+
ret[name] = {}
|
126
|
+
parse(tag, params, ret[name])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
ret[name] = unpack_attrs(ret[name]) if unpack.include?(name)
|
131
|
+
|
132
|
+
ret
|
133
|
+
end
|
134
|
+
|
135
|
+
def fetch(http_verb, base_uri, params, options={})
|
136
|
+
r = get("#{base_uri}?#{sign(http_verb, base_uri, params)}")
|
137
|
+
data = parse(Nokogiri::XML.parse(r.body), options)
|
138
|
+
if 200 <= r.code && r.code <= 299
|
139
|
+
data
|
140
|
+
else
|
141
|
+
raise Error.new(r, data)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
autoload :SDB, 'raws/sdb'
|
147
|
+
autoload :SQS, 'raws/sqs'
|
148
|
+
autoload :S3, 'raws/s3'
|
149
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec/spec_config'
|
2
|
+
|
3
|
+
describe RAWS::S3::Adapter do
|
4
|
+
describe 'class' do
|
5
|
+
it 'get_service' do
|
6
|
+
begin
|
7
|
+
p RAWS::S3::Adapter.get_service
|
8
|
+
rescue RAWS::Error => e
|
9
|
+
p e.response.code
|
10
|
+
p e.data
|
11
|
+
rescue => e
|
12
|
+
p e
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'put_bucket' do
|
17
|
+
begin
|
18
|
+
# p RAWS::S3::Adapter.delete_bucket('kikuchitestbucket')
|
19
|
+
#p RAWS::S3::Adapter.put_bucket('kikuchitestbucket')
|
20
|
+
rescue RAWS::Error => e
|
21
|
+
p e.response.code
|
22
|
+
p e.data
|
23
|
+
rescue => e
|
24
|
+
p e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec/spec_config'
|
2
|
+
|
3
|
+
class SDBModel
|
4
|
+
include RAWS::SDB::Model
|
5
|
+
self.domain_name = RAWS_SDB_DOMAIN
|
6
|
+
end
|
7
|
+
|
8
|
+
describe RAWS::SDB::Model do
|
9
|
+
describe 'class' do
|
10
|
+
it 'methods' do
|
11
|
+
%w'
|
12
|
+
create_domain
|
13
|
+
delete_domain
|
14
|
+
select
|
15
|
+
all
|
16
|
+
generate_id
|
17
|
+
'.each do |val|
|
18
|
+
SDBModel.should respond_to val.to_sym
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'domain_name' do
|
23
|
+
SDBModel.domain_name.should == RAWS_SDB_DOMAIN
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'object' do
|
28
|
+
before do
|
29
|
+
@model = SDBModel.new
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'methods' do
|
33
|
+
%w'
|
34
|
+
[]
|
35
|
+
[]=
|
36
|
+
delete
|
37
|
+
save
|
38
|
+
'.each do |val|
|
39
|
+
@model.should respond_to val.to_sym
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|