aws-sdk 1.2.4 → 1.2.5

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.
@@ -56,7 +56,7 @@ require 'aws/core/autoloader'
56
56
  module AWS
57
57
 
58
58
  # Current version of the AWS SDK for Ruby
59
- VERSION = "1.2.4"
59
+ VERSION = "1.2.5"
60
60
 
61
61
  register_autoloads(self) do
62
62
  autoload :Errors, 'errors'
@@ -19,26 +19,30 @@ module AWS
19
19
 
20
20
  # @private
21
21
  class CurbHandler
22
-
22
+
23
23
  def initialize
24
24
  @q = []
25
25
  @sem = Mutex.new
26
26
  @multi = Curl::Multi.new
27
-
27
+
28
28
  start_processor
29
29
  end
30
-
30
+
31
31
  def handle request, response
32
32
  raise "unsupport http reqest method: #{request.http_method}" unless
33
33
  ['GET', 'HEAD', 'PUT', 'POST', 'DELETE'].include? request.http_method
34
34
  @sem.synchronize do
35
35
  @q << [request, response, Thread.current]
36
- @processor.wakeup
36
+ begin
37
+ @processor.wakeup
38
+ rescue ThreadError
39
+ start_processor
40
+ end
37
41
  end
38
42
  Thread.stop
39
43
  nil
40
44
  end
41
-
45
+
42
46
  # fills the Curl::Multi handle with the given array of queue
43
47
  # items, calling make_easy_handle on each one first
44
48
  private
@@ -48,7 +52,7 @@ module AWS
48
52
  @multi.add(c)
49
53
  end
50
54
  end
51
-
55
+
52
56
  # starts a background thread that waits for new items and
53
57
  # sends them through the Curl::Multi handle
54
58
  private
@@ -73,56 +77,60 @@ module AWS
73
77
  end
74
78
  end
75
79
  end
76
-
80
+
77
81
  # wait for a new item to show up before continuing
78
82
  Thread.stop if @q.empty?
79
83
  end
80
84
  end
81
85
  end
82
-
86
+
83
87
  private
84
88
  def make_easy_handle request, response, thread = nil
85
-
89
+
86
90
  url = request.use_ssl? ?
87
91
  "https://#{request.host}:443#{request.uri}" :
88
92
  "http://#{request.host}#{request.uri}"
89
-
93
+
90
94
  curl = Curl::Easy.new(url)
91
- curl.headers = request.headers
92
-
95
+ # curl.verbose = true
96
+ request.headers.each {|k, v| curl.headers[k] = v}
97
+
93
98
  if proxy = request.proxy_uri
94
99
  curl.proxy_url = proxy.to_s
95
100
  curl.proxy_port = proxy.port
96
101
  end
97
-
102
+
98
103
  curl.on_header {|header_data|
99
- name, value = header_data.strip.split(/:\s+/, 2)
100
- response.headers[name] = value
104
+ if header_data =~ /:\s+/
105
+ name, value = header_data.strip.split(/:\s+/, 2)
106
+ response.headers[name] = value
107
+ end
101
108
  header_data.length
102
109
  }
103
-
110
+
104
111
  case request.http_method
105
112
  when 'GET'
106
113
  # ....
107
114
  when 'HEAD'
108
115
  curl.head = true
109
116
  when 'PUT'
110
- curl.put_data = request.body
117
+ curl.put_data = request.body || ''
111
118
  when 'POST'
112
- curl.post_body = request.body
119
+ curl.headers['Content-Type'] = curl.headers['Content-Type'] || ''
120
+ curl.post_body = request.body || ''
113
121
  when 'DELETE'
114
122
  curl.delete = true
115
123
  end
116
-
124
+
117
125
  curl.on_complete do
118
126
  response.body = curl.body_str
119
127
  response.status = curl.response_code
120
128
  thread.run if thread
121
129
  end
122
-
130
+
123
131
  curl
124
132
  end
125
-
133
+
126
134
  end
127
135
  end
128
136
  end
@@ -467,7 +467,8 @@ module AWS
467
467
  #
468
468
  # @return [String] the console output.
469
469
  def console_output
470
- Base64.decode64(client.get_console_output(:instance_id => self.id).output)
470
+ output = client.get_console_output(:instance_id => self.id).output
471
+ Base64.decode64(output) if output
471
472
  end
472
473
 
