rubygems-test 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.3.7 / 2011-03-02
2
+
3
+ * Support for proxy environment variables. If it works on rubygems, it probably works here now too!
4
+
5
+ === 0.3.6 / 2011-02-27
6
+
7
+ * Moved publish host default to test.rubygems.org
8
+
1
9
  === 0.3.5 / 2011-02-11
2
10
 
3
11
  * rebuild of rubygems-test 0.3.4 on rubygems 1.5.2
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ spec = Hoe.spec 'rubygems-test' do
12
12
 
13
13
  # doin' it wrong because we're a gem plugin
14
14
  # that means I can be "special"!
15
- self.version = '0.3.6'
15
+ self.version = '0.3.7'
16
16
 
17
17
  self.rubyforge_name = nil
18
18
 
@@ -149,6 +149,53 @@ class Gem::Commands::TestCommand < Gem::Command
149
149
  $RG_T_INSTALLING_DEPENDENCIES = false
150
150
  true
151
151
  end
152
+
153
+ ##
154
+ # Normalize the URI by adding "http://" if it is missing.
155
+ #
156
+ #--
157
+ #
158
+ # taken verbatim from rubygems.
159
+ #
160
+
161
+ def normalize_uri(uri)
162
+ (uri =~ /^(https?|ftp|file):/) ? uri : "http://#{uri}"
163
+ end
164
+
165
+ ##
166
+ # Escapes a URI.
167
+ #
168
+ #--
169
+ #
170
+ # Taken verbatim from rubygems.
171
+ #
172
+ def escape(str)
173
+ return nil unless str
174
+ URI.escape str
175
+ end
176
+
177
+ #
178
+ # if a proxy is supplied, return a URI
179
+ #
180
+ #--
181
+ #
182
+ # taken almost verbatim from rubygems.
183
+ #
184
+ def proxy
185
+ env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
186
+
187
+ return nil if env_proxy.nil? or env_proxy.empty?
188
+
189
+ uri = URI.parse(normalize_uri(env_proxy))
190
+
191
+ if uri and uri.user.nil? and uri.password.nil? then
192
+ # Probably we have http_proxy_* variables?
193
+ uri.user = escape(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER'])
194
+ uri.password = escape(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS'])
195
+ end
196
+
197
+ uri
198
+ end
152
199
 
153
200
  #
154
201
  # Upload +yaml+ Results to +results_url+.
@@ -158,12 +205,28 @@ class Gem::Commands::TestCommand < Gem::Command
158
205
  begin
159
206
  results_url ||= config["upload_service_url"] || 'http://test.rubygems.org/test_results'
160
207
  url = URI.parse(results_url)
161
- response = Net::HTTP.post_form url, {:results => yaml}
162
- rescue Errno::ECONNREFUSED => e
163
- say 'Unable to post test results. Can\'t connect to the results server.'
164
- rescue => e
165
- say e.message
166
- else
208
+
209
+ net_http_args = [url.host, url.port]
210
+
211
+ if proxy_uri = proxy
212
+ net_http_args += [
213
+ proxy_uri.host,
214
+ proxy_uri.port,
215
+ proxy_uri.user,
216
+ proxy_uri.password
217
+ ]
218
+ end
219
+
220
+ http = Net::HTTP.new(*net_http_args)
221
+
222
+ if ENV["RG_T_DEBUG_HTTP"]
223
+ http.set_debug_output($stderr)
224
+ end
225
+
226
+ req = Net::HTTP::Post.new(url.path)
227
+ req.set_form_data({:results => yaml})
228
+ response = http.start { |x| x.request(req) }
229
+
167
230
  case response
168
231
  when Net::HTTPSuccess
169
232
  body = YAML::load(response.body)
@@ -191,6 +254,11 @@ class Gem::Commands::TestCommand < Gem::Command
191
254
  else
192
255
  say %q[Something weird happened. Probably a bug.]
193
256
  end
257
+ rescue Errno::ECONNREFUSED => e
258
+ say 'Unable to post test results. Can\'t connect to the results server.'
259
+ rescue => e
260
+ say e.message
261
+ say e.backtrace
194
262
  end
195
263
  end
196
264
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rubygems-test
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.6
5
+ version: 0.3.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Erik Hollensbe
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-02-27 00:00:00 -05:00
14
+ date: 2011-03-02 00:00:00 -05:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency