bundler 2.0.2 → 2.1.0

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 (249) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +735 -574
  3. data/LICENSE.md +18 -19
  4. data/README.md +8 -7
  5. data/bundler.gemspec +5 -23
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +202 -87
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +179 -143
  11. data/lib/bundler/cli/add.rb +28 -16
  12. data/lib/bundler/cli/cache.rb +25 -13
  13. data/lib/bundler/cli/common.rb +10 -11
  14. data/lib/bundler/cli/config.rb +161 -86
  15. data/lib/bundler/cli/console.rb +2 -2
  16. data/lib/bundler/cli/doctor.rb +4 -4
  17. data/lib/bundler/cli/exec.rb +15 -18
  18. data/lib/bundler/cli/gem.rb +5 -5
  19. data/lib/bundler/cli/info.rb +17 -5
  20. data/lib/bundler/cli/init.rb +1 -1
  21. data/lib/bundler/cli/install.rb +3 -3
  22. data/lib/bundler/cli/issue.rb +1 -1
  23. data/lib/bundler/cli/open.rb +10 -6
  24. data/lib/bundler/cli/outdated.rb +85 -81
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +31 -11
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +8 -7
  32. data/lib/bundler/definition.rb +33 -26
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +2 -2
  35. data/lib/bundler/dsl.rb +19 -43
  36. data/lib/bundler/env.rb +6 -5
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +1 -13
  39. data/lib/bundler/fetcher.rb +16 -13
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +4 -1
  43. data/lib/bundler/fetcher/index.rb +5 -3
  44. data/lib/bundler/friendly_errors.rb +6 -7
  45. data/lib/bundler/gem_helper.rb +14 -14
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +3 -1
  51. data/lib/bundler/inline.rb +40 -30
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -4
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -3
  57. data/lib/bundler/lockfile_parser.rb +14 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/mirror.rb +3 -3
  60. data/lib/bundler/plugin.rb +29 -18
  61. data/lib/bundler/plugin/api.rb +1 -1
  62. data/lib/bundler/plugin/api/source.rb +4 -6
  63. data/lib/bundler/plugin/index.rb +10 -2
  64. data/lib/bundler/plugin/installer.rb +28 -15
  65. data/lib/bundler/psyched_yaml.rb +1 -1
  66. data/lib/bundler/remote_specification.rb +0 -2
  67. data/lib/bundler/resolver.rb +72 -24
  68. data/lib/bundler/resolver/spec_group.rb +3 -2
  69. data/lib/bundler/retry.rb +2 -2
  70. data/lib/bundler/ruby_version.rb +4 -19
  71. data/lib/bundler/rubygems_ext.rb +11 -66
  72. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  73. data/lib/bundler/rubygems_integration.rb +133 -410
  74. data/lib/bundler/runtime.rb +2 -9
  75. data/lib/bundler/settings.rb +22 -52
  76. data/lib/bundler/setup.rb +7 -13
  77. data/lib/bundler/shared_helpers.rb +46 -74
  78. data/lib/bundler/similarity_detector.rb +2 -2
  79. data/lib/bundler/source.rb +5 -5
  80. data/lib/bundler/source/git.rb +24 -17
  81. data/lib/bundler/source/git/git_proxy.rb +38 -41
  82. data/lib/bundler/source/metadata.rb +7 -2
  83. data/lib/bundler/source/path.rb +13 -8
  84. data/lib/bundler/source/rubygems.rb +14 -8
  85. data/lib/bundler/source/rubygems/remote.rb +2 -3
  86. data/lib/bundler/source_list.rb +9 -12
  87. data/lib/bundler/spec_set.rb +1 -6
  88. data/lib/bundler/stub_specification.rb +18 -30
  89. data/lib/bundler/templates/Executable.bundler +22 -13
  90. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  91. data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
  92. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  93. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -18
  94. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  95. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  96. data/lib/bundler/ui.rb +3 -3
  97. data/lib/bundler/ui/rg_proxy.rb +1 -1
  98. data/lib/bundler/ui/shell.rb +4 -8
  99. data/lib/bundler/uri_credentials_filter.rb +7 -3
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  101. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  102. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  103. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  104. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +134 -111
  105. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  120. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  121. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  122. data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
  123. data/lib/bundler/vendor/thor/lib/thor/actions.rb +17 -12
  124. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  126. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  127. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  128. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  129. data/lib/bundler/vendor/thor/lib/thor/base.rb +51 -39
  130. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  131. data/lib/bundler/vendor/thor/lib/thor/error.rb +14 -18
  132. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  133. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  134. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  135. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  136. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  137. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  138. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  139. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
  140. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  141. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -3
  142. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  143. data/lib/bundler/vendor/thor/lib/thor/runner.rb +13 -12
  144. data/lib/bundler/vendor/thor/lib/thor/shell.rb +3 -3
  145. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
  146. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
  147. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  148. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  149. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  150. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  151. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  152. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  153. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  154. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  155. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  156. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  157. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  158. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  159. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  160. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  161. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  162. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  163. data/lib/bundler/vendored_fileutils.rb +1 -6
  164. data/lib/bundler/vendored_molinillo.rb +1 -1
  165. data/lib/bundler/vendored_persistent.rb +7 -5
  166. data/lib/bundler/vendored_thor.rb +2 -2
  167. data/lib/bundler/vendored_uri.rb +4 -0
  168. data/lib/bundler/version.rb +1 -20
  169. data/lib/bundler/version_ranges.rb +51 -5
  170. data/lib/bundler/vlad.rb +3 -3
  171. data/lib/bundler/worker.rb +1 -3
  172. data/lib/bundler/yaml_serializer.rb +2 -3
  173. data/man/bundle-add.1 +10 -2
  174. data/man/bundle-add.1.txt +11 -5
  175. data/man/bundle-add.ronn +7 -1
  176. data/man/bundle-binstubs.1 +2 -2
  177. data/man/bundle-binstubs.1.txt +2 -2
  178. data/man/bundle-binstubs.ronn +1 -1
  179. data/man/bundle-cache.1 +55 -0
  180. data/man/bundle-cache.1.txt +78 -0
  181. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  182. data/man/bundle-check.1 +1 -1
  183. data/man/bundle-check.1.txt +6 -6
  184. data/man/bundle-clean.1 +1 -1
  185. data/man/bundle-clean.1.txt +1 -1
  186. data/man/bundle-config.1 +35 -35
  187. data/man/bundle-config.1.txt +65 -66
  188. data/man/bundle-config.ronn +41 -39
  189. data/man/bundle-doctor.1 +1 -1
  190. data/man/bundle-doctor.1.txt +1 -1
  191. data/man/bundle-exec.1 +2 -2
  192. data/man/bundle-exec.1.txt +2 -2
  193. data/man/bundle-exec.ronn +1 -1
  194. data/man/bundle-gem.1 +1 -1
  195. data/man/bundle-gem.1.txt +3 -3
  196. data/man/bundle-info.1 +1 -1
  197. data/man/bundle-info.1.txt +1 -1
  198. data/man/bundle-init.1 +1 -1
  199. data/man/bundle-init.1.txt +1 -1
  200. data/man/bundle-inject.1 +1 -1
  201. data/man/bundle-inject.1.txt +1 -1
  202. data/man/bundle-install.1 +8 -5
  203. data/man/bundle-install.1.txt +56 -51
  204. data/man/bundle-install.ronn +9 -4
  205. data/man/bundle-list.1 +1 -1
  206. data/man/bundle-list.1.txt +1 -1
  207. data/man/bundle-lock.1 +1 -1
  208. data/man/bundle-lock.1.txt +16 -16
  209. data/man/bundle-open.1 +1 -1
  210. data/man/bundle-open.1.txt +1 -1
  211. data/man/bundle-outdated.1 +1 -1
  212. data/man/bundle-outdated.1.txt +1 -1
  213. data/man/bundle-platform.1 +1 -1
  214. data/man/bundle-platform.1.txt +1 -1
  215. data/man/bundle-pristine.1 +1 -1
  216. data/man/bundle-pristine.1.txt +1 -1
  217. data/man/bundle-remove.1 +1 -1
  218. data/man/bundle-remove.1.txt +1 -1
  219. data/man/bundle-show.1 +1 -1
  220. data/man/bundle-show.1.txt +1 -1
  221. data/man/bundle-update.1 +4 -4
  222. data/man/bundle-update.1.txt +64 -65
  223. data/man/bundle-update.ronn +3 -3
  224. data/man/bundle-viz.1 +1 -1
  225. data/man/bundle-viz.1.txt +1 -1
  226. data/man/bundle.1 +2 -2
  227. data/man/bundle.1.txt +7 -7
  228. data/man/bundle.ronn +1 -1
  229. data/man/gemfile.5 +12 -15
  230. data/man/gemfile.5.ronn +9 -13
  231. data/man/gemfile.5.txt +103 -107
  232. data/man/index.txt +1 -1
  233. metadata +30 -120
  234. data/exe/bundle_ruby +0 -60
  235. data/lib/bundler/cli/package.rb +0 -49
  236. data/lib/bundler/compatibility_guard.rb +0 -13
  237. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  238. data/lib/bundler/ssl_certs/.document +0 -1
  239. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  240. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  241. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  242. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  243. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
  244. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  245. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  246. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  247. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  248. data/man/bundle-package.1 +0 -55
  249. data/man/bundle-package.1.txt +0 -79
@@ -62,6 +62,7 @@ module Bundler
62
62
  end
63
63
 
64
64
  def eql?(other)
65
+ return unless other.is_a?(SpecGroup)
65
66
  name.eql?(other.name) &&
66
67
  version.eql?(other.version) &&
67
68
  source.eql?(other.source)
@@ -94,10 +95,10 @@ module Bundler
94
95
  return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
95
96
  dependencies = []
96
97
  if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
97
- dependencies << DepProxy.new(Gem::Dependency.new("ruby\0", spec.required_ruby_version), platform)
98
+ dependencies << DepProxy.new(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
98
99
  end
99
100
  if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
100
- dependencies << DepProxy.new(Gem::Dependency.new("rubygems\0", spec.required_rubygems_version), platform)
101
+ dependencies << DepProxy.new(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
101
102
  end
102
103
  dependencies
103
104
  end
@@ -35,10 +35,10 @@ module Bundler
35
35
  private
36
36
 
37
37
  def run(&block)
38
- @failed = false
38
+ @failed = false
39
39
  @current_run += 1
40
40
  @result = block.call
41
- rescue => e
41
+ rescue StandardError => e
42
42
  fail_attempt(e)
43
43
  end
44
44
 
@@ -49,7 +49,7 @@ module Bundler
49
49
  ([\d.]+) # ruby version
50
50
  (?:p(-?\d+))? # optional patchlevel
51
51
  (?:\s\((\S+)\s(.+)\))? # optional engine info
52
- /xo
52
+ /xo.freeze
53
53
 
54
54
  # Returns a RubyVersion from the given string.
55
55
  # @param [String] the version string to match.
@@ -74,7 +74,7 @@ module Bundler
74
74
  @host ||= [
75
75
  RbConfig::CONFIG["host_cpu"],
76
76
  RbConfig::CONFIG["host_vendor"],
77
- RbConfig::CONFIG["host_os"]
77
+ RbConfig::CONFIG["host_os"],
78
78
  ].join("-")
79
79
  end
80
80
 
@@ -102,24 +102,9 @@ module Bundler
102
102
  end
103
103
 
104
104
  def self.system
105
- ruby_engine = if defined?(RUBY_ENGINE) && !RUBY_ENGINE.nil?
106
- RUBY_ENGINE.dup
107
- else
108
- # not defined in ruby 1.8.7
109
- "ruby"
110
- end
111
- # :sob: mocking RUBY_VERSION breaks stuff on 1.8.7
105
+ ruby_engine = RUBY_ENGINE.dup
112
106
  ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
113
- ruby_engine_version = case ruby_engine
114
- when "ruby"
115
- ruby_version
116
- when "rbx"
117
- Rubinius::VERSION.dup
118
- when "jruby"
119
- JRUBY_VERSION.dup
120
- else
121
- RUBY_ENGINE_VERSION.dup
122
- end
107
+ ruby_engine_version = RUBY_ENGINE_VERSION.dup
123
108
  patchlevel = RUBY_PATCHLEVEL.to_s
124
109
 
125
110
  @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
@@ -2,52 +2,34 @@
2
2
 
3
3
  require "pathname"
4
4
 
5
- if defined?(Gem::QuickLoader)
6
- # Gem Prelude makes me a sad panda :'(
7
- Gem::QuickLoader.load_full_rubygems_library
8
- end
9
-
10
5
  require "rubygems/specification"
11
6
 
12
- begin
13
- # Possible use in Gem::Specification#source below and require
14
- # shouldn't be deferred.
15
- require "rubygems/source"
16
- rescue LoadError
17
- # Not available before RubyGems 2.0.0, ignore
18
- nil
19
- end
7
+ # Possible use in Gem::Specification#source below and require
8
+ # shouldn't be deferred.
9
+ require "rubygems/source"
20
10
 
21
- require "bundler/match_platform"
11
+ require_relative "match_platform"
22
12
 
23
13
  module Gem
24
- @loaded_stacks = Hash.new {|h, k| h[k] = [] }
25
-
26
14
  class Specification
27
15
  attr_accessor :remote, :location, :relative_loaded_from
28
16
 
29
- if instance_methods(false).map(&:to_sym).include?(:source)
30
- remove_method :source
31
- attr_writer :source
32
- def source
33
- (defined?(@source) && @source) || Gem::Source::Installed.new
34
- end
35
- else
36
- attr_accessor :source
17
+ remove_method :source
18
+ attr_writer :source
19
+ def source
20
+ (defined?(@source) && @source) || Gem::Source::Installed.new
37
21
  end
38
22
 
39
23
  alias_method :rg_full_gem_path, :full_gem_path
40
24
  alias_method :rg_loaded_from, :loaded_from
41
25
 
42
- attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
43
-
44
26
  def full_gem_path
45
27
  # this cannot check source.is_a?(Bundler::Plugin::API::Source)
46
28
  # because that _could_ trip the autoload, and if there are unresolved
47
29
  # gems at that time, this method could be called inside another require,
48
30
  # thus raising with that constant being undefined. Better to check a method
49
31
  if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
50
- Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint
32
+ Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
51
33
  else
52
34
  rg_full_gem_path
53
35
  end
@@ -62,15 +44,7 @@ module Gem
62
44
  end
63
45
 
64
46
  def load_paths
65
- return full_require_paths if respond_to?(:full_require_paths)
66
-
67
- require_paths.map do |require_path|
68
- if require_path.include?(full_gem_path)
69
- require_path
70
- else
71
- File.join(full_gem_path, require_path)
72
- end
73
- end
47
+ full_require_paths
74
48
  end
75
49
 
76
50
  if method_defined?(:extension_dir)
@@ -84,10 +58,7 @@ module Gem
84
58
  end
85
59
  end
86
60
 
87
- # RubyGems 1.8+ used only.
88
- methods = instance_methods(false)
89
- gem_dir = methods.first.is_a?(String) ? "gem_dir" : :gem_dir
90
- remove_method :gem_dir if methods.include?(gem_dir)
61
+ remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
91
62
  def gem_dir
92
63
  full_gem_path
93
64
  end
@@ -157,32 +128,6 @@ module Gem
157
128
  end
158
129
  out
159
130
  end
160
-
161
- # Backport of performance enhancement added to RubyGems 1.4
162
- def matches_spec?(spec)
163
- # name can be a Regexp, so use ===
164
- return false unless name === spec.name
165
- return true if requirement.none?
166
-
167
- requirement.satisfied_by?(spec.version)
168
- end unless allocate.respond_to?(:matches_spec?)
169
- end
170
-
171
- class Requirement
172
- # Backport of performance enhancement added to RubyGems 1.4
173
- def none?
174
- # note that it might be tempting to replace with with RubyGems 2.0's
175
- # improved implementation. Don't. It requires `DefaultRequirement` to be
176
- # defined, and more importantantly, these overrides are not used when the
177
- # running RubyGems defines these methods
178
- to_s == ">= 0"
179
- end unless allocate.respond_to?(:none?)
180
-
181
- # Backport of performance enhancement added to RubyGems 2.2
182
- def exact?
183
- return false unless @requirements.size == 1
184
- @requirements[0][0] == "="
185
- end unless allocate.respond_to?(:exact?)
186
131
  end
187
132
 
188
133
  class Platform
@@ -66,7 +66,7 @@ module Bundler
66
66
 
67
67
  If you wish to continue installing the downloaded gem, and are certain it does not pose a \
68
68
  security issue despite the mismatching checksum, do the following:
69
- 1. run `bundle config disable_checksum_validation true` to turn off checksum verification
69
+ 1. run `bundle config set disable_checksum_validation true` to turn off checksum verification
70
70
  2. run `bundle install`
71
71
 
72
72
  (More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "monitor"
4
-
5
3
  module Bundler
6
4
  class RubygemsIntegration
7
5
  if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
8
6
  EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
9
7
  else
8
+ require "monitor"
9
+
10
10
  EXT_LOCK = Monitor.new
11
11
  end
12
12
 
@@ -20,6 +20,7 @@ module Bundler
20
20
 
21
21
  def initialize
22
22
  @replaced_methods = {}
23
+ backport_ext_builder_monitor
23
24
  end
24
25
 
25
26
  def version
@@ -38,14 +39,22 @@ module Bundler
38
39
  Gem::Command.build_args = args
39
40
  end
40
41
 
41
- def load_path_insert_index
42
- Gem.load_path_insert_index
43
- end
44
-
45
42
  def loaded_specs(name)
46
43
  Gem.loaded_specs[name]
47
44
  end
48
45
 
46
+ def add_to_load_path(paths)
47
+ return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
48
+
49
+ if insert_index = Gem.load_path_insert_index
50
+ # Gem directories must come after -I and ENV['RUBYLIB']
51
+ $LOAD_PATH.insert(insert_index, *paths)
52
+ else
53
+ # We are probably testing in core, -I and RUBYLIB don't apply
54
+ $LOAD_PATH.unshift(*paths)
55
+ end
56
+ end
57
+
49
58
  def mark_loaded(spec)
50
59
  if spec.respond_to?(:activated=)
51
60
  current = Gem.loaded_specs[spec.name]
@@ -110,7 +119,7 @@ module Bundler
110
119
  end
111
120
 
112
121
  def configuration
113
- require "bundler/psyched_yaml"
122
+ require_relative "psyched_yaml"
114
123
  Gem.configuration
115
124
  rescue Gem::SystemExitException, LoadError => e
116
125
  Bundler.ui.error "#{e.class}: #{e.message}"
@@ -130,10 +139,20 @@ module Bundler
130
139
  end
131
140
 
132
141
  def inflate(obj)
133
- if defined?(Gem::Util)
134
- Gem::Util.inflate(obj)
142
+ require "rubygems/util"
143
+
144
+ Gem::Util.inflate(obj)
145
+ end
146
+
147
+ def correct_for_windows_path(path)
148
+ require "rubygems/util"
149
+
150
+ if Gem::Util.respond_to?(:correct_for_windows_path)
151
+ Gem::Util.correct_for_windows_path(path)
152
+ elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
153
+ path[1..-1]
135
154
  else
136
- Gem.inflate(obj)
155
+ path
137
156
  end
138
157
  end
139
158
 
@@ -194,14 +213,6 @@ module Bundler
194
213
  Gem::MARSHAL_SPEC_DIR
195
214
  end
196
215
 
197
- def config_map
198
- Gem::ConfigMap
199
- end
200
-
201
- def repository_subdirectories
202
- %w[cache doc gems specifications]
203
- end
204
-
205
216
  def clear_paths
206
217
  Gem.clear_paths
207
218
  end
@@ -210,26 +221,14 @@ module Bundler
210
221
  Gem.bin_path(gem, bin, ver)
211
222
  end
212
223
 
213
- def path_separator
214
- File::PATH_SEPARATOR
215
- end
216
-
217
224
  def preserve_paths
218
225
  # this is a no-op outside of RubyGems 1.8
219
226
  yield
220
227
  end
221
228
 
222
229
  def loaded_gem_paths
223
- # RubyGems 2.2+ can put binary extension into dedicated folders,
224
- # therefore use RubyGems facilities to obtain their load paths.
225
- if Gem::Specification.method_defined? :full_require_paths
226
- loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
227
- loaded_gem_paths.flatten
228
- else
229
- $LOAD_PATH.select do |p|
230
- Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
231
- end
232
- end
230
+ loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
231
+ loaded_gem_paths.flatten
233
232
  end
234
233
 
235
234
  def load_plugins
@@ -248,36 +247,6 @@ module Bundler
248
247
  EXT_LOCK
249
248
  end
250
249
 
251
- def fetch_specs(all, pre, &blk)
252
- require "rubygems/spec_fetcher"
253
- specs = Gem::SpecFetcher.new.list(all, pre)
254
- specs.each { yield } if block_given?
255
- specs
256
- end
257
-
258
- def fetch_prerelease_specs
259
- fetch_specs(false, true)
260
- rescue Gem::RemoteFetcher::FetchError
261
- {} # if we can't download them, there aren't any
262
- end
263
-
264
- # TODO: This is for older versions of RubyGems... should we support the
265
- # X-Gemfile-Source header on these old versions?
266
- # Maybe the newer implementation will work on older RubyGems?
267
- # It seems difficult to keep this implementation and still send the header.
268
- def fetch_all_remote_specs(remote)
269
- old_sources = Bundler.rubygems.sources
270
- Bundler.rubygems.sources = [remote.uri.to_s]
271
- # Fetch all specs, minus prerelease specs
272
- spec_list = fetch_specs(true, false)
273
- # Then fetch the prerelease specs
274
- fetch_prerelease_specs.each {|k, v| spec_list[k].concat(v) }
275
-
276
- spec_list.values.first
277
- ensure
278
- Bundler.rubygems.sources = old_sources
279
- end
280
-
281
250
  def with_build_args(args)
282
251
  ext_lock.synchronize do
283
252
  old_args = build_args
@@ -290,22 +259,13 @@ module Bundler
290
259
  end
291
260
  end
292
261
 
293
- def install_with_build_args(args)
294
- with_build_args(args) { yield }
295
- end
296
-
297
- def gem_from_path(path, policy = nil)
298
- require "rubygems/format"
299
- Gem::Format.from_file_by_path(path, policy)
300
- end
301
-
302
262
  def spec_from_gem(path, policy = nil)
303
263
  require "rubygems/security"
304
- require "bundler/psyched_yaml"
264
+ require_relative "psyched_yaml"
305
265
  gem_from_path(path, security_policies[policy]).spec
306
266
  rescue Gem::Package::FormatError
307
267
  raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
308
- rescue Exception, Gem::Exception, Gem::Security::Exception => e
268
+ rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
309
269
  if e.is_a?(Gem::Security::Exception) ||
310
270
  e.message =~ /unknown trust policy|unsigned gem/i ||
311
271
  e.message =~ /couldn't verify (meta)?data signature/i
@@ -317,23 +277,10 @@ module Bundler
317
277
  end
318
278
  end
319
279
 
320
- def build(spec, skip_validation = false)
321
- require "rubygems/builder"
322
- Gem::Builder.new(spec).build
323
- end
324
-
325
280
  def build_gem(gem_dir, spec)
326
281
  build(spec)
327
282
  end
328
283
 
329
- def download_gem(spec, uri, path)
330
- uri = Bundler.settings.mirror_for(uri)
331
- fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
332
- Bundler::Retry.new("download gem from #{uri}").attempts do
333
- fetcher.download(spec, uri, path)
334
- end
335
- end
336
-
337
284
  def security_policy_keys
338
285
  %w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
339
286
  end
@@ -357,14 +304,6 @@ module Bundler
357
304
  end
358
305
  end
359
306
 
360
- def binstubs_call_gem?
361
- true
362
- end
363
-
364
- def stubs_provide_full_functionality?
365
- false
366
- end
367
-
368
307
  def replace_gem(specs, specs_by_name)
369
308
  reverse_rubygems_kernel_mixin
370
309
 
@@ -373,7 +312,6 @@ module Bundler
373
312
  kernel = (class << ::Kernel; self; end)
374
313
  [kernel, ::Kernel].each do |kernel_class|
375
314
  redefine_method(kernel_class, :gem) do |dep, *reqs|
376
- executables ||= specs.map(&:executables).flatten if ::Bundler.rubygems.binstubs_call_gem?
377
315
  if executables && executables.include?(File.basename(caller.first.split(":").first))
378
316
  break
379
317
  end
@@ -411,63 +349,45 @@ module Bundler
411
349
  end
412
350
  end
413
351
 
414
- def stub_source_index(specs)
415
- Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
416
- redefine_method(Gem::SourceIndex, :initialize) do |*args|
417
- @gems = {}
418
- # You're looking at this thinking: Oh! This is how I make those
419
- # rubygems deprecations go away!
420
- #
421
- # You'd be correct BUT using of this method in production code
422
- # must be approved by the rubygems team itself!
423
- #
424
- # This is your warning. If you use this and don't have approval
425
- # we can't protect you.
426
- #
427
- Deprecate.skip_during do
428
- self.spec_dirs = *args
429
- add_specs(*specs)
430
- end
431
- end
432
- end
433
-
434
352
  # Used to make bin stubs that are not created by bundler work
435
353
  # under bundler. The new Gem.bin_path only considers gems in
436
354
  # +specs+
437
- def replace_bin_path(specs, specs_by_name)
355
+ def replace_bin_path(specs_by_name)
438
356
  gem_class = (class << Gem; self; end)
439
357
 
440
358
  redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
441
359
  exec_name = args.first
360
+ raise ArgumentError, "you must supply exec_name" unless exec_name
442
361
 
443
362
  spec_with_name = specs_by_name[gem_name]
444
- spec = if exec_name
445
- if spec_with_name && spec_with_name.executables.include?(exec_name)
446
- spec_with_name
447
- else
448
- specs.find {|s| s.executables.include?(exec_name) }
449
- end
450
- else
451
- spec_with_name
452
- end
363
+ matching_specs_by_exec_name = specs_by_name.values.select {|s| s.executables.include?(exec_name) }
364
+ spec = matching_specs_by_exec_name.delete(spec_with_name)
453
365
 
454
- unless spec
366
+ unless spec || !matching_specs_by_exec_name.empty?
455
367
  message = "can't find executable #{exec_name} for gem #{gem_name}"
456
- if !exec_name || spec_with_name.nil?
368
+ if spec_with_name.nil?
457
369
  message += ". #{gem_name} is not currently included in the bundle, " \
458
370
  "perhaps you meant to add it to your #{Bundler.default_gemfile.basename}?"
459
371
  end
460
372
  raise Gem::Exception, message
461
373
  end
462
374
 
463
- raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable
464
-
465
- unless spec.name == gem_name
466
- Bundler::SharedHelpers.major_deprecation 3,
375
+ unless spec
376
+ spec = matching_specs_by_exec_name.shift
377
+ warn \
467
378
  "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
468
379
  "You should run `bundle binstub #{gem_name}` " \
469
380
  "to work around a system/bundle conflict."
470
381
  end
382
+
383
+ unless matching_specs_by_exec_name.empty?
384
+ conflicting_names = matching_specs_by_exec_name.map(&:name).join(", ")
385
+ warn \
386
+ "The `#{exec_name}` executable in the `#{spec.name}` gem is being loaded, but it's also present in other gems (#{conflicting_names}).\n" \
387
+ "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
388
+ "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
389
+ end
390
+
471
391
  spec
472
392
  end
473
393
 
@@ -497,13 +417,6 @@ module Bundler
497
417
  end
498
418
  end
499
419
 
500
- # Because Bundler has a static view of what specs are available,
501
- # we don't #refresh, so stub it out.
502
- def replace_refresh
503
- gem_class = (class << Gem; self; end)
504
- redefine_method(gem_class, :refresh) {}
505
- end
506
-
507
420
  # Replace or hook into RubyGems to provide a bundlerized view
508
421
  # of the world.
509
422
  def replace_entrypoints(specs)
@@ -523,31 +436,11 @@ module Bundler
523
436
 
524
437
  replace_gem(specs, specs_by_name)
525
438
  stub_rubygems(specs)
526
- replace_bin_path(specs, specs_by_name)
527
- replace_refresh
439
+ replace_bin_path(specs_by_name)
528
440
 
529
441
  Gem.clear_paths
530
442
  end
531
443
 
532
- # This backports the correct segment generation code from RubyGems 1.4+
533
- # by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7.
534
- def backport_segment_generation
535
- redefine_method(Gem::Version, :segments) do
536
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
537
- /^\d+$/ =~ s ? s.to_i : s
538
- end
539
- end
540
- end
541
-
542
- # This backport fixes the marshaling of @segments.
543
- def backport_yaml_initialize
544
- redefine_method(Gem::Version, :yaml_initialize) do |_, map|
545
- @version = map["version"]
546
- @segments = nil
547
- @hash = nil
548
- end
549
- end
550
-
551
444
  # This backports base_dir which replaces installation path
552
445
  # RubyGems 1.8+
553
446
  def backport_base_dir
@@ -620,296 +513,126 @@ module Bundler
620
513
  end
621
514
  end
622
515
 
623
- # RubyGems 1.4 through 1.6
624
- class Legacy < RubygemsIntegration
625
- def initialize
626
- super
627
- backport_base_dir
628
- backport_cache_file
629
- backport_spec_file
630
- backport_yaml_initialize
631
- end
632
-
633
- def stub_rubygems(specs)
634
- # RubyGems versions lower than 1.7 use SourceIndex#from_gems_in
635
- source_index_class = (class << Gem::SourceIndex; self; end)
636
- redefine_method(source_index_class, :from_gems_in) do |*args|
637
- Gem::SourceIndex.new.tap do |source_index|
638
- source_index.spec_dirs = *args
639
- source_index.add_specs(*specs)
640
- end
641
- end
642
- end
643
-
644
- def all_specs
645
- Gem.source_index.gems.values
646
- end
647
-
648
- def find_name(name)
649
- Gem.source_index.find_name(name)
650
- end
516
+ def stub_rubygems(specs)
517
+ Gem::Specification.all = specs
651
518
 
652
- def validate(spec)
653
- # These versions of RubyGems always validate in "packaging" mode,
654
- # which is too strict for the kinds of checks we care about. As a
655
- # result, validation is disabled on versions of RubyGems below 1.7.
519
+ Gem.post_reset do
520
+ Gem::Specification.all = specs
656
521
  end
657
522
 
658
- def post_reset_hooks
523
+ redefine_method((class << Gem; self; end), :finish_resolve) do |*|
659
524
  []
660
525
  end
661
-
662
- def reset
663
- end
664
526
  end
665
527
 
666
- # RubyGems versions 1.3.6 and 1.3.7
667
- class Ancient < Legacy
668
- def initialize
669
- super
670
- backport_segment_generation
671
- end
528
+ def fetch_specs(remote, name)
529
+ path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
530
+ fetcher = gem_remote_fetcher
531
+ fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
532
+ string = fetcher.fetch_path(path)
533
+ Bundler.load_marshal(string)
534
+ rescue Gem::RemoteFetcher::FetchError => e
535
+ # it's okay for prerelease to fail
536
+ raise e unless name == "prerelease_specs"
672
537
  end
673
538
 
674
- # RubyGems 1.7
675
- class Transitional < Legacy
676
- def stub_rubygems(specs)
677
- stub_source_index(specs)
678
- end
539
+ def fetch_all_remote_specs(remote)
540
+ specs = fetch_specs(remote, "specs")
541
+ pres = fetch_specs(remote, "prerelease_specs") || []
679
542
 
680
- def validate(spec)
681
- # Missing summary is downgraded to a warning in later versions,
682
- # so we set it to an empty string to prevent an exception here.
683
- spec.summary ||= ""
684
- RubygemsIntegration.instance_method(:validate).bind(self).call(spec)
685
- end
543
+ specs.concat(pres)
686
544
  end
687
545
 
688
- # RubyGems 1.8.5-1.8.19
689
- class Modern < RubygemsIntegration
690
- def stub_rubygems(specs)
691
- Gem::Specification.all = specs
692
-
693
- Gem.post_reset do
694
- Gem::Specification.all = specs
695
- end
696
-
697
- stub_source_index(specs)
698
- end
699
-
700
- def all_specs
701
- Gem::Specification.to_a
702
- end
703
-
704
- def find_name(name)
705
- Gem::Specification.find_all_by_name name
546
+ def download_gem(spec, uri, path)
547
+ uri = Bundler.settings.mirror_for(uri)
548
+ fetcher = gem_remote_fetcher
549
+ fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
550
+ Bundler::Retry.new("download gem from #{uri}").attempts do
551
+ fetcher.download(spec, uri, path)
706
552
  end
707
553
  end
708
554
 
709
- # RubyGems 1.8.0 to 1.8.4
710
- class AlmostModern < Modern
711
- # RubyGems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
712
- # you call Gem::Installer#install with an :install_dir set. We have to
713
- # change it back for our sudo mode to work.
714
- def preserve_paths
715
- old_dir = gem_dir
716
- old_path = gem_path
717
- yield
718
- Gem.use_paths(old_dir, old_path)
719
- end
555
+ def gem_remote_fetcher
556
+ require "resolv"
557
+ proxy = configuration[:http_proxy]
558
+ dns = Resolv::DNS.new
559
+ Gem::RemoteFetcher.new(proxy, dns)
720
560
  end
721
561
 
722
- # RubyGems 1.8.20+
723
- class MoreModern < Modern
724
- # RubyGems 1.8.20 and adds the skip_validation parameter, so that's
725
- # when we start passing it through.
726
- def build(spec, skip_validation = false)
727
- require "rubygems/builder"
728
- Gem::Builder.new(spec).build(skip_validation)
729
- end
562
+ def gem_from_path(path, policy = nil)
563
+ require "rubygems/package"
564
+ p = Gem::Package.new(path)
565
+ p.security_policy = policy if policy
566
+ p
730
567
  end
731
568
 
732
- # RubyGems 2.0
733
- class Future < RubygemsIntegration
734
- def stub_rubygems(specs)
735
- Gem::Specification.all = specs
736
-
737
- Gem.post_reset do
738
- Gem::Specification.all = specs
739
- end
740
-
741
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
742
- []
743
- end
744
- end
745
-
746
- def all_specs
747
- Gem::Specification.to_a
748
- end
749
-
750
- def find_name(name)
751
- Gem::Specification.find_all_by_name name
752
- end
753
-
754
- def fetch_specs(source, remote, name)
755
- path = source + "#{name}.#{Gem.marshal_version}.gz"
756
- fetcher = gem_remote_fetcher
757
- fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
758
- string = fetcher.fetch_path(path)
759
- Bundler.load_marshal(string)
760
- rescue Gem::RemoteFetcher::FetchError => e
761
- # it's okay for prerelease to fail
762
- raise e unless name == "prerelease_specs"
763
- end
764
-
765
- def fetch_all_remote_specs(remote)
766
- source = remote.uri.is_a?(URI) ? remote.uri : URI.parse(source.to_s)
767
-
768
- specs = fetch_specs(source, remote, "specs")
769
- pres = fetch_specs(source, remote, "prerelease_specs") || []
770
-
771
- specs.concat(pres)
772
- end
773
-
774
- def download_gem(spec, uri, path)
775
- uri = Bundler.settings.mirror_for(uri)
776
- fetcher = gem_remote_fetcher
777
- fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
778
- Bundler::Retry.new("download gem from #{uri}").attempts do
779
- fetcher.download(spec, uri, path)
780
- end
781
- end
782
-
783
- def gem_remote_fetcher
784
- require "resolv"
785
- proxy = configuration[:http_proxy]
786
- dns = Resolv::DNS.new
787
- Bundler::GemRemoteFetcher.new(proxy, dns)
788
- end
789
-
790
- def gem_from_path(path, policy = nil)
791
- require "rubygems/package"
792
- p = Gem::Package.new(path)
793
- p.security_policy = policy if policy
794
- p
795
- end
796
-
797
- def build(spec, skip_validation = false)
798
- require "rubygems/package"
799
- Gem::Package.build(spec, skip_validation)
800
- end
569
+ def build(spec, skip_validation = false)
570
+ require "rubygems/package"
571
+ Gem::Package.build(spec, skip_validation)
572
+ end
801
573
 
802
- def repository_subdirectories
803
- Gem::REPOSITORY_SUBDIRECTORIES
804
- end
574
+ def repository_subdirectories
575
+ Gem::REPOSITORY_SUBDIRECTORIES
576
+ end
805
577
 
806
- def install_with_build_args(args)
807
- yield
808
- end
578
+ def install_with_build_args(args)
579
+ yield
580
+ end
809
581
 
810
- def path_separator
811
- Gem.path_separator
812
- end
582
+ def path_separator
583
+ Gem.path_separator
813
584
  end
814
585
 
815
- # RubyGems 2.1.0
816
- class MoreFuture < Future
817
- def initialize
818
- super
819
- backport_ext_builder_monitor
586
+ def all_specs
587
+ require_relative "remote_specification"
588
+ Gem::Specification.stubs.map do |stub|
589
+ StubSpecification.from_stub(stub)
820
590
  end
591
+ end
821
592
 
822
- def all_specs
823
- require "bundler/remote_specification"
824
- Gem::Specification.stubs.map do |stub|
825
- StubSpecification.from_stub(stub)
593
+ def backport_ext_builder_monitor
594
+ # So we can avoid requiring "rubygems/ext" in its entirety
595
+ Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
596
+ module Ext
826
597
  end
827
- end
828
-
829
- def backport_ext_builder_monitor
830
- # So we can avoid requiring "rubygems/ext" in its entirety
831
- Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
832
- module Ext
833
- end
834
- RB
598
+ RB
835
599
 
836
- require "rubygems/ext/builder"
600
+ require "rubygems/ext/builder"
837
601
 
838
- Gem::Ext::Builder.class_eval do
839
- unless const_defined?(:CHDIR_MONITOR)
840
- const_set(:CHDIR_MONITOR, EXT_LOCK)
841
- end
842
-
843
- remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
844
- const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
602
+ Gem::Ext::Builder.class_eval do
603
+ unless const_defined?(:CHDIR_MONITOR)
604
+ const_set(:CHDIR_MONITOR, EXT_LOCK)
845
605
  end
846
- end
847
606
 
848
- if Gem::Specification.respond_to?(:stubs_for)
849
- def find_name(name)
850
- Gem::Specification.stubs_for(name).map(&:to_spec)
851
- end
852
- else
853
- def find_name(name)
854
- Gem::Specification.stubs.find_all do |spec|
855
- spec.name == name
856
- end.map(&:to_spec)
857
- end
607
+ remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
608
+ const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
858
609
  end
610
+ end
859
611
 
860
- if Gem::Specification.respond_to?(:default_stubs)
861
- def default_stubs
862
- Gem::Specification.default_stubs("*.gemspec")
863
- end
864
- else
865
- def default_stubs
866
- Gem::Specification.send(:default_stubs, "*.gemspec")
867
- end
868
- end
612
+ def find_name(name)
613
+ Gem::Specification.stubs_for(name).map(&:to_spec)
614
+ end
869
615
 
870
- def use_gemdeps(gemfile)
871
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
872
- require "bundler/gemdeps"
873
- runtime = Bundler.setup
874
- Bundler.ui = nil
875
- activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
876
- [Gemdeps.new(runtime), activated_spec_names]
616
+ if Gem::Specification.respond_to?(:default_stubs)
617
+ def default_stubs
618
+ Gem::Specification.default_stubs("*.gemspec")
877
619
  end
878
-
879
- if provides?(">= 2.5.2")
880
- # RubyGems-generated binstubs call Kernel#gem
881
- def binstubs_call_gem?
882
- false
883
- end
884
-
885
- # only 2.5.2+ has all of the stub methods we want to use, and since this
886
- # is a performance optimization _only_,
887
- # we'll restrict ourselves to the most
888
- # recent RG versions instead of all versions that have stubs
889
- def stubs_provide_full_functionality?
890
- true
891
- end
620
+ else
621
+ def default_stubs
622
+ Gem::Specification.send(:default_stubs, "*.gemspec")
892
623
  end
893
624
  end
625
+
626
+ def use_gemdeps(gemfile)
627
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
628
+ require_relative "gemdeps"
629
+ runtime = Bundler.setup
630
+ activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
631
+ [Gemdeps.new(runtime), activated_spec_names]
632
+ end
894
633
  end
895
634
 
896
635
  def self.rubygems
897
- @rubygems ||= if RubygemsIntegration.provides?(">= 2.1.0")
898
- RubygemsIntegration::MoreFuture.new
899
- elsif RubygemsIntegration.provides?(">= 1.99.99")
900
- RubygemsIntegration::Future.new
901
- elsif RubygemsIntegration.provides?(">= 1.8.20")
902
- RubygemsIntegration::MoreModern.new
903
- elsif RubygemsIntegration.provides?(">= 1.8.5")
904
- RubygemsIntegration::Modern.new
905
- elsif RubygemsIntegration.provides?(">= 1.8.0")
906
- RubygemsIntegration::AlmostModern.new
907
- elsif RubygemsIntegration.provides?(">= 1.7.0")
908
- RubygemsIntegration::Transitional.new
909
- elsif RubygemsIntegration.provides?(">= 1.4.0")
910
- RubygemsIntegration::Legacy.new
911
- else # RubyGems 1.3.6 and 1.3.7
912
- RubygemsIntegration::Ancient.new
913
- end
636
+ @rubygems ||= RubygemsIntegration.new
914
637
  end
915
638
  end