bundler 1.0.22 → 1.1.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (114) hide show
  1. data/CHANGELOG.md +15 -181
  2. data/ISSUES.md +11 -26
  3. data/LICENSE +0 -2
  4. data/Rakefile +67 -116
  5. data/UPGRADING.md +4 -4
  6. data/bin/bundle +10 -10
  7. data/bundler.gemspec +5 -5
  8. data/lib/bundler.rb +15 -25
  9. data/lib/bundler/capistrano.rb +2 -2
  10. data/lib/bundler/cli.rb +41 -72
  11. data/lib/bundler/definition.rb +11 -37
  12. data/lib/bundler/dependency.rb +9 -13
  13. data/lib/bundler/deployment.rb +3 -8
  14. data/lib/bundler/dsl.rb +10 -24
  15. data/lib/bundler/fetcher.rb +101 -0
  16. data/lib/bundler/gem_helper.rb +6 -11
  17. data/lib/bundler/index.rb +8 -15
  18. data/lib/bundler/installer.rb +55 -35
  19. data/lib/bundler/lazy_specification.rb +7 -10
  20. data/lib/bundler/remote_specification.rb +6 -8
  21. data/lib/bundler/resolver.rb +18 -12
  22. data/lib/bundler/rubygems_ext.rb +3 -20
  23. data/lib/bundler/runtime.rb +57 -8
  24. data/lib/bundler/settings.rb +6 -4
  25. data/lib/bundler/setup.rb +5 -12
  26. data/lib/bundler/shared_helpers.rb +100 -4
  27. data/lib/bundler/source.rb +61 -106
  28. data/lib/bundler/spec_set.rb +8 -9
  29. data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
  30. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +0 -2
  31. data/lib/bundler/templates/newgem/newgem.gemspec.tt +3 -6
  32. data/lib/bundler/ui.rb +1 -4
  33. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  34. data/lib/bundler/vendor/net/http/persistent.rb +464 -0
  35. data/lib/bundler/vendor/thor.rb +4 -43
  36. data/lib/bundler/vendor/thor/actions.rb +11 -28
  37. data/lib/bundler/vendor/thor/actions/create_file.rb +2 -2
  38. data/lib/bundler/vendor/thor/actions/directory.rb +2 -2
  39. data/lib/bundler/vendor/thor/actions/empty_directory.rb +0 -0
  40. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +15 -56
  41. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +10 -15
  42. data/lib/bundler/vendor/thor/base.rb +4 -24
  43. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +0 -0
  44. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +0 -0
  45. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +0 -0
  46. data/lib/bundler/vendor/thor/error.rb +0 -0
  47. data/lib/bundler/vendor/thor/invocation.rb +0 -0
  48. data/lib/bundler/vendor/thor/parser.rb +0 -0
  49. data/lib/bundler/vendor/thor/parser/argument.rb +0 -0
  50. data/lib/bundler/vendor/thor/parser/arguments.rb +2 -2
  51. data/lib/bundler/vendor/thor/parser/option.rb +1 -1
  52. data/lib/bundler/vendor/thor/parser/options.rb +16 -17
  53. data/lib/bundler/vendor/thor/shell.rb +0 -0
  54. data/lib/bundler/vendor/thor/shell/basic.rb +13 -40
  55. data/lib/bundler/vendor/thor/shell/color.rb +0 -0
  56. data/lib/bundler/vendor/thor/task.rb +4 -3
  57. data/lib/bundler/vendor/thor/util.rb +2 -2
  58. data/lib/bundler/vendor/thor/version.rb +1 -1
  59. data/lib/bundler/version.rb +1 -1
  60. data/lib/bundler/vlad.rb +0 -2
  61. data/man/bundle-install.ronn +3 -6
  62. data/man/gemfile.5.ronn +2 -7
  63. data/spec/cache/gems_spec.rb +0 -11
  64. data/spec/cache/git_spec.rb +2 -5
  65. data/spec/install/deploy_spec.rb +8 -8
  66. data/spec/install/gems/dependency_api_spec.rb +85 -0
  67. data/spec/install/gems/flex_spec.rb +4 -4
  68. data/spec/install/gems/groups_spec.rb +3 -17
  69. data/spec/install/gems/platform_spec.rb +16 -0
  70. data/spec/install/gems/simple_case_spec.rb +24 -88
  71. data/spec/install/gems/standalone_spec.rb +162 -0
  72. data/spec/install/gems/sudo_spec.rb +2 -3
  73. data/spec/install/gemspec_spec.rb +0 -38
  74. data/spec/install/git_spec.rb +4 -3
  75. data/spec/install/invalid_spec.rb +0 -18
  76. data/spec/install/path_spec.rb +1 -53
  77. data/spec/lock/git_spec.rb +1 -1
  78. data/spec/lock/lockfile_spec.rb +16 -72
  79. data/spec/other/check_spec.rb +6 -6
  80. data/spec/other/clean_spec.rb +202 -0
  81. data/spec/other/exec_spec.rb +7 -14
  82. data/spec/other/ext_spec.rb +0 -21
  83. data/spec/{bundler → other}/gem_helper_spec.rb +1 -16
  84. data/spec/other/help_spec.rb +1 -2
  85. data/spec/other/init_spec.rb +3 -3
  86. data/spec/other/newgem_spec.rb +1 -23
  87. data/spec/pack/gems_spec.rb +22 -0
  88. data/spec/quality_spec.rb +2 -6
  89. data/spec/runtime/require_spec.rb +10 -10
  90. data/spec/runtime/setup_spec.rb +12 -54
  91. data/spec/spec_helper.rb +7 -14
  92. data/spec/support/artifice/endpoint.rb +50 -0
  93. data/spec/support/artifice/endpoint_fallback.rb +22 -0
  94. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  95. data/spec/support/artifice/endpoint_redirect.rb +11 -0
  96. data/spec/support/builders.rb +2 -25
  97. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  98. data/spec/support/fakeweb/windows.rb +23 -0
  99. data/spec/support/helpers.rb +12 -5
  100. data/spec/support/matchers.rb +16 -4
  101. data/spec/support/path.rb +2 -0
  102. data/spec/support/rubygems_ext.rb +2 -6
  103. data/spec/update/gems_spec.rb +2 -3
  104. data/spec/update/git_spec.rb +2 -2
  105. metadata +41 -24
  106. data/.travis.yml +0 -31
  107. data/lib/bundler/gem_installer.rb +0 -9
  108. data/lib/bundler/gem_tasks.rb +0 -2
  109. data/lib/bundler/rubygems_integration.rb +0 -344
  110. data/lib/bundler/vendor/thor/actions/create_link.rb +0 -57
  111. data/lib/bundler/vendor/thor/group.rb +0 -273
  112. data/lib/bundler/vendor/thor/rake_compat.rb +0 -66
  113. data/lib/bundler/vendor/thor/runner.rb +0 -309
  114. data/lib/bundler/vendored_thor.rb +0 -7
@@ -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,464 @@
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
+ req.add_field 'Connection', 'keep-alive'
352
+ req.add_field 'Keep-Alive', @keep_alive
353
+
354
+ connection = connection_for uri
355
+ connection_id = connection.object_id
356
+
357
+ begin
358
+ Thread.current[@request_key][connection_id] += 1
359
+ response = connection.request req, &block
360
+
361
+ rescue Net::HTTPBadResponse => e
362
+ message = error_message connection
363
+
364
+ finish connection
365
+
366
+ raise Error, "too many bad responses #{message}" if
367
+ bad_response or not idempotent? req
368
+
369
+ bad_response = true
370
+ retry
371
+ rescue IOError, EOFError, Timeout::Error,
372
+ Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e
373
+
374
+ if retried or not idempotent? req
375
+ due_to = "(due to #{e.message} - #{e.class})"
376
+ message = error_message connection
377
+
378
+ finish connection
379
+
380
+ raise Error, "too many connection resets #{due_to} #{message}"
381
+ end
382
+
383
+ reset connection
384
+
385
+ retried = true
386
+ retry
387
+ end
388
+
389
+ @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
390
+
391
+ response
392
+ end
393
+
394
+ ##
395
+ # Shuts down all connections for +thread+.
396
+ #
397
+ # Uses the current thread by default.
398
+ #
399
+ # If you've used Net::HTTP::Persistent across multiple threads you should
400
+ # call this in each thread when you're done making HTTP requests.
401
+ #
402
+ # *NOTE*: Calling shutdown for another thread can be dangerous!
403
+ #
404
+ # If the thread is still using the connection it may cause an error! It is
405
+ # best to call #shutdown in the thread at the appropriate time instead!
406
+
407
+ def shutdown thread = Thread.current
408
+ connections = thread[@connection_key]
409
+
410
+ connections.each do |_, connection|
411
+ begin
412
+ connection.finish
413
+ rescue IOError
414
+ end
415
+ end if connections
416
+
417
+ thread[@connection_key] = nil
418
+ thread[@request_key] = nil
419
+ end
420
+
421
+ ##
422
+ # Shuts down all connections in all threads
423
+ #
424
+ # *NOTE*: THIS METHOD IS VERY DANGEROUS!
425
+ #
426
+ # Do not call this method if other threads are still using their
427
+ # connections! Call #shutdown at the appropriate time instead!
428
+ #
429
+ # Use this method only as a last resort!
430
+
431
+ def shutdown_in_all_threads
432
+ Thread.list.each do |thread|
433
+ shutdown thread
434
+ end
435
+
436
+ nil
437
+ end
438
+
439
+ ##
440
+ # Enables SSL on +connection+
441
+
442
+ def ssl connection
443
+ require 'net/https'
444
+ connection.use_ssl = true
445
+
446
+ # suppress warning but allow override
447
+ connection.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_mode
448
+
449
+ if @ca_file then
450
+ connection.ca_file = @ca_file
451
+ connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
452
+ connection.verify_callback = @verify_callback if @verify_callback
453
+ end
454
+
455
+ if @certificate and @private_key then
456
+ connection.cert = @certificate
457
+ connection.key = @private_key
458
+ end
459
+
460
+ connection.verify_mode = @verify_mode if @verify_mode
461
+ end
462
+
463
+ end
464
+