bundler 1.7.15 → 1.8.0.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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -14
  3. data/.rspec +1 -0
  4. data/.travis.yml +22 -15
  5. data/CHANGELOG.md +43 -13
  6. data/CODE_OF_CONDUCT.md +40 -0
  7. data/CONTRIBUTING.md +14 -12
  8. data/DEVELOPMENT.md +4 -2
  9. data/ISSUES.md +1 -1
  10. data/README.md +10 -14
  11. data/Rakefile +10 -10
  12. data/bin/bundle +1 -1
  13. data/bundler.gemspec +5 -4
  14. data/lib/bundler.rb +22 -3
  15. data/lib/bundler/anonymizable_uri.rb +24 -8
  16. data/lib/bundler/cli.rb +103 -66
  17. data/lib/bundler/cli/cache.rb +1 -0
  18. data/lib/bundler/cli/clean.rb +11 -4
  19. data/lib/bundler/cli/common.rb +2 -0
  20. data/lib/bundler/cli/console.rb +22 -26
  21. data/lib/bundler/cli/exec.rb +29 -22
  22. data/lib/bundler/cli/gem.rb +125 -37
  23. data/lib/bundler/cli/install.rb +22 -9
  24. data/lib/bundler/cli/outdated.rb +1 -1
  25. data/lib/bundler/cli/package.rb +8 -1
  26. data/lib/bundler/cli/show.rb +29 -3
  27. data/lib/bundler/cli/update.rb +2 -2
  28. data/lib/bundler/cli/viz.rb +1 -1
  29. data/lib/bundler/definition.rb +14 -22
  30. data/lib/bundler/dependency.rb +8 -1
  31. data/lib/bundler/dsl.rb +17 -4
  32. data/lib/bundler/endpoint_specification.rb +1 -1
  33. data/lib/bundler/env.rb +44 -25
  34. data/lib/bundler/fetcher.rb +33 -25
  35. data/lib/bundler/friendly_errors.rb +38 -5
  36. data/lib/bundler/gem_helper.rb +16 -10
  37. data/lib/bundler/gem_helpers.rb +1 -0
  38. data/lib/bundler/graph.rb +4 -1
  39. data/lib/bundler/index.rb +15 -25
  40. data/lib/bundler/installer.rb +6 -6
  41. data/lib/bundler/lockfile_parser.rb +7 -7
  42. data/lib/bundler/resolver.rb +2 -1
  43. data/lib/bundler/ruby_version.rb +1 -1
  44. data/lib/bundler/rubygems_ext.rb +1 -0
  45. data/lib/bundler/rubygems_integration.rb +1 -1
  46. data/lib/bundler/runtime.rb +22 -40
  47. data/lib/bundler/settings.rb +14 -5
  48. data/lib/bundler/setup.rb +2 -1
  49. data/lib/bundler/shared_helpers.rb +56 -4
  50. data/lib/bundler/source.rb +8 -9
  51. data/lib/bundler/source/git.rb +5 -1
  52. data/lib/bundler/source/git/git_proxy.rb +4 -0
  53. data/lib/bundler/source/path.rb +8 -11
  54. data/lib/bundler/source/path/installer.rb +0 -2
  55. data/lib/bundler/source/rubygems.rb +58 -72
  56. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +13 -0
  57. data/lib/bundler/templates/newgem/LICENSE.txt.tt +17 -18
  58. data/lib/bundler/templates/newgem/README.md.tt +9 -1
  59. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  60. data/lib/bundler/templates/newgem/bin/console.tt +14 -0
  61. data/lib/bundler/templates/newgem/bin/setup.tt +7 -0
  62. data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  63. data/lib/bundler/templates/newgem/gitignore.tt +2 -0
  64. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +1 -1
  65. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -13
  66. data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +1 -1
  67. data/lib/bundler/ui/shell.rb +1 -1
  68. data/lib/bundler/version.rb +1 -1
  69. data/lib/bundler/worker.rb +73 -0
  70. data/man/bundle-config.ronn +17 -15
  71. data/man/bundle-install.ronn +102 -93
  72. data/man/bundle-update.ronn +39 -30
  73. data/man/bundle.ronn +6 -0
  74. data/man/gemfile.5.ronn +74 -13
  75. metadata +10 -231
  76. data/lib/bundler/parallel_workers.rb +0 -18
  77. data/lib/bundler/parallel_workers/thread_worker.rb +0 -30
  78. data/lib/bundler/parallel_workers/unix_worker.rb +0 -101
  79. data/lib/bundler/parallel_workers/worker.rb +0 -69
  80. data/lib/bundler/templates/newgem/bin/newgem.tt +0 -3
  81. data/spec/bundler/anonymizable_uri_spec.rb +0 -32
  82. data/spec/bundler/bundler_spec.rb +0 -72
  83. data/spec/bundler/cli_spec.rb +0 -16
  84. data/spec/bundler/definition_spec.rb +0 -22
  85. data/spec/bundler/dsl_spec.rb +0 -82
  86. data/spec/bundler/friendly_errors_spec.rb +0 -13
  87. data/spec/bundler/gem_helper_spec.rb +0 -226
  88. data/spec/bundler/psyched_yaml_spec.rb +0 -8
  89. data/spec/bundler/retry_spec.rb +0 -59
  90. data/spec/bundler/settings_spec.rb +0 -13
  91. data/spec/bundler/source/rubygems_spec.rb +0 -25
  92. data/spec/bundler/source_list_spec.rb +0 -361
  93. data/spec/cache/gems_spec.rb +0 -284
  94. data/spec/cache/git_spec.rb +0 -188
  95. data/spec/cache/path_spec.rb +0 -121
  96. data/spec/cache/platform_spec.rb +0 -57
  97. data/spec/commands/binstubs_spec.rb +0 -219
  98. data/spec/commands/check_spec.rb +0 -278
  99. data/spec/commands/clean_spec.rb +0 -592
  100. data/spec/commands/config_spec.rb +0 -263
  101. data/spec/commands/console_spec.rb +0 -76
  102. data/spec/commands/exec_spec.rb +0 -309
  103. data/spec/commands/help_spec.rb +0 -39
  104. data/spec/commands/init_spec.rb +0 -39
  105. data/spec/commands/inject_spec.rb +0 -78
  106. data/spec/commands/licenses_spec.rb +0 -18
  107. data/spec/commands/newgem_spec.rb +0 -428
  108. data/spec/commands/open_spec.rb +0 -68
  109. data/spec/commands/outdated_spec.rb +0 -156
  110. data/spec/commands/package_spec.rb +0 -114
  111. data/spec/commands/show_spec.rb +0 -125
  112. data/spec/install/binstubs_spec.rb +0 -24
  113. data/spec/install/bundler_spec.rb +0 -146
  114. data/spec/install/deploy_spec.rb +0 -250
  115. data/spec/install/gemfile/gemspec_spec.rb +0 -170
  116. data/spec/install/gemfile/git_spec.rb +0 -967
  117. data/spec/install/gemfile/path_spec.rb +0 -500
  118. data/spec/install/gemfile_spec.rb +0 -44
  119. data/spec/install/gems/c_ext_spec.rb +0 -48
  120. data/spec/install/gems/dependency_api_spec.rb +0 -652
  121. data/spec/install/gems/env_spec.rb +0 -107
  122. data/spec/install/gems/flex_spec.rb +0 -314
  123. data/spec/install/gems/groups_spec.rb +0 -308
  124. data/spec/install/gems/mirror_spec.rb +0 -39
  125. data/spec/install/gems/platform_spec.rb +0 -195
  126. data/spec/install/gems/post_install_spec.rb +0 -121
  127. data/spec/install/gems/resolving_spec.rb +0 -124
  128. data/spec/install/gems/simple_case_spec.rb +0 -377
  129. data/spec/install/gems/sources_spec.rb +0 -386
  130. data/spec/install/gems/standalone_spec.rb +0 -260
  131. data/spec/install/gems/sudo_spec.rb +0 -136
  132. data/spec/install/gems/win32_spec.rb +0 -26
  133. data/spec/install/gemspecs_spec.rb +0 -50
  134. data/spec/install/path_spec.rb +0 -150
  135. data/spec/install/post_bundle_message_spec.rb +0 -142
  136. data/spec/install/prereleases_spec.rb +0 -43
  137. data/spec/install/security_policy_spec.rb +0 -77
  138. data/spec/install/upgrade_spec.rb +0 -26
  139. data/spec/lock/git_spec.rb +0 -34
  140. data/spec/lock/lockfile_spec.rb +0 -924
  141. data/spec/other/bundle_ruby_spec.rb +0 -142
  142. data/spec/other/cli_dispatch_spec.rb +0 -21
  143. data/spec/other/ext_spec.rb +0 -60
  144. data/spec/other/platform_spec.rb +0 -1285
  145. data/spec/other/ssl_cert_spec.rb +0 -23
  146. data/spec/quality_spec.rb +0 -88
  147. data/spec/realworld/dependency_api_spec.rb +0 -60
  148. data/spec/realworld/edgecases_spec.rb +0 -212
  149. data/spec/realworld/parallel_spec.rb +0 -71
  150. data/spec/resolver/basic_spec.rb +0 -66
  151. data/spec/resolver/platform_spec.rb +0 -88
  152. data/spec/runtime/executable_spec.rb +0 -149
  153. data/spec/runtime/load_spec.rb +0 -107
  154. data/spec/runtime/platform_spec.rb +0 -90
  155. data/spec/runtime/require_spec.rb +0 -332
  156. data/spec/runtime/setup_spec.rb +0 -853
  157. data/spec/runtime/with_clean_env_spec.rb +0 -91
  158. data/spec/spec_helper.rb +0 -123
  159. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +0 -13
  160. data/spec/support/artifice/endpoint.rb +0 -71
  161. data/spec/support/artifice/endpoint_500.rb +0 -37
  162. data/spec/support/artifice/endpoint_api_forbidden.rb +0 -11
  163. data/spec/support/artifice/endpoint_api_missing.rb +0 -16
  164. data/spec/support/artifice/endpoint_basic_authentication.rb +0 -13
  165. data/spec/support/artifice/endpoint_creds_diff_host.rb +0 -38
  166. data/spec/support/artifice/endpoint_extra.rb +0 -31
  167. data/spec/support/artifice/endpoint_extra_api.rb +0 -32
  168. data/spec/support/artifice/endpoint_extra_missing.rb +0 -15
  169. data/spec/support/artifice/endpoint_fallback.rb +0 -17
  170. data/spec/support/artifice/endpoint_host_redirect.rb +0 -15
  171. data/spec/support/artifice/endpoint_marshal_fail.rb +0 -11
  172. data/spec/support/artifice/endpoint_redirect.rb +0 -15
  173. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +0 -18
  174. data/spec/support/artifice/endpoint_timeout.rb +0 -13
  175. data/spec/support/builders.rb +0 -693
  176. data/spec/support/fakeweb/rack-1.0.0.marshal +0 -2
  177. data/spec/support/fakeweb/windows.rb +0 -23
  178. data/spec/support/hax.rb +0 -22
  179. data/spec/support/helpers.rb +0 -361
  180. data/spec/support/indexes.rb +0 -280
  181. data/spec/support/matchers.rb +0 -77
  182. data/spec/support/path.rb +0 -85
  183. data/spec/support/permissions.rb +0 -10
  184. data/spec/support/platforms.rb +0 -94
  185. data/spec/support/ruby_ext.rb +0 -20
  186. data/spec/support/rubygems_ext.rb +0 -39
  187. data/spec/support/streams.rb +0 -13
  188. data/spec/support/sudo.rb +0 -16
  189. data/spec/update/gems_spec.rb +0 -201
  190. data/spec/update/git_spec.rb +0 -283
  191. data/spec/update/path_spec.rb +0 -18
@@ -1,5 +1,7 @@
1
1
  module Bundler
2
2
  class Settings
3
+ BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check gem.mit gem.coc).freeze
4
+
3
5
  def initialize(root = nil)
4
6
  @root = root
5
7
  @local_config = load_config(local_config_file)
@@ -115,14 +117,22 @@ module Bundler
115
117
  ENV['BUNDLE_IGNORE_CONFIG']
116
118
  end
117
119
 
120
+ def app_cache_path
121
+ @app_cache_path ||= begin
122
+ path = self[:cache_path] || "vendor/cache"
123
+ raise InvalidOption, "Cache path must be relative to the bundle path" if path.start_with?("/")
124
+ path
125
+ end
126
+ end
127
+
118
128
  private
119
129
  def key_for(key)
120
- key = key.to_s.sub(".", "__").upcase
130
+ key = key.to_s.gsub(".", "__").upcase
121
131
  "BUNDLE_#{key}"
122
132
  end
123
133
 
124
134
  def is_bool(key)
125
- %w(frozen cache_all no_prune disable_local_branch_check).include? key.to_s
135
+ BOOL_KEYS.include?(key.to_s)
126
136
  end
127
137
 
128
138
  def to_bool(value)
@@ -155,10 +165,9 @@ module Bundler
155
165
  def load_config(config_file)
156
166
  valid_file = config_file && config_file.exist? && !config_file.size.zero?
157
167
  if !ignore_config? && valid_file
158
- config_regex = /^(BUNDLE_.+): (['"]?)(.*(?:\n(?!BUNDLE).+)?)\2$/
168
+ config_regex = /^(BUNDLE_.+): (?:['"](.*)['"]|(.+(?:\n(?!BUNDLE).+))|(.+))$/
159
169
  config_pairs = config_file.read.scan(config_regex).map do |m|
160
- key, _, value = m
161
- [key, value.gsub(/\s+/, " ").tr('"', "'")]
170
+ m.compact.map { |n| n.gsub(/\s+/, " ").tr('"', "'") }
162
171
  end
163
172
  Hash[config_pairs]
164
173
  else
@@ -2,7 +2,8 @@ require 'bundler/shared_helpers'
2
2
 
3
3
  if Bundler::SharedHelpers.in_bundle?
4
4
  require 'bundler'
5
- if STDOUT.tty?
5
+
6
+ if STDOUT.tty? || ENV['BUNDLER_FORCE_TTY']
6
7
  begin
7
8
  Bundler.setup
8
9
  rescue Bundler::BundlerError => e
@@ -28,7 +28,23 @@ module Bundler
28
28
  end
29
29
 
30
30
  def default_lockfile
31
- Pathname.new("#{default_gemfile}.lock")
31
+ gemfile = default_gemfile
32
+
33
+ case gemfile.basename.to_s
34
+ when 'gems.rb' then Pathname.new(gemfile.sub(/.rb$/, '.locked'))
35
+ else Pathname.new("#{gemfile}.lock")
36
+ end
37
+ end
38
+
39
+ def default_bundle_dir
40
+ global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle")
41
+ bundle_dir = find_directory(".bundle")
42
+
43
+ if bundle_dir && bundle_dir != global_bundle_dir
44
+ Pathname.new(bundle_dir)
45
+ else
46
+ nil
47
+ end
32
48
  end
33
49
 
34
50
  def in_bundle?
@@ -64,12 +80,47 @@ module Bundler
64
80
  keys.each {|key| ENV[key] = old_env[key] }
65
81
  end
66
82
 
83
+ def set_bundle_environment
84
+ # Set PATH
85
+ paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
86
+ paths.unshift "#{Bundler.bundle_path}/bin"
87
+ ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
88
+
89
+ # Set RUBYOPT
90
+ rubyopt = [ENV["RUBYOPT"]].compact
91
+ if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
92
+ rubyopt.unshift %|-rbundler/setup|
93
+ ENV["RUBYOPT"] = rubyopt.join(' ')
94
+ end
95
+
96
+ # Set RUBYLIB
97
+ rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
98
+ rubylib.unshift File.expand_path('../..', __FILE__)
99
+ ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
100
+ end
101
+
67
102
  private
68
103
 
69
104
  def find_gemfile
70
105
  given = ENV['BUNDLE_GEMFILE']
71
106
  return given if given && !given.empty?
72
107
 
108
+ find_file('Gemfile', 'gems.rb')
109
+ end
110
+
111
+ def find_file(*names)
112
+ search_up(*names) {|filename|
113
+ return filename if File.file?(filename)
114
+ }
115
+ end
116
+
117
+ def find_directory(*names)
118
+ search_up(*names) do |dirname|
119
+ return dirname if File.directory?(dirname)
120
+ end
121
+ end
122
+
123
+ def search_up(*names)
73
124
  previous = nil
74
125
  current = File.expand_path(SharedHelpers.pwd)
75
126
 
@@ -79,9 +130,10 @@ module Bundler
79
130
  return nil if File.file?(File.join(current, 'bundler.gemspec'))
80
131
  end
81
132
 
82
- # otherwise return the Gemfile if it's there
83
- filename = File.join(current, 'Gemfile')
84
- return filename if File.file?(filename)
133
+ names.each do |name|
134
+ filename = File.join(current, name)
135
+ yield filename
136
+ end
85
137
  current, previous = File.expand_path("..", current), current
86
138
  end
87
139
  end
@@ -21,22 +21,21 @@ module Bundler
21
21
  end
22
22
 
23
23
  def version_message(spec)
24
- locked_spec = Bundler.locked_gems.specs.find { |s| s.name == spec.name } if Bundler.locked_gems
25
- locked_spec_version = locked_spec.version if locked_spec
26
24
  message = "#{spec.name} #{spec.version}"
27
- if locked_spec_version && spec.version != locked_spec_version
28
- message << " (was #{locked_spec_version})"
25
+
26
+ if Bundler.locked_gems
27
+ locked_spec = Bundler.locked_gems.specs.find { |s| s.name == spec.name }
28
+ locked_spec_version = locked_spec.version if locked_spec
29
+ if locked_spec_version && spec.version != locked_spec_version
30
+ message << " (was #{locked_spec_version})"
31
+ end
29
32
  end
33
+
30
34
  message
31
35
  end
32
36
 
33
37
  def can_lock?(spec)
34
38
  spec.source == self
35
39
  end
36
-
37
- def include?(other)
38
- other == self
39
- end
40
-
41
40
  end
42
41
  end
@@ -20,7 +20,7 @@ module Bundler
20
20
  # Stringify options that could be set as symbols
21
21
  %w(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] }
22
22
 
23
- @uri = options["uri"]
23
+ @uri = options["uri"] || ''
24
24
  @branch = options["branch"]
25
25
  @ref = options["ref"] || options["branch"] || options["tag"] || 'master'
26
26
  @submodules = options["submodules"]
@@ -46,6 +46,10 @@ module Bundler
46
46
  out << " specs:\n"
47
47
  end
48
48
 
49
+ def hash
50
+ [self.class, uri, ref, branch, name, version, submodules].hash
51
+ end
52
+
49
53
  def eql?(o)
50
54
  o.is_a?(Git) &&
51
55
  uri == o.uri &&
@@ -60,6 +60,10 @@ module Bundler
60
60
  end
61
61
  end
62
62
 
63
+ def version
64
+ git("--version").sub("git version", "").strip
65
+ end
66
+
63
67
  def checkout
64
68
  if path.exist?
65
69
  return if has_revision_cached?
@@ -54,19 +54,19 @@ module Bundler
54
54
  end
55
55
 
56
56
  def hash
57
- self.class.hash
57
+ [self.class, expanded_path, version].hash
58
58
  end
59
59
 
60
60
  def eql?(o)
61
61
  o.instance_of?(Path) &&
62
- expand(path) == expand(o.path) &&
62
+ expanded_path == expand(o.path) &&
63
63
  version == o.version
64
64
  end
65
65
 
66
66
  alias == eql?
67
67
 
68
68
  def name
69
- File.basename(expand(path).to_s)
69
+ File.basename(expanded_path.to_s)
70
70
  end
71
71
 
72
72
  def install(spec)
@@ -95,6 +95,7 @@ module Bundler
95
95
  def specs
96
96
  if has_app_cache?
97
97
  @path = app_cache_path
98
+ @expanded_path = nil # Invalidate
98
99
  end
99
100
  local_specs
100
101
  end
@@ -105,6 +106,10 @@ module Bundler
105
106
 
106
107
  private
107
108
 
109
+ def expanded_path
110
+ @expanded_path ||= expand(path)
111
+ end
112
+
108
113
  def expand(somepath)
109
114
  somepath.expand_path(Bundler.root)
110
115
  rescue ArgumentError => e
@@ -123,7 +128,6 @@ module Bundler
123
128
 
124
129
  def load_spec_files
125
130
  index = Index.new
126
- expanded_path = expand(path)
127
131
 
128
132
  if File.directory?(expanded_path)
129
133
  Dir["#{expanded_path}/#{@glob}"].each do |file|
@@ -169,7 +173,6 @@ module Bundler
169
173
 
170
174
  def generate_bin(spec, disable_extensions = false)
171
175
  gem_dir = Pathname.new(spec.full_gem_path)
172
- gem_file = nil
173
176
 
174
177
  # Some gem authors put absolute paths in their gemspec
175
178
  # and we have to save them from themselves
@@ -183,8 +186,6 @@ module Bundler
183
186
  end.compact
184
187
 
185
188
  SharedHelpers.chdir(gem_dir) do
186
- gem_file = Bundler.rubygems.build_gem gem_dir, spec
187
-
188
189
  installer = Path::Installer.new(spec, :env_shebang => false)
189
190
  run_hooks(:pre_install, installer)
190
191
  installer.build_extensions unless disable_extensions
@@ -204,10 +205,6 @@ module Bundler
204
205
  end
205
206
 
206
207
  Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
207
- ensure
208
- if gem_dir && gem_file
209
- FileUtils.rm_rf(gem_dir.join gem_file)
210
- end
211
208
  end
212
209
 
213
210
  def run_hooks(type, installer)
@@ -3,8 +3,6 @@ module Bundler
3
3
  class Path
4
4
 
5
5
  class Installer < Bundler::GemInstaller
6
- attr_reader :spec
7
-
8
6
  def initialize(spec, options = {})
9
7
  @spec = spec
10
8
  @tmp_bin_dir = "#{Bundler.tmp(spec.full_name)}/bin"
@@ -5,8 +5,7 @@ require 'rubygems/spec_fetcher'
5
5
  module Bundler
6
6
  class Source
7
7
  class Rubygems < Source
8
- # threshold for switching back to the modern index instead of fetching every spec
9
- API_REQUEST_LIMIT = 100
8
+ API_REQUEST_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec
10
9
 
11
10
  attr_reader :remotes, :caches
12
11
 
@@ -34,15 +33,11 @@ module Bundler
34
33
  end
35
34
 
36
35
  def eql?(o)
37
- o.is_a?(Rubygems) && o.credless_remotes == credless_remotes
36
+ o.is_a?(Rubygems) && remotes_equal?(o.remotes)
38
37
  end
39
38
 
40
39
  alias == eql?
41
40
 
42
- def include?(o)
43
- o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
44
- end
45
-
46
41
  def can_lock?(spec)
47
42
  spec.source.is_a?(Rubygems)
48
43
  end
@@ -97,49 +92,50 @@ module Bundler
97
92
  spec.__swap__(s)
98
93
  end
99
94
 
100
- path = cached_gem(spec)
101
- if Bundler.requires_sudo?
102
- install_path = Bundler.tmp(spec.full_name)
103
- bin_path = install_path.join("bin")
104
- else
105
- install_path = Bundler.rubygems.gem_dir
106
- bin_path = Bundler.system_bindir
107
- end
95
+ unless Bundler.settings[:no_install]
96
+ path = cached_gem(spec)
97
+ if Bundler.requires_sudo?
98
+ install_path = Bundler.tmp(spec.full_name)
99
+ bin_path = install_path.join("bin")
100
+ else
101
+ install_path = Bundler.rubygems.gem_dir
102
+ bin_path = Bundler.system_bindir
103
+ end
108
104
 
109
- installed_spec = nil
110
- Bundler.rubygems.preserve_paths do
111
- installed_spec = Bundler::GemInstaller.new(path,
112
- :install_dir => install_path.to_s,
113
- :bin_dir => bin_path.to_s,
114
- :ignore_dependencies => true,
115
- :wrappers => true,
116
- :env_shebang => true
117
- ).install
118
- end
105
+ installed_spec = nil
106
+ Bundler.rubygems.preserve_paths do
107
+ installed_spec = Bundler::GemInstaller.new(path,
108
+ :install_dir => install_path.to_s,
109
+ :bin_dir => bin_path.to_s,
110
+ :ignore_dependencies => true,
111
+ :wrappers => true,
112
+ :env_shebang => true
113
+ ).install
114
+ end
119
115
 
120
- # SUDO HAX
121
- if Bundler.requires_sudo?
122
- Bundler.rubygems.repository_subdirectories.each do |name|
123
- src = File.join(install_path, name, "*")
124
- dst = File.join(Bundler.rubygems.gem_dir, name)
125
- if name == "extensions" && Dir.glob(src).any?
126
- src = File.join(src, "*/*")
127
- ext_src = Dir.glob(src).first
128
- ext_src.gsub!(src[0..-6], '')
129
- dst = File.dirname(File.join(dst, ext_src))
116
+ # SUDO HAX
117
+ if Bundler.requires_sudo?
118
+ Bundler.rubygems.repository_subdirectories.each do |name|
119
+ src = File.join(install_path, name, "*")
120
+ dst = File.join(Bundler.rubygems.gem_dir, name)
121
+ if name == "extensions" && Dir.glob(src).any?
122
+ src = File.join(src, "*/*")
123
+ ext_src = Dir.glob(src).first
124
+ ext_src.gsub!(src[0..-6], '')
125
+ dst = File.dirname(File.join(dst, ext_src))
126
+ end
127
+ Bundler.mkdir_p dst
128
+ Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
130
129
  end
131
- Bundler.mkdir_p dst
132
- Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
133
- end
134
130
 
135
- spec.executables.each do |exe|
136
- Bundler.mkdir_p Bundler.system_bindir
137
- Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
131
+ spec.executables.each do |exe|
132
+ Bundler.mkdir_p Bundler.system_bindir
133
+ Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
134
+ end
138
135
  end
136
+ installed_spec.loaded_from = loaded_from(spec)
139
137
  end
140
-
141
- spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
142
- installed_spec.loaded_from = spec.loaded_from
138
+ spec.loaded_from = loaded_from(spec)
143
139
  ["Installing #{version_message(spec)}", spec.post_install_message]
144
140
  ensure
145
141
  if install_path && Bundler.requires_sudo?
@@ -190,21 +186,27 @@ module Bundler
190
186
  end
191
187
  end
192
188
 
193
- protected
194
-
195
- def credless_remotes
196
- remotes.map(&method(:suppress_configured_credentials))
189
+ def fetchers
190
+ @fetchers ||= remotes.map do |uri|
191
+ Bundler::Fetcher.new(uri)
192
+ end
197
193
  end
198
194
 
199
- private
195
+ protected
200
196
 
201
197
  def source_uris_for_spec(spec)
202
- specs.search_all(spec.name).inject([]) do |uris, spec|
203
- uris << spec.source_uri.without_credentials if spec.source_uri
198
+ specs.search_all(spec.name).inject([]) do |uris, s|
199
+ uris << s.source_uri.without_credentials if s.source_uri
204
200
  uris
205
201
  end
206
202
  end
207
203
 
204
+ private
205
+
206
+ def loaded_from(spec)
207
+ "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
208
+ end
209
+
208
210
  def cached_gem(spec)
209
211
  cached_gem = cached_path(spec)
210
212
  unless cached_gem
@@ -281,12 +283,6 @@ module Bundler
281
283
  idx
282
284
  end
283
285
 
284
- def fetchers
285
- @fetchers ||= remotes.map do |url|
286
- Bundler::Fetcher.new(url)
287
- end
288
- end
289
-
290
286
  def api_fetchers
291
287
  fetchers.select{|f| f.use_api }
292
288
  end
@@ -313,20 +309,6 @@ module Bundler
313
309
  Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over
314
310
  end
315
311
 
316
- # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
317
- # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
318
- # but will not have found any versions of Bar from source B, which is a problem if the requested version
319
- # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
320
- # each spec we found, we add all possible versions from all sources to the index.
321
- begin
322
- idxcount = idx.size
323
- api_fetchers.each do |f|
324
- Bundler.ui.info "Fetching version metadata from #{f.uri}", Bundler.ui.debug?
325
- idx.use f.specs(idx.dependency_names, self), true
326
- Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over
327
- end
328
- end until idxcount == idx.size
329
-
330
312
  if api_fetchers.any? && api_fetchers.all?{|f| f.use_api }
331
313
  # it's possible that gems from one source depend on gems from some
332
314
  # other source, so now we download gemspecs and iterate over those
@@ -335,7 +317,7 @@ module Bundler
335
317
 
336
318
  # if there are any cross-site gems we missed, get them now
337
319
  api_fetchers.each do |f|
338
- Bundler.ui.info "Fetching dependency metadata from #{f.uri}", Bundler.ui.debug?
320
+ Bundler.ui.info "Fetching additional metadata from #{f.uri}", Bundler.ui.debug?
339
321
  idx.use f.specs(unmet, self)
340
322
  Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over
341
323
  end if unmet.any?
@@ -366,6 +348,10 @@ module Bundler
366
348
  spec.loaded_from && spec.loaded_from.include?("specifications/default/")
367
349
  end
368
350
 
351
+ def remotes_equal?(other_remotes)
352
+ remotes.map(&method(:suppress_configured_credentials)) == other_remotes.map(&method(:suppress_configured_credentials))
353
+ end
354
+
369
355
  end
370
356
  end
371
357
  end