bundler 1.0.21 → 1.1.rc

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.
Files changed (90) hide show
  1. data/.travis.yml +7 -0
  2. data/CHANGELOG.md +153 -1
  3. data/README.md +3 -3
  4. data/Rakefile +15 -27
  5. data/bin/bundle +7 -0
  6. data/bundler.gemspec +1 -1
  7. data/lib/bundler/cli.rb +126 -45
  8. data/lib/bundler/definition.rb +22 -5
  9. data/lib/bundler/dep_proxy.rb +35 -0
  10. data/lib/bundler/dsl.rb +17 -34
  11. data/lib/bundler/endpoint_specification.rb +69 -0
  12. data/lib/bundler/fetcher.rb +221 -0
  13. data/lib/bundler/gem_helper.rb +0 -1
  14. data/lib/bundler/gem_helpers.rb +23 -0
  15. data/lib/bundler/index.rb +77 -38
  16. data/lib/bundler/installer.rb +43 -1
  17. data/lib/bundler/man/bundle-benchmark +19 -0
  18. data/lib/bundler/man/bundle-benchmark.txt +27 -0
  19. data/lib/bundler/man/bundle-config +1 -1
  20. data/lib/bundler/man/bundle-config.txt +3 -3
  21. data/lib/bundler/man/bundle-install +288 -0
  22. data/lib/bundler/man/bundle-install.txt +74 -79
  23. data/lib/bundler/man/bundle-package +1 -1
  24. data/lib/bundler/man/bundle-package.txt +1 -1
  25. data/lib/bundler/man/bundle-update +1 -1
  26. data/lib/bundler/man/bundle-update.txt +41 -41
  27. data/lib/bundler/man/gemfile.5 +6 -7
  28. data/lib/bundler/man/gemfile.5.txt +9 -9
  29. data/lib/bundler/match_platform.rb +13 -0
  30. data/lib/bundler/remote_specification.rb +6 -8
  31. data/lib/bundler/resolver.rb +32 -19
  32. data/lib/bundler/rubygems_ext.rb +2 -86
  33. data/lib/bundler/rubygems_integration.rb +35 -0
  34. data/lib/bundler/runtime.rb +84 -1
  35. data/lib/bundler/source.rb +85 -88
  36. data/lib/bundler/spec_set.rb +2 -0
  37. data/lib/bundler/templates/Executable +1 -1
  38. data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
  39. data/lib/bundler/templates/newgem/Rakefile.tt +1 -0
  40. data/lib/bundler/templates/newgem/bin/newgem.tt +1 -1
  41. data/lib/bundler/templates/newgem/gitignore.tt +14 -1
  42. data/lib/bundler/templates/newgem/newgem.gemspec.tt +13 -20
  43. data/lib/bundler/ui.rb +32 -17
  44. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  45. data/lib/bundler/vendor/net/http/persistent.rb +468 -0
  46. data/lib/bundler/version.rb +1 -1
  47. data/lib/bundler.rb +56 -23
  48. data/man/bundle-install.ronn +7 -0
  49. data/man/bundle.ronn +3 -0
  50. data/man/gemfile.5.ronn +6 -6
  51. data/spec/bundler/dsl_spec.rb +22 -0
  52. data/spec/bundler/source_spec.rb +25 -0
  53. data/spec/install/deprecated_spec.rb +2 -3
  54. data/spec/install/gems/dependency_api_spec.rb +358 -0
  55. data/spec/install/gems/flex_spec.rb +1 -1
  56. data/spec/install/gems/groups_spec.rb +17 -8
  57. data/spec/install/gems/platform_spec.rb +16 -0
  58. data/spec/install/gems/post_install_spec.rb +47 -0
  59. data/spec/install/gems/simple_case_spec.rb +61 -64
  60. data/spec/install/gems/standalone_spec.rb +238 -0
  61. data/spec/install/git_spec.rb +62 -0
  62. data/spec/other/check_spec.rb +30 -0
  63. data/spec/other/clean_spec.rb +397 -0
  64. data/spec/other/exec_spec.rb +0 -29
  65. data/spec/other/newgem_spec.rb +39 -0
  66. data/spec/other/outdated_spec.rb +93 -0
  67. data/spec/other/show_spec.rb +6 -0
  68. data/spec/quality_spec.rb +1 -1
  69. data/spec/realworld/edgecases_spec.rb +12 -0
  70. data/spec/runtime/executable_spec.rb +10 -0
  71. data/spec/runtime/require_spec.rb +8 -9
  72. data/spec/runtime/with_clean_env_spec.rb +60 -7
  73. data/spec/spec_helper.rb +8 -1
  74. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  75. data/spec/support/artifice/endpoint.rb +54 -0
  76. data/spec/support/artifice/endpoint_500.rb +37 -0
  77. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  78. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  79. data/spec/support/artifice/endpoint_extra.rb +27 -0
  80. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  81. data/spec/support/artifice/endpoint_fallback.rb +18 -0
  82. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  83. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  84. data/spec/support/builders.rb +7 -0
  85. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  86. data/spec/support/fakeweb/windows.rb +23 -0
  87. data/spec/support/helpers.rb +36 -3
  88. data/spec/support/path.rb +2 -0
  89. data/spec/support/rubygems_ext.rb +3 -3
  90. metadata +48 -74
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "<%= config[:name] %>"
3
+ require '<%= config[:name] %>'
@@ -1,4 +1,17 @@
1
1
  *.gem
2
+ *.rbc
2
3
  .bundle
4
+ .config
5
+ .yardoc
3
6
  Gemfile.lock
4
- pkg/*
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -1,24 +1,17 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "<%=config[:name]%>/version"
2
+ require File.expand_path('../lib/<%=config[:name]%>/version', __FILE__)
4
3
 
5
- Gem::Specification.new do |s|
6
- s.name = <%=config[:name].inspect%>
7
- s.version = <%=config[:constant_name]%>::VERSION
8
- s.authors = ["<%= config[:author_name] %>"]
9
- s.email = ["<%= config[:author_email] %>"]
10
- s.homepage = ""
11
- s.summary = %q{TODO: Write a gem summary}
12
- s.description = %q{TODO: Write a gem description}
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = [<%=config[:author].inspect%>]
6
+ gem.email = [<%=config[:email].inspect%>]
7
+ gem.description = %q{TODO: Write a gem description}
8
+ gem.summary = %q{TODO: Write a gem summary}
9
+ gem.homepage = ""
13
10
 
14
- s.rubyforge_project = <%=config[:name].inspect%>
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = <%=config[:name].inspect%>
15
+ gem.require_paths = ["lib"]
16
+ gem.version = <%=config[:constant_name]%>::VERSION
24
17
  end
data/lib/bundler/ui.rb CHANGED
@@ -2,19 +2,23 @@ require 'rubygems/user_interaction'
2
2
 
3
3
  module Bundler
4
4
  class UI
5
- def warn(message)
5
+ def warn(message, newline = nil)
6
6
  end
7
7
 
8
- def debug(message)
8
+ def debug(message, newline = nil)
9
9
  end
10
10
 
11
- def error(message)
11
+ def error(message, newline = nil)
12
12
  end
13
13
 
14
- def info(message)
14
+ def info(message, newline = nil)
15
15
  end
16
16
 
17
- def confirm(message)
17
+ def confirm(message, newline = nil)
18
+ end
19
+
20
+ def debug?
21
+ false
18
22
  end
19
23
 
20
24
  class Shell < UI
@@ -26,33 +30,44 @@ module Bundler
26
30
  @debug = ENV['DEBUG']
27
31
  end
28
32
 
29
- def debug(msg)
30
- @shell.say(msg) if @debug && !@quiet
33
+ def info(msg, newline = nil)
34
+ tell_me(msg, nil, newline) if !@quiet
31
35
  end
32
36
 
33
- def info(msg)
34
- @shell.say(msg) if !@quiet
37
+ def confirm(msg, newline = nil)
38
+ tell_me(msg, :green, newline) if !@quiet
35
39
  end
36
40
 
37
- def confirm(msg)
38
- @shell.say(msg, :green) if !@quiet
41
+ def warn(msg, newline = nil)
42
+ tell_me(msg, :yellow, newline)
39
43
  end
40
44
 
41
- def warn(msg)
42
- @shell.say(msg, :yellow)
43
- end
44
-
45
- def error(msg)
46
- @shell.say(msg, :red)
45
+ def error(msg, newline = nil)
46
+ tell_me(msg, :red, newline)
47
47
  end
48
48
 
49
49
  def be_quiet!
50
50
  @quiet = true
51
51
  end
52
52
 
53
+ def debug?
54
+ # needs to be false instead of nil to be newline param to other methods
55
+ !!@debug && !@quiet
56
+ end
57
+
53
58
  def debug!
54
59
  @debug = true
55
60
  end
61
+
62
+ def debug(msg, newline = nil)
63
+ tell_me(msg, nil, newline) if debug?
64
+ end
65
+
66
+ private
67
+ # valimism
68
+ def tell_me(msg, color = nil, newline = nil)
69
+ newline.nil? ? @shell.say(msg, color) : @shell.say(msg, color, newline)
70
+ end
56
71
  end
57
72
 
58
73
  class RGProxy < ::Gem::SilentUI
@@ -0,0 +1,27 @@
1
+ require 'net/protocol'
2
+
3
+ ##
4
+ # Aaron Patterson's monkeypatch (accepted into 1.9.1) to fix Net::HTTP's speed
5
+ # problems.
6
+ #
7
+ # http://gist.github.com/251244
8
+
9
+ class Net::BufferedIO #:nodoc:
10
+ alias :old_rbuf_fill :rbuf_fill
11
+
12
+ def rbuf_fill
13
+ if @io.respond_to? :read_nonblock then
14
+ begin
15
+ @rbuf << @io.read_nonblock(65536)
16
+ rescue Errno::EWOULDBLOCK => e
17
+ retry if IO.select [@io], nil, nil, @read_timeout
18
+ raise Timeout::Error, e.message
19
+ end
20
+ else # SSL sockets do not have read_nonblock
21
+ timeout @read_timeout do
22
+ @rbuf << @io.sysread(65536)
23
+ end
24
+ end
25
+ end
26
+ end if RUBY_VERSION < '1.9'
27
+
@@ -0,0 +1,468 @@
1
+ require 'net/http'
2
+ require 'net/http/faster'
3
+ require 'uri'
4
+ require 'cgi' # for escaping
5
+
6
+ ##
7
+ # Persistent connections for Net::HTTP
8
+ #
9
+ # Net::HTTP::Persistent maintains persistent connections across all the
10
+ # servers you wish to talk to. For each host:port you communicate with a
11
+ # single persistent connection is created.
12
+ #
13
+ # Multiple Net::HTTP::Persistent objects will share the same set of
14
+ # connections.
15
+ #
16
+ # For each thread you start a new connection will be created. A
17
+ # Net::HTTP::Persistent connection will not be shared across threads.
18
+ #
19
+ # You can shut down the HTTP connections when done by calling #shutdown. You
20
+ # should name your Net::HTTP::Persistent object if you intend to call this
21
+ # method.
22
+ #
23
+ # Example:
24
+ #
25
+ # uri = URI.parse 'http://example.com/awesome/web/service'
26
+ # http = Net::HTTP::Persistent.new
27
+ # stuff = http.request uri # performs a GET
28
+ #
29
+ # # perform a POST
30
+ # post_uri = uri + 'create'
31
+ # post = Net::HTTP::Post.new post_uri.path
32
+ # post.set_form_data 'some' => 'cool data'
33
+ # http.request post_uri, post # URI is always required
34
+
35
+ class Net::HTTP::Persistent
36
+
37
+ ##
38
+ # The version of Net::HTTP::Persistent use are using
39
+
40
+ VERSION = '1.4.1'
41
+
42
+ ##
43
+ # Error class for errors raised by Net::HTTP::Persistent. Various
44
+ # SystemCallErrors are re-raised with a human-readable message under this
45
+ # class.
46
+
47
+ class Error < StandardError; end
48
+
49
+ ##
50
+ # This client's OpenSSL::X509::Certificate
51
+
52
+ attr_accessor :certificate
53
+
54
+ ##
55
+ # An SSL certificate authority. Setting this will set verify_mode to
56
+ # VERIFY_PEER.
57
+
58
+ attr_accessor :ca_file
59
+
60
+ ##
61
+ # Where this instance's connections live in the thread local variables
62
+
63
+ attr_reader :connection_key # :nodoc:
64
+
65
+ ##
66
+ # Sends debug_output to this IO via Net::HTTP#set_debug_output.
67
+ #
68
+ # Never use this method in production code, it causes a serious security
69
+ # hole.
70
+
71
+ attr_accessor :debug_output
72
+
73
+ ##
74
+ # Headers that are added to every request
75
+
76
+ attr_reader :headers
77
+
78
+ ##
79
+ # Maps host:port to an HTTP version. This allows us to enable version
80
+ # specific features.
81
+
82
+ attr_reader :http_versions
83
+
84
+ ##
85
+ # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
86
+ # HTTP/1.1 servers.
87
+ #
88
+ # This may not work correctly for HTTP/1.0 servers
89
+ #
90
+ # This method may be removed in a future version as RFC 2616 does not
91
+ # require this header.
92
+
93
+ attr_accessor :keep_alive
94
+
95
+ ##
96
+ # A name for this connection. Allows you to keep your connections apart
97
+ # from everybody else's.
98
+
99
+ attr_reader :name
100
+
101
+ ##
102
+ # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
103
+
104
+ attr_accessor :open_timeout
105
+
106
+ ##
107
+ # This client's SSL private key
108
+
109
+ attr_accessor :private_key
110
+
111
+ ##
112
+ # The URL through which requests will be proxied
113
+
114
+ attr_reader :proxy_uri
115
+
116
+ ##
117
+ # Seconds to wait until reading one block. See Net::HTTP#read_timeout
118
+
119
+ attr_accessor :read_timeout
120
+
121
+ ##
122
+ # Where this instance's request counts live in the thread local variables
123
+
124
+ attr_reader :request_key # :nodoc:
125
+
126
+ ##
127
+ # SSL verification callback. Used when ca_file is set.
128
+
129
+ attr_accessor :verify_callback
130
+
131
+ ##
132
+ # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_NONE which ignores
133
+ # certificate problems.
134
+ #
135
+ # You can use +verify_mode+ to override any default values.
136
+
137
+ attr_accessor :verify_mode
138
+
139
+ ##
140
+ # Creates a new Net::HTTP::Persistent.
141
+ #
142
+ # Set +name+ to keep your connections apart from everybody else's. Not
143
+ # required currently, but highly recommended. Your library name should be
144
+ # good enough. This parameter will be required in a future version.
145
+ #
146
+ # +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
147
+ # the environment. See proxy_from_env for details.
148
+ #
149
+ # In order to use a URI for the proxy you'll need to do some extra work
150
+ # beyond URI.parse:
151
+ #
152
+ # proxy = URI.parse 'http://proxy.example'
153
+ # proxy.user = 'AzureDiamond'
154
+ # proxy.password = 'hunter2'
155
+
156
+ def initialize name = nil, proxy = nil
157
+ @name = name
158
+
159
+ @proxy_uri = case proxy
160
+ when :ENV then proxy_from_env
161
+ when URI::HTTP then proxy
162
+ when nil then # ignore
163
+ else raise ArgumentError, 'proxy must be :ENV or a URI::HTTP'
164
+ end
165
+
166
+ if @proxy_uri then
167
+ @proxy_args = [
168
+ @proxy_uri.host,
169
+ @proxy_uri.port,
170
+ @proxy_uri.user,
171
+ @proxy_uri.password,
172
+ ]
173
+
174
+ @proxy_connection_id = [nil, *@proxy_args].join ':'
175
+ end
176
+
177
+ @debug_output = nil
178
+ @headers = {}
179
+ @http_versions = {}
180
+ @keep_alive = 30
181
+ @open_timeout = nil
182
+ @read_timeout = nil
183
+
184
+ key = ['net_http_persistent', name, 'connections'].compact.join '_'
185
+ @connection_key = key.intern
186
+ key = ['net_http_persistent', name, 'requests'].compact.join '_'
187
+ @request_key = key.intern
188
+
189
+ @certificate = nil
190
+ @ca_file = nil
191
+ @private_key = nil
192
+ @verify_callback = nil
193
+ @verify_mode = nil
194
+ end
195
+
196
+ ##
197
+ # Creates a new connection for +uri+
198
+
199
+ def connection_for uri
200
+ Thread.current[@connection_key] ||= {}
201
+ Thread.current[@request_key] ||= Hash.new 0
202
+
203
+ connections = Thread.current[@connection_key]
204
+
205
+ net_http_args = [uri.host, uri.port]
206
+ connection_id = net_http_args.join ':'
207
+
208
+ if @proxy_uri then
209
+ connection_id << @proxy_connection_id
210
+ net_http_args.concat @proxy_args
211
+ end
212
+
213
+ unless connection = connections[connection_id] then
214
+ connections[connection_id] = Net::HTTP.new(*net_http_args)
215
+ connection = connections[connection_id]
216
+ ssl connection if uri.scheme == 'https'
217
+ end
218
+
219
+ unless connection.started? then
220
+ connection.set_debug_output @debug_output if @debug_output
221
+ connection.open_timeout = @open_timeout if @open_timeout
222
+ connection.read_timeout = @read_timeout if @read_timeout
223
+
224
+ connection.start
225
+ end
226
+
227
+ connection
228
+ rescue Errno::ECONNREFUSED
229
+ raise Error, "connection refused: #{connection.address}:#{connection.port}"
230
+ rescue Errno::EHOSTDOWN
231
+ raise Error, "host down: #{connection.address}:#{connection.port}"
232
+ end
233
+
234
+ ##
235
+ # Returns an error message containing the number of requests performed on
236
+ # this connection
237
+
238
+ def error_message connection
239
+ requests =
240
+ Thread.current[@request_key][connection.object_id]
241
+
242
+ "after #{requests} requests on #{connection.object_id}"
243
+ end
244
+
245
+ ##
246
+ # URI::escape wrapper
247
+
248
+ def escape str
249
+ CGI.escape str if str
250
+ end
251
+
252
+ ##
253
+ # Finishes the Net::HTTP +connection+
254
+
255
+ def finish connection
256
+ Thread.current[@request_key].delete connection.object_id
257
+
258
+ connection.finish
259
+ rescue IOError
260
+ end
261
+
262
+ ##
263
+ # Returns the HTTP protocol version for +uri+
264
+
265
+ def http_version uri
266
+ @http_versions["#{uri.host}:#{uri.port}"]
267
+ end
268
+
269
+ ##
270
+ # Is +req+ idempotent according to RFC 2616?
271
+
272
+ def idempotent? req
273
+ case req
274
+ when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
275
+ Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
276
+ true
277
+ end
278
+ end
279
+
280
+ ##
281
+ # Adds "http://" to the String +uri+ if it is missing.
282
+
283
+ def normalize_uri uri
284
+ (uri =~ /^https?:/) ? uri : "http://#{uri}"
285
+ end
286
+
287
+ ##
288
+ # Creates a URI for an HTTP proxy server from ENV variables.
289
+ #
290
+ # If +HTTP_PROXY+ is set a proxy will be returned.
291
+ #
292
+ # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the URI is given the
293
+ # indicated user and password unless HTTP_PROXY contains either of these in
294
+ # the URI.
295
+ #
296
+ # For Windows users lowercase ENV variables are preferred over uppercase ENV
297
+ # variables.
298
+
299
+ def proxy_from_env
300
+ env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
301
+
302
+ return nil if env_proxy.nil? or env_proxy.empty?
303
+
304
+ uri = URI.parse normalize_uri env_proxy
305
+
306
+ unless uri.user or uri.password then
307
+ uri.user = escape ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']
308
+ uri.password = escape ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS']
309
+ end
310
+
311
+ uri
312
+ end
313
+
314
+ ##
315
+ # Finishes then restarts the Net::HTTP +connection+
316
+
317
+ def reset connection
318
+ Thread.current[@request_key].delete connection.object_id
319
+
320
+ finish connection
321
+
322
+ connection.start
323
+ rescue Errno::ECONNREFUSED
324
+ raise Error, "connection refused: #{connection.address}:#{connection.port}"
325
+ rescue Errno::EHOSTDOWN
326
+ raise Error, "host down: #{connection.address}:#{connection.port}"
327
+ end
328
+
329
+ ##
330
+ # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
331
+ # against +uri+.
332
+ #
333
+ # If a block is passed #request behaves like Net::HTTP#request (the body of
334
+ # the response will not have been read).
335
+ #
336
+ # +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list).
337
+ #
338
+ # If there is an error and the request is idempontent according to RFC 2616
339
+ # it will be retried automatically.
340
+
341
+ def request uri, req = nil, &block
342
+ retried = false
343
+ bad_response = false
344
+
345
+ req = Net::HTTP::Get.new uri.request_uri unless req
346
+
347
+ headers.each do |pair|
348
+ req.add_field(*pair)
349
+ end
350
+
351
+ if uri.user or uri.password
352
+ req.basic_auth uri.user, uri.password
353
+ end
354
+
355
+ req.add_field 'Connection', 'keep-alive'
356
+ req.add_field 'Keep-Alive', @keep_alive
357
+
358
+ connection = connection_for uri
359
+ connection_id = connection.object_id
360
+
361
+ begin
362
+ Thread.current[@request_key][connection_id] += 1
363
+ response = connection.request req, &block
364
+
365
+ rescue Net::HTTPBadResponse => e
366
+ message = error_message connection
367
+
368
+ finish connection
369
+
370
+ raise Error, "too many bad responses #{message}" if
371
+ bad_response or not idempotent? req
372
+
373
+ bad_response = true
374
+ retry
375
+ rescue IOError, EOFError, Timeout::Error,
376
+ Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e
377
+
378
+ if retried or not idempotent? req
379
+ due_to = "(due to #{e.message} - #{e.class})"
380
+ message = error_message connection
381
+
382
+ finish connection
383
+
384
+ raise Error, "too many connection resets #{due_to} #{message}"
385
+ end
386
+
387
+ reset connection
388
+
389
+ retried = true
390
+ retry
391
+ end
392
+
393
+ @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
394
+
395
+ response
396
+ end
397
+
398
+ ##
399
+ # Shuts down all connections for +thread+.
400
+ #
401
+ # Uses the current thread by default.
402
+ #
403
+ # If you've used Net::HTTP::Persistent across multiple threads you should
404
+ # call this in each thread when you're done making HTTP requests.
405
+ #
406
+ # *NOTE*: Calling shutdown for another thread can be dangerous!
407
+ #
408
+ # If the thread is still using the connection it may cause an error! It is
409
+ # best to call #shutdown in the thread at the appropriate time instead!
410
+
411
+ def shutdown thread = Thread.current
412
+ connections = thread[@connection_key]
413
+
414
+ connections.each do |_, connection|
415
+ begin
416
+ connection.finish
417
+ rescue IOError
418
+ end
419
+ end if connections
420
+
421
+ thread[@connection_key] = nil
422
+ thread[@request_key] = nil
423
+ end
424
+
425
+ ##
426
+ # Shuts down all connections in all threads
427
+ #
428
+ # *NOTE*: THIS METHOD IS VERY DANGEROUS!
429
+ #
430
+ # Do not call this method if other threads are still using their
431
+ # connections! Call #shutdown at the appropriate time instead!
432
+ #
433
+ # Use this method only as a last resort!
434
+
435
+ def shutdown_in_all_threads
436
+ Thread.list.each do |thread|
437
+ shutdown thread
438
+ end
439
+
440
+ nil
441
+ end
442
+
443
+ ##
444
+ # Enables SSL on +connection+
445
+
446
+ def ssl connection
447
+ require 'net/https'
448
+ connection.use_ssl = true
449
+
450
+ # suppress warning but allow override
451
+ connection.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_mode
452
+
453
+ if @ca_file then
454
+ connection.ca_file = @ca_file
455
+ connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
456
+ connection.verify_callback = @verify_callback if @verify_callback
457
+ end
458
+
459
+ if @certificate and @private_key then
460
+ connection.cert = @certificate
461
+ connection.key = @private_key
462
+ end
463
+
464
+ connection.verify_mode = @verify_mode if @verify_mode
465
+ end
466
+
467
+ end
468
+
@@ -2,5 +2,5 @@ module Bundler
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of bundler and we are unsure how to
4
4
  # handle this better.
5
- VERSION = "1.0.21" unless defined?(::Bundler::VERSION)
5
+ VERSION = "1.1.rc" unless defined?(::Bundler::VERSION)
6
6
  end