473
474
  # Associates the elastic IP address with this instance.
@@ -36,7 +36,6 @@ module AWS
36
36
 
37
37
  groups = p.groups.collect do |group|
38
38
  SecurityGroup.new(group.group_id,
39
- :name => group.group_name,
40
39
  :owner_id => group.user_id,
41
40
  :config => config)
42
41
  end
@@ -287,7 +287,12 @@ module AWS
287
287
  # @private
288
288
  protected
289
289
  def next_markers page
290
- { :marker => (last = page.contents.last and last.key) }
290
+ marker = (last = page.contents.last and last.key)
291
+ if marker.nil?
292
+ raise 'Unable to find marker in S3 list objects response'
293
+ else
294
+ { :marker => marker }
295
+ end
291
296
  end
292
297
 
293
298
  # processes items in batches of 1k items
@@ -91,17 +91,20 @@ module AWS
91
91
  # @param [mixed] endpoint The endpoint that should receive
92
92
  # messages that are published to this topic. Valid values
93
93
  # for +endpoint+ include:
94
+ #
94
95
  # * URI object
95
96
  # * http and https URI strings
96
- # * email addresse
97
+ # * email address
97
98
  # * {SQS::Queue}
98
99
  # * SQS queue ARN
100
+ # * phone number of an SMS-enabled device
101
+ #
99
102
  # @param [Hash] options
100
103
  # @option options [Boolean] :json (false)
101
104
  # @return [Subscription,nil] Returns a subscription when possible.
102
105
  # If the subscription requires confirmation first, then +nil+ is
103
106
  # returned instead.
104
- def subscribe(endpoint, opts = {})
107
+ def subscribe endpoint, opts = {}
105
108
  subscribe_opts = endpoint_opts(endpoint, opts).merge(:topic_arn => arn)
106
109
  resp = client.subscribe(subscribe_opts)
107
110
  if arn = resp.subscription_arn and arn =~ /^arn:/
@@ -369,6 +372,8 @@ module AWS
369
372
  when endpoint.include?("@")
370
373
  { :protocol => opts[:json] ? "email-json" : "email",
371
374
  :endpoint => endpoint }
375
+ when endpoint.gsub(/\D/,'') =~ /\d{11,15}/
376
+ { :protocol => "sms", :endpoint => endpoint.gsub(/\D/,'') }
372
377
  else
373
378
  raise ArgumentError, "could not determine protocol for '#{endpoint}'"
374
379
  end
@@ -94,8 +94,7 @@ module AWS
94
94
  # @return [SentMessage] An object containing information about
95
95
  # the message that was sent.
96
96
  def send_message(body)
97
- resp = client.send_message(:queue_url => url,
98
- :message_body => body)
97
+ resp = client.send_message(:queue_url => url, :message_body => body)
99
98
  msg = SentMessage.new
100
99
  msg.message_id = resp.message_id
101
100
  msg.md5 = resp.md5_of_message_body
@@ -22,19 +22,19 @@ module AWS
22
22
 
23
23
  include Core::Model
24
24
 
25
- # @param [String] encoded_body The base64 encoded json string
25
+ # @param [String] body The SQS message body
26
26
  # from a message published by SNS.
27
27
  # @param [Hash] options
28
- def initialize encoded_body, options = {}
29
- @encoded_body = encoded_body
28
+ def initialize body, options = {}
29
+ @body = body
30
30
  super
31
31
  end
32
32
 
33
- # @return [String] Returns the Base64 encoded JSON hash as was
33
+ # @return [String] Returns the JSON hash (as a string) as was
34
34
  # published by SNS. See {#body} to get the decoded message
35
35
  # or {#to_h} to get the decoded JSON hash as a ruby hash.
36
- def encoded_body
37
- @encoded_body
36
+ def raw_message
37
+ @body
38
38
  end
39
39
 
40
40
  # @return[String] Returns the decoded message as was published.
@@ -92,7 +92,7 @@ module AWS
92
92
 
93
93
  # @return [Hash] Returns the decoded message as a hash.
94
94
  def to_h
95
- data = JSON.parse(Base64.decode64(@encoded_body))
95
+ data = JSON.parse(@body)
96
96
  {
97
97
  :body => data['Message'],
98
98
  :topic_arn => data['TopicArn'],
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Amazon Web Services
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-07 00:00:00 -08:00
18
+ date: 2011-12-15 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency