em_aws 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- em_aws (0.3.1)
4
+ em_aws (0.3.2)
5
5
  aws-sdk (>= 1.9.3)
6
6
  em-http-request
7
7
  em-synchrony
@@ -12,7 +12,7 @@ GEM
12
12
  specs:
13
13
  ZenTest (4.8.4)
14
14
  addressable (2.3.4)
15
- aws-sdk (1.11.2)
15
+ aws-sdk (1.11.3)
16
16
  json (~> 1.4)
17
17
  nokogiri (< 1.6.0)
18
18
  uuidtools (~> 2.1)
@@ -25,7 +25,7 @@ GEM
25
25
  em-socksify
26
26
  eventmachine (>= 1.0.0.beta.4)
27
27
  http_parser.rb (>= 0.5.3)
28
- em-socksify (0.2.1)
28
+ em-socksify (0.3.0)
29
29
  eventmachine (>= 1.0.0.beta.4)
30
30
  em-synchrony (1.0.3)
31
31
  eventmachine (>= 1.0.0.beta.1)
data/HISTORY.md CHANGED
@@ -4,6 +4,9 @@ EmAws Changelog
4
4
  HEAD
5
5
  =======
6
6
 
7
+ - check for Aws.config.logger when setting HotTub.logger [kybishop #21]
8
+ - Clean up specs [kybishop #22]
9
+
7
10
  0.3.0
8
11
  =======
9
12
 
@@ -8,5 +8,5 @@ require 'aws/core/http/em_http_handler'
8
8
  require 'hot_tub'
9
9
 
10
10
  AWS.eager_autoload! # lazy load isn't thread safe
11
- HotTub.logger = AWS.config.logger
11
+ HotTub.logger = AWS.config.logger if AWS.config.logger
12
12
  module EmAws;end
@@ -1,3 +1,3 @@
1
1
  module EmAws
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -22,7 +22,7 @@ module AWS::Core
22
22
  end
23
23
  end
24
24
 
25
- # A slow server for testing timeout,
25
+ # A slow server for testing timeout,
26
26
  # borrowed from: http://www.igvita.com/2008/05/27/ruby-eventmachine-the-speed-demon/
27
27
  class SlowServer < EventMachine::Connection
28
28
  include EventMachine::HttpServer
@@ -39,10 +39,9 @@ module AWS::Core
39
39
  end
40
40
 
41
41
  describe EMHttpHandler do
42
-
43
42
  let(:handler) { EMHttpHandler.new(default_request_options) }
44
43
 
45
- let(:default_request_options) { {} }
44
+ let(:default_request_options) { Hash.new }
46
45
 
47
46
  let(:req) do
48
47
  r = Http::Request.new
@@ -56,50 +55,112 @@ module AWS::Core
56
55
 
57
56
  let(:em_http_options) do
58
57
  options = nil
59
- EMHttpHandler.should_receive(:fetch_response).with do |url, method,opts|
58
+ EMHttpHandler.should_receive(:fetch_response).with do |url, _, opts|
60
59
  options = opts
61
60
  double("http response",
62
61
  :response => "<foo/>",
63
62
  :code => 200,
64
63
  :to_hash => {})
65
64
  end
65
+
66
66
  handler.handle(req, resp)
67
+
67
68
  options
68
69
  end
69
70
 
70
71
  it 'should be accessible from AWS as well as AWS::Core' do
71
- AWS::Http::EMHttpHandler.new.should
72
- be_an(AWS::Core::Http::EMHttpHandler)
72
+ AWS::Http::EMHttpHandler.new
73
+ .should be_an(AWS::Core::Http::EMHttpHandler)
74
+ end
75
+
76
+ it "should not timeout" do
77
+ EM.synchrony do
78
+ response = Http::Response.new
79
+ request = Http::Request.new
80
+ request.host = "127.0.0.1"
81
+ request.port = "8081"
82
+ request.uri = "/"
83
+ request.body_stream = StringIO.new("myStringIO")
84
+
85
+ # turn on our test server
86
+ EventMachine::run do
87
+ EventMachine::start_server request.host, request.port, SlowServer
88
+ end
89
+
90
+ handler.stub(:fetch_url).and_return("http://127.0.0.1:8081")
91
+
92
+ handler.handle(request,response)
93
+
94
+ response.network_error.should be_nil
95
+
96
+ EM.stop
97
+ end
98
+ end
99
+
100
+ it "should timeout after 0.1 seconds" do
101
+ EM.synchrony do
102
+ response = Http::Response.new
103
+ request = Http::Request.new
104
+ request.host = "127.0.0.1"
105
+ request.port = "8081"
106
+ request.uri = "/"
107
+ request.body_stream = StringIO.new("myStringIO")
108
+
109
+ # turn on our test server
110
+ EventMachine::run do
111
+ EventMachine::start_server request.host, request.port, SlowServer
112
+ end
113
+
114
+ handler.stub(:fetch_url).and_return("http://127.0.0.1:8081")
115
+ request.stub(:read_timeout).and_return(0.01)
116
+ handler.stub(:connect_timeout).and_return(1) #just to speed up the test
117
+
118
+ handler.handle(request,response)
119
+
120
+ response.network_error.should be_a(Timeout::Error)
121
+
122
+ EM.stop
123
+ end
73
124
  end
74
125
 
75
126
  describe '#handle' do
76
127
  context 'timeouts' do
77
128
  it 'should rescue Timeout::Error' do
78
- handler.stub(:fetch_response).
79
- and_raise(Timeout::Error)
80
- lambda { handler.handle(req, resp) }.
81
- should_not raise_error
129
+ handler
130
+ .stub(:fetch_response)
131
+ .and_raise(Timeout::Error)
132
+
133
+ expect {
134
+ handler.handle(req, resp)
135
+ }.to_not raise_error
82
136
  end
83
137
 
84
138
  it 'should rescue Errno::ETIMEDOUT' do
85
- handler.stub(:fetch_response).
86
- and_raise(Errno::ETIMEDOUT)
87
- lambda { handler.handle(req, resp) }.
88
- should_not raise_error
139
+ handler
140
+ .stub(:fetch_response)
141
+ .and_raise(Errno::ETIMEDOUT)
142
+
143
+ expect {
144
+ handler.handle(req, resp)
145
+ }.to_not raise_error
89
146
  end
90
147
 
91
148
  it 'should indicate that there was a network_error' do
92
- handler.stub(:fetch_response).
93
- and_raise(Errno::ETIMEDOUT)
149
+ handler
150
+ .stub(:fetch_response)
151
+ .and_raise(Errno::ETIMEDOUT)
152
+
94
153
  handler.handle(req, resp)
154
+
95
155
  resp.network_error?.should be_true
96
156
  end
97
157
  end
98
158
 
99
159
  context 'default request options' do
100
160
  before(:each) do
101
- handler.stub(:default_request_options).and_return({ :foo => "BAR",
102
- :private_key_file => "blarg" })
161
+ handler
162
+ .stub(:default_request_options)
163
+ .and_return(:foo => "BAR", :private_key_file => "blarg")
103
164
  end
104
165
 
105
166
  it 'passes extra options through to synchrony' do
@@ -115,92 +176,75 @@ module AWS::Core
115
176
 
116
177
  describe '#fetch_request_options' do
117
178
  it "should set :query and :body to request.querystring" do
118
- opts = handler.send(:fetch_request_options,(req))
179
+ opts = handler.send(:fetch_request_options, req)
119
180
  opts[:query].should eql(req.querystring)
120
181
  end
121
182
 
122
183
  it "should set :path to request.path" do
123
- opts = handler.send(:fetch_request_options,(req))
184
+ opts = handler.send(:fetch_request_options, req)
124
185
  opts[:path].should eql(req.path)
125
186
  end
187
+
126
188
  context "request.body_stream is a StringIO" do
127
189
  it "should set :body to request.body_stream" do
128
- opts = handler.send(:fetch_request_options,(req))
190
+ opts = handler.send(:fetch_request_options, req)
129
191
  opts[:body].should eql("myStringIO")
130
192
  end
131
193
  end
194
+
132
195
  context "request.body_stream is an object that responds to :path" do
196
+ let(:io_object) { EMFooIO.new }
197
+
198
+ before(:each) do
199
+ req
200
+ .stub(:body_stream)
201
+ .and_return(io_object)
202
+ end
203
+
133
204
  it "should set :file to object.path " do
134
- my_io = EMFooIO.new
135
- req.stub(:body_stream).and_return(my_io)
136
- opts = handler.send(:fetch_request_options,(req))
137
- opts[:file].should eql(my_io.path)
205
+ opts = handler.send(:fetch_request_options, req)
206
+ opts[:file].should eql(io_object.path)
138
207
  end
139
208
  end
140
-
141
209
  end
142
210
 
143
211
  describe '#fetch_client_options' do
144
212
  it "should remove pool related options" do
145
213
  opts = handler.send(:fetch_client_options)
214
+
146
215
  opts.has_key?(:size).should be_false
147
216
  opts.has_key?(:never_block).should be_false
148
217
  opts.has_key?(:blocking_timeout).should be_false
149
218
  end
150
- context "with_pool is true" do
219
+
220
+ context "when with_pool is true" do
221
+ before(:each) do
222
+ handler
223
+ .stub(:with_pool?)
224
+ .and_return(true)
225
+ end
226
+
151
227
  it "should set keepalive as true" do
152
- handler.stub(:with_pool?).and_return(true)
153
228
  opts = handler.send(:fetch_client_options)
229
+
154
230
  opts[:keepalive].should be_true
155
231
  end
156
232
  end
157
- context "with_pool is false" do
233
+
234
+ context "when with_pool is false" do
235
+ before(:each) do
236
+ handler
237
+ .stub(:with_pool?)
238
+ .and_return(false)
239
+ end
240
+
158
241
  it "should keepalive be false" do
159
- handler.stub(:with_pool?).and_return(false)
160
242
  opts = handler.send(:fetch_client_options)
243
+
161
244
  opts[:keepalive].should_not be_true
162
245
  end
163
246
  end
164
247
  end
165
-
166
- it "should not timeout" do
167
- EM.synchrony {
168
- response = Http::Response.new
169
- request = Http::Request.new
170
- request.host = "127.0.0.1"
171
- request.port = "8081"
172
- request.uri = "/"
173
- request.body_stream = StringIO.new("myStringIO")
174
- # turn on our test server
175
- EventMachine::run {
176
- EventMachine::start_server request.host, request.port, SlowServer
177
- }
178
- handler.stub(:fetch_url).and_return("http://127.0.0.1:8081")
179
- handler.handle(request,response)
180
- response.network_error.should be_nil
181
- EM.stop
182
- }
183
- end
184
- it "should timeout after 0.1 seconds" do
185
- EM.synchrony {
186
- response = Http::Response.new
187
- request = Http::Request.new
188
- request.host = "127.0.0.1"
189
- request.port = "8081"
190
- request.uri = "/"
191
- request.body_stream = StringIO.new("myStringIO")
192
- # turn on our test server
193
- EventMachine::run {
194
- EventMachine::start_server request.host, request.port, SlowServer
195
- }
196
- handler.stub(:fetch_url).and_return("http://127.0.0.1:8081")
197
- request.stub(:read_timeout).and_return(0.01)
198
- handler.stub(:connect_timeout).and_return(1) #just to speed up the test
199
- handler.handle(request,response)
200
- response.network_error.should be_a(Timeout::Error)
201
- EM.stop
202
- }
203
- end
204
248
  end
205
249
  end
206
250
  end
@@ -7,20 +7,20 @@ describe Mutex do
7
7
  EM.stop
8
8
  end
9
9
  end
10
-
10
+
11
11
  it "should be a fiber safe mutex" do
12
12
  EM.synchrony do
13
13
  AWS.mutex.new.should be_kind_of(EM::Synchrony::Thread::Mutex)
14
14
  EM.stop
15
15
  end
16
16
  end
17
-
17
+
18
18
  it "should not affect Mutex outside AWS" do
19
19
  Mutex.new.should be_kind_of(Mutex)
20
20
  end
21
21
  end
22
22
 
23
- describe Kernel,'#sleep' do
23
+ describe Kernel, '#sleep' do
24
24
  it "should be a fiber safe sleep from with AWS module" do
25
25
  EM.synchrony do
26
26
  EM::Synchrony.stub(:sleep).and_return("fiber safe")
@@ -28,8 +28,8 @@ describe Kernel,'#sleep' do
28
28
  EM.stop
29
29
  end
30
30
  end
31
-
31
+
32
32
  it "should not affect normal Kernel.sleep if not in EM" do
33
33
  Kernel.sleep(1).should eql(1)
34
34
  end
35
- end
35
+ end
metadata CHANGED
@@ -1,60 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Joshua Mckinney
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-12 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: aws-sdk
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 1.9.3
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.9.3
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: em-synchrony
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: em-http-request
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: hot_tub
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,29 +78,33 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rspec
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: builder
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  description: Adds EM-Synchrony support to AWS-SDK gem
@@ -120,26 +133,27 @@ files:
120
133
  homepage: https://github.com/JoshMcKin/em_aws
121
134
  licenses:
122
135
  - MIT
123
- metadata: {}
124
136
  post_install_message:
125
137
  rdoc_options: []
126
138
  require_paths:
127
139
  - lib
128
140
  required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
129
142
  requirements:
130
- - - '>='
143
+ - - ! '>='
131
144
  - !ruby/object:Gem::Version
132
145
  version: '0'
133
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
+ none: false
134
148
  requirements:
135
- - - '>='
149
+ - - ! '>='
136
150
  - !ruby/object:Gem::Version
137
151
  version: '0'
138
152
  requirements: []
139
153
  rubyforge_project: em_aws
140
- rubygems_version: 2.0.3
154
+ rubygems_version: 1.8.25
141
155
  signing_key:
142
- specification_version: 4
156
+ specification_version: 3
143
157
  summary: Adds EM-Synchrony support to AWS-SDK gem
144
158
  test_files:
145
159
  - spec/em_http_handler_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 76fb6ffb745a5461bc79e96230007856e0a8fbd1
4
- data.tar.gz: 8bb813a1ce07abb55da8a70710af177c47b79c79
5
- SHA512:
6
- metadata.gz: 68fcac41420bc2411c41cc8e16cf8e6e15d796c442e4135095554f9f350554a550592e12c2d6f06e6ffd113d819a24dbd92ed0baaad1a8fbc0cf3a29714f00f5
7
- data.tar.gz: 88092efaf8a1b3abf52e9c9575715d678dedc295ba68028cc35d9857a420b612b9b4b0ed8cac7b26c3149a09aa41f37a3f3c26452fde045d303a8e3c7bbeafe3