bundler 1.10.6 → 1.11.0.pre.1

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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +105 -0
  3. data/.rubocop_todo.yml +120 -0
  4. data/.travis.yml +8 -23
  5. data/CHANGELOG.md +69 -0
  6. data/CODE_OF_CONDUCT.md +6 -4
  7. data/DEVELOPMENT.md +4 -5
  8. data/README.md +2 -2
  9. data/Rakefile +70 -87
  10. data/bin/rake +14 -0
  11. data/bin/rspec +10 -0
  12. data/bin/rubocop +11 -0
  13. data/bundler.gemspec +17 -15
  14. data/exe/bundle +20 -0
  15. data/{bin → exe}/bundle_ruby +6 -4
  16. data/exe/bundler +20 -0
  17. data/lib/bundler.rb +98 -119
  18. data/lib/bundler/capistrano.rb +2 -2
  19. data/lib/bundler/cli.rb +85 -74
  20. data/lib/bundler/cli/binstubs.rb +1 -2
  21. data/lib/bundler/cli/cache.rb +0 -1
  22. data/lib/bundler/cli/check.rb +7 -5
  23. data/lib/bundler/cli/clean.rb +0 -1
  24. data/lib/bundler/cli/common.rb +6 -7
  25. data/lib/bundler/cli/config.rb +69 -56
  26. data/lib/bundler/cli/console.rb +8 -8
  27. data/lib/bundler/cli/exec.rb +4 -3
  28. data/lib/bundler/cli/gem.rb +50 -39
  29. data/lib/bundler/cli/init.rb +5 -6
  30. data/lib/bundler/cli/inject.rb +1 -2
  31. data/lib/bundler/cli/install.rb +18 -21
  32. data/lib/bundler/cli/lock.rb +8 -3
  33. data/lib/bundler/cli/open.rb +4 -5
  34. data/lib/bundler/cli/outdated.rb +7 -8
  35. data/lib/bundler/cli/package.rb +1 -1
  36. data/lib/bundler/cli/platform.rb +2 -3
  37. data/lib/bundler/cli/show.rb +9 -9
  38. data/lib/bundler/cli/update.rb +2 -3
  39. data/lib/bundler/cli/viz.rb +1 -2
  40. data/lib/bundler/constants.rb +1 -1
  41. data/lib/bundler/current_ruby.rb +38 -3
  42. data/lib/bundler/definition.rb +83 -88
  43. data/lib/bundler/dep_proxy.rb +11 -9
  44. data/lib/bundler/dependency.rb +26 -11
  45. data/lib/bundler/deployment.rb +2 -2
  46. data/lib/bundler/deprecate.rb +3 -3
  47. data/lib/bundler/dsl.rb +63 -44
  48. data/lib/bundler/env.rb +19 -12
  49. data/lib/bundler/environment.rb +1 -2
  50. data/lib/bundler/errors.rb +82 -0
  51. data/lib/bundler/fetcher.rb +45 -39
  52. data/lib/bundler/fetcher/base.rb +20 -7
  53. data/lib/bundler/fetcher/dependency.rb +5 -5
  54. data/lib/bundler/fetcher/downloader.rb +1 -2
  55. data/lib/bundler/fetcher/index.rb +4 -7
  56. data/lib/bundler/friendly_errors.rb +15 -8
  57. data/lib/bundler/gem_helper.rb +44 -35
  58. data/lib/bundler/gem_helpers.rb +7 -8
  59. data/lib/bundler/gem_remote_fetcher.rb +41 -0
  60. data/lib/bundler/gem_tasks.rb +4 -1
  61. data/lib/bundler/graph.rb +25 -24
  62. data/lib/bundler/index.rb +21 -18
  63. data/lib/bundler/injector.rb +2 -4
  64. data/lib/bundler/inline.rb +3 -3
  65. data/lib/bundler/installer.rb +57 -144
  66. data/lib/bundler/installer/gem_installer.rb +76 -0
  67. data/lib/bundler/installer/parallel_installer.rb +22 -13
  68. data/lib/bundler/installer/standalone.rb +48 -0
  69. data/lib/bundler/lazy_specification.rb +3 -4
  70. data/lib/bundler/lockfile_parser.rb +21 -19
  71. data/lib/bundler/match_platform.rb +4 -4
  72. data/lib/bundler/psyched_yaml.rb +3 -3
  73. data/lib/bundler/remote_specification.rb +1 -1
  74. data/lib/bundler/resolver.rb +93 -88
  75. data/lib/bundler/retry.rb +9 -10
  76. data/lib/bundler/ruby_dsl.rb +1 -1
  77. data/lib/bundler/ruby_version.rb +7 -10
  78. data/lib/bundler/rubygems_ext.rb +32 -27
  79. data/lib/bundler/{gem_installer.rb → rubygems_gem_installer.rb} +2 -2
  80. data/lib/bundler/rubygems_integration.rb +85 -70
  81. data/lib/bundler/runtime.rb +57 -61
  82. data/lib/bundler/settings.rb +27 -26
  83. data/lib/bundler/setup.rb +3 -3
  84. data/lib/bundler/shared_helpers.rb +45 -20
  85. data/lib/bundler/similarity_detector.rb +19 -21
  86. data/lib/bundler/source.rb +4 -5
  87. data/lib/bundler/source/git.rb +29 -31
  88. data/lib/bundler/source/git/git_proxy.rb +52 -26
  89. data/lib/bundler/source/path.rb +25 -28
  90. data/lib/bundler/source/path/installer.rb +4 -4
  91. data/lib/bundler/source/rubygems.rb +62 -48
  92. data/lib/bundler/source/rubygems/remote.rb +3 -3
  93. data/lib/bundler/source_list.rb +4 -4
  94. data/lib/bundler/spec_set.rb +17 -15
  95. data/lib/bundler/ssl_certs/certificate_manager.rb +5 -6
  96. data/lib/bundler/stub_specification.rb +2 -2
  97. data/lib/bundler/templates/Executable +5 -5
  98. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +42 -6
  99. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  100. data/lib/bundler/templates/newgem/Rakefile.tt +4 -2
  101. data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
  102. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  103. data/lib/bundler/ui.rb +3 -3
  104. data/lib/bundler/ui/rg_proxy.rb +2 -2
  105. data/lib/bundler/ui/shell.rb +10 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +82 -71
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +9 -0
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +40 -21
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -0
  111. data/lib/bundler/vendored_molinillo.rb +1 -1
  112. data/lib/bundler/vendored_persistent.rb +3 -3
  113. data/lib/bundler/vendored_thor.rb +2 -2
  114. data/lib/bundler/version.rb +1 -1
  115. data/lib/bundler/vlad.rb +1 -1
  116. data/lib/bundler/worker.rb +4 -5
  117. data/man/bundle-config.ronn +4 -2
  118. data/man/bundle-gem.ronn +77 -0
  119. data/man/bundle-install.ronn +13 -6
  120. data/man/bundle-lock.ronn +47 -0
  121. data/man/bundle.ronn +1 -1
  122. data/man/gemfile.5.ronn +8 -0
  123. data/man/index.txt +1 -0
  124. metadata +37 -8
  125. data/bin/bundle +0 -21
  126. data/bin/bundler +0 -21
@@ -0,0 +1,48 @@
1
+ module Bundler
2
+ class Standalone
3
+ def initialize(groups, definition)
4
+ @specs = groups.empty? ? definition.requested_specs : definition.specs_for(groups.map(&:to_sym))
5
+ end
6
+
7
+ def generate
8
+ SharedHelpers.filesystem_access(bundler_path) do |p|
9
+ FileUtils.mkdir_p(p)
10
+ end
11
+ File.open File.join(bundler_path, "setup.rb"), "w" do |file|
12
+ file.puts "require 'rbconfig'"
13
+ file.puts "# ruby 1.8.7 doesn't define RUBY_ENGINE"
14
+ file.puts "ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'"
15
+ file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
16
+ file.puts "path = File.expand_path('..', __FILE__)"
17
+ paths.each do |path|
18
+ file.puts %($:.unshift "\#{path}/#{path}")
19
+ end
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def paths
26
+ @specs.map do |spec|
27
+ next if spec.name == "bundler"
28
+ Array(spec.require_paths).map do |path|
29
+ gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
30
+ # This is a static string intentionally. It's interpolated at a later time.
31
+ end
32
+ end.flatten
33
+ end
34
+
35
+ def version_dir
36
+ "#{Bundler.ruby_version.engine}/#{RbConfig::CONFIG["ruby_version"]}"
37
+ end
38
+
39
+ def bundler_path
40
+ File.join(Bundler.settings[:path], "bundler")
41
+ end
42
+
43
+ def gem_path(path, spec)
44
+ full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
45
+ Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
46
+ end
47
+ end
48
+ end
@@ -19,7 +19,7 @@ module Bundler
19
19
  end
20
20
 
21
21
  def full_name
22
- if platform == Gem::Platform::RUBY or platform.nil? then
22
+ if platform == Gem::Platform::RUBY || platform.nil?
23
23
  "#{@name}-#{@version}"
24
24
  else
25
25
  "#{@name}-#{@version}-#{platform}"
@@ -35,13 +35,13 @@ module Bundler
35
35
  end
36
36
 
37
37
  def to_lock
38
- if platform == Gem::Platform::RUBY or platform.nil?
38
+ if platform == Gem::Platform::RUBY || platform.nil?
39
39
  out = " #{name} (#{version})\n"
40
40
  else
41
41
  out = " #{name} (#{version}-#{platform})\n"
42
42
  end
43
43
 
44
- dependencies.sort_by {|d| d.to_s }.uniq.each do |dep|
44
+ dependencies.sort_by(&:to_s).uniq.each do |dep|
45
45
  next if dep.type == :development
46
46
  out << " #{dep.to_lock}\n"
47
47
  end
@@ -78,6 +78,5 @@ module Bundler
78
78
 
79
79
  @specification.send(method, *args, &blk)
80
80
  end
81
-
82
81
  end
83
82
  end
@@ -34,8 +34,8 @@ module Bundler
34
34
  @rubygems_aggregate = Source::Rubygems.new
35
35
 
36
36
  if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
37
- raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \
38
- "Run `git checkout HEAD -- Gemfile.lock` first to get a clean lock."
37
+ raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
38
+ "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
39
39
  end
40
40
 
41
41
  lockfile.split(/(?:\r?\n)+/).each do |line|
@@ -59,7 +59,7 @@ module Bundler
59
59
  warn_for_outdated_bundler_version
60
60
  rescue ArgumentError => e
61
61
  Bundler.ui.debug(e)
62
- raise LockfileError, "Your lockfile is unreadable. Run `rm Gemfile.lock` " \
62
+ raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
63
63
  "and then `bundle install` to generate a new lockfile."
64
64
  end
65
65
 
@@ -92,7 +92,8 @@ module Bundler
92
92
  case line
93
93
  when GIT, GEM, PATH
94
94
  @current_source = nil
95
- @opts, @type = {}, line
95
+ @opts = {}
96
+ @type = line
96
97
  when SPECS
97
98
  case @type
98
99
  when PATH
@@ -102,7 +103,7 @@ module Bundler
102
103
  @current_source = TYPES[@type].from_lock(@opts)
103
104
  # Strip out duplicate GIT sections
104
105
  if @sources.include?(@current_source)
105
- @current_source = @sources.find { |s| s == @current_source }
106
+ @current_source = @sources.find {|s| s == @current_source }
106
107
  else
107
108
  @sources << @current_source
108
109
  end
@@ -131,19 +132,21 @@ module Bundler
131
132
  end
132
133
 
133
134
  NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'
134
- NAME_VERSION_2 = %r{^ {2}#{NAME_VERSION}(!)?$}
135
- NAME_VERSION_4 = %r{^ {4}#{NAME_VERSION}$}
136
- NAME_VERSION_6 = %r{^ {6}#{NAME_VERSION}$}
135
+ NAME_VERSION_2 = /^ {2}#{NAME_VERSION}(!)?$/
136
+ NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/
137
+ NAME_VERSION_6 = /^ {6}#{NAME_VERSION}$/
137
138
 
138
139
  def parse_dependency(line)
139
140
  if line =~ NAME_VERSION_2
140
- name, version, pinned = $1, $2, $4
141
- version = version.split(",").map { |d| d.strip } if version
141
+ name = $1
142
+ version = $2
143
+ pinned = $4
144
+ version = version.split(",").map(&:strip) if version
142
145
 
143
146
  dep = Bundler::Dependency.new(name, version)
144
147
 
145
- if pinned && dep.name != 'bundler'
146
- spec = @specs.find {|k, v| v.name == dep.name }
148
+ if pinned && dep.name != "bundler"
149
+ spec = @specs.find {|_, v| v.name == dep.name }
147
150
  dep.source = spec.last.source if spec
148
151
 
149
152
  # Path sources need to know what the default name / version
@@ -162,7 +165,8 @@ module Bundler
162
165
 
163
166
  def parse_spec(line)
164
167
  if line =~ NAME_VERSION_4
165
- name, version = $1, Gem::Version.new($2)
168
+ name = $1
169
+ version = Gem::Version.new($2)
166
170
  platform = $3 ? Gem::Platform.new($3) : Gem::Platform::RUBY
167
171
  @current_spec = LazySpecification.new(name, version, platform)
168
172
  @current_spec.source = @current_source
@@ -171,17 +175,16 @@ module Bundler
171
175
  # duplicate GIT sections)
172
176
  @specs[@current_spec.identifier] ||= @current_spec
173
177
  elsif line =~ NAME_VERSION_6
174
- name, version = $1, $2
175
- version = version.split(',').map { |d| d.strip } if version
178
+ name = $1
179
+ version = $2
180
+ version = version.split(",").map(&:strip) if version
176
181
  dep = Gem::Dependency.new(name, version)
177
182
  @current_spec.dependencies << dep
178
183
  end
179
184
  end
180
185
 
181
186
  def parse_platform(line)
182
- if line =~ /^ (.*)$/
183
- @platforms << Gem::Platform.new($1)
184
- end
187
+ @platforms << Gem::Platform.new($1) if line =~ /^ (.*)$/
185
188
  end
186
189
 
187
190
  def parse_bundled_with(line)
@@ -190,6 +193,5 @@ module Bundler
190
193
  @bundler_version = Gem::Version.create(line)
191
194
  end
192
195
  end
193
-
194
196
  end
195
197
  end
@@ -1,13 +1,13 @@
1
- require 'bundler/gem_helpers'
1
+ require "bundler/gem_helpers"
2
2
 
3
3
  module Bundler
4
4
  module MatchPlatform
5
5
  include GemHelpers
6
6
 
7
7
  def match_platform(p)
8
- Gem::Platform::RUBY == platform or
9
- platform.nil? or p == platform or
10
- generic(Gem::Platform.new(platform)) === p
8
+ Gem::Platform::RUBY == platform ||
9
+ platform.nil? || p == platform ||
10
+ generic(Gem::Platform.new(platform)) === p
11
11
  end
12
12
  end
13
13
  end
@@ -1,19 +1,19 @@
1
1
  # Psych could be a gem, so try to ask for it
2
2
  begin
3
- gem 'psych'
3
+ gem "psych"
4
4
  rescue LoadError
5
5
  end if defined?(gem)
6
6
 
7
7
  # Psych could just be in the stdlib
8
8
  # but it's too late if Syck is already loaded
9
9
  begin
10
- require 'psych' unless defined?(Syck)
10
+ require "psych" unless defined?(Syck)
11
11
  rescue LoadError
12
12
  # Apparently Psych wasn't available. Oh well.
13
13
  end
14
14
 
15
15
  # At least load the YAML stdlib, whatever that may be
16
- require 'yaml' unless defined?(YAML.dump)
16
+ require "yaml" unless defined?(YAML.dump)
17
17
 
18
18
  module Bundler
19
19
  # On encountering invalid YAML,
@@ -27,7 +27,7 @@ module Bundler
27
27
  end
28
28
 
29
29
  def full_name
30
- if platform == Gem::Platform::RUBY or platform.nil? then
30
+ if platform == Gem::Platform::RUBY || platform.nil?
31
31
  "#{@name}-#{@version}"
32
32
  else
33
33
  "#{@name}-#{@version}-#{platform}"
@@ -1,52 +1,48 @@
1
- require 'set'
2
-
3
- # This is the latest iteration of the gem dependency resolving algorithm. As of now,
4
- # it can resolve (as a success or failure) any set of gem dependencies we throw at it
5
- # in a reasonable amount of time. The most iterations I've seen it take is about 150.
6
- # The actual implementation of the algorithm is not as good as it could be yet, but that
7
- # can come later.
8
-
9
1
  module Bundler
10
2
  class Resolver
11
-
12
- require 'bundler/vendored_molinillo'
3
+ require "bundler/vendored_molinillo"
13
4
 
14
5
  class Molinillo::VersionConflict
15
- def clean_req(req)
16
- if req.to_s.include?(">= 0")
17
- req.to_s.gsub(/ \(.*?\)$/, '')
6
+ def printable_dep(dep)
7
+ if dep.is_a?(Bundler::Dependency)
8
+ DepProxy.new(dep, dep.platforms.join(", ")).to_s.strip
18
9
  else
19
- req.to_s.gsub(/\, (runtime|development)\)$/, ')')
10
+ dep.to_s
20
11
  end
21
12
  end
22
13
 
23
14
  def message
24
- conflicts.values.flatten.reduce('') do |o, conflict|
25
- o << %(Bundler could not find compatible versions for gem "#{conflict.requirement.name}":\n)
15
+ conflicts.sort.reduce("") do |o, (name, conflict)|
16
+ o << %(Bundler could not find compatible versions for gem "#{name}":\n)
26
17
  if conflict.locked_requirement
27
- o << %( In snapshot (Gemfile.lock):\n)
28
- o << %( #{clean_req conflict.locked_requirement}\n)
18
+ o << %( In snapshot (#{Bundler.default_lockfile.basename}):\n)
19
+ o << %( #{printable_dep(conflict.locked_requirement)}\n)
29
20
  o << %(\n)
30
21
  end
31
22
  o << %( In Gemfile:\n)
32
- o << conflict.requirement_trees.map do |tree|
33
- t = ''
23
+ o << conflict.requirement_trees.sort_by {|t| t.reverse.map(&:name) }.map do |tree|
24
+ t = ""
34
25
  depth = 2
35
26
  tree.each do |req|
36
- t << ' ' * depth << %(#{clean_req req})
37
- t << %( depends on) unless tree[-1] == req
27
+ t << " " * depth << req.to_s
28
+ unless tree.last == req
29
+ if spec = conflict.activated_by_name[req.name]
30
+ t << %( was resolved to #{spec.version}, which)
31
+ end
32
+ t << %( depends on)
33
+ end
38
34
  t << %(\n)
39
35
  depth += 1
40
36
  end
41
37
  t
42
38
  end.join("\n")
43
39
 
44
- if conflict.requirement.name == 'bundler'
40
+ if name == "bundler"
45
41
  o << %(\n Current Bundler version:\n bundler (#{Bundler::VERSION}))
46
42
  other_bundler_required = !conflict.requirement.requirement.satisfied_by?(Gem::Version.new Bundler::VERSION)
47
43
  end
48
44
 
49
- if conflict.requirement.name == "bundler" && other_bundler_required
45
+ if name == "bundler" && other_bundler_required
50
46
  o << "\n"
51
47
  o << "This Gemfile requires a different version of Bundler.\n"
52
48
  o << "Perhaps you need to update Bundler by running `gem install bundler`?\n"
@@ -56,11 +52,12 @@ module Bundler
56
52
  o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
57
53
  o << %(the gems in your Gemfile, which may resolve the conflict.\n)
58
54
  elsif !conflict.existing
55
+ o << "\n"
59
56
  if conflict.requirement_trees.first.size > 1
60
- o << "Could not find gem '#{clean_req(conflict.requirement)}', which is required by "
61
- o << "gem '#{clean_req(conflict.requirement_trees.first[-2])}', in any of the sources."
57
+ o << "Could not find gem '#{conflict.requirement}', which is required by "
58
+ o << "gem '#{conflict.requirement_trees.first[-2]}', in any of the sources."
62
59
  else
63
- o << "Could not find gem '#{clean_req(conflict.requirement)} in any of the sources\n"
60
+ o << "Could not find gem '#{conflict.requirement}' in any of the sources\n"
64
61
  end
65
62
  end
66
63
  o
@@ -83,7 +80,7 @@ module Bundler
83
80
  @specs = {}
84
81
 
85
82
  ALL.each do |p|
86
- @specs[p] = reverse.find { |s| s.match_platform(p) }
83
+ @specs[p] = reverse.find {|s| s.match_platform(p) }
87
84
  end
88
85
  end
89
86
 
@@ -97,21 +94,20 @@ module Bundler
97
94
  specs = {}
98
95
 
99
96
  @activated.each do |p|
100
- if s = @specs[p]
101
- platform = generic(Gem::Platform.new(s.platform))
102
- next if specs[platform]
97
+ next unless s = @specs[p]
98
+ platform = generic(Gem::Platform.new(s.platform))
99
+ next if specs[platform]
103
100
 
104
- lazy_spec = LazySpecification.new(name, version, platform, source)
105
- lazy_spec.dependencies.replace s.dependencies
106
- specs[platform] = lazy_spec
107
- end
101
+ lazy_spec = LazySpecification.new(name, version, platform, source)
102
+ lazy_spec.dependencies.replace s.dependencies
103
+ specs[platform] = lazy_spec
108
104
  end
109
105
  specs.values
110
106
  end
111
107
 
112
108
  def activate_platform(platform)
113
109
  unless @activated.include?(platform)
114
- if for?(platform)
110
+ if for?(platform, nil)
115
111
  @activated << platform
116
112
  return __dependencies[platform] || []
117
113
  end
@@ -131,8 +127,14 @@ module Bundler
131
127
  @source ||= first.source
132
128
  end
133
129
 
134
- def for?(platform)
135
- @specs[platform]
130
+ def for?(platform, required_ruby_version)
131
+ if spec = @specs[platform]
132
+ if required_ruby_version && spec_required_ruby_version = spec.required_ruby_version
133
+ spec_required_ruby_version.satisfied_by?(required_ruby_version)
134
+ else
135
+ true
136
+ end
137
+ end
136
138
  end
137
139
 
138
140
  def to_s
@@ -140,11 +142,11 @@ module Bundler
140
142
  end
141
143
 
142
144
  def dependencies_for_activated_platforms
143
- @activated.map { |p| __dependencies[p] }.flatten
145
+ @activated.map {|p| __dependencies[p] }.flatten
144
146
  end
145
147
 
146
148
  def platforms_for_dependency_named(dependency)
147
- __dependencies.select { |p, deps| deps.map(&:name).include? dependency }.keys
149
+ __dependencies.select {|_, deps| deps.map(&:name).include? dependency }.keys
148
150
  end
149
151
 
150
152
  private
@@ -153,12 +155,11 @@ module Bundler
153
155
  @dependencies ||= begin
154
156
  dependencies = {}
155
157
  ALL.each do |p|
156
- if spec = @specs[p]
157
- dependencies[p] = []
158
- spec.dependencies.each do |dep|
159
- next if dep.type == :development
160
- dependencies[p] << DepProxy.new(dep, p)
161
- end
158
+ next unless spec = @specs[p]
159
+ dependencies[p] = []
160
+ spec.dependencies.each do |dep|
161
+ next if dep.type == :development
162
+ dependencies[p] << DepProxy.new(dep, p)
162
163
  end
163
164
  end
164
165
  dependencies
@@ -176,22 +177,22 @@ module Bundler
176
177
  # ==== Returns
177
178
  # <GemBundle>,nil:: If the list of dependencies can be resolved, a
178
179
  # collection of gemspecs is returned. Otherwise, nil is returned.
179
- def self.resolve(requirements, index, source_requirements = {}, base = [])
180
+ def self.resolve(requirements, index, source_requirements = {}, base = [], ruby_version = nil)
180
181
  base = SpecSet.new(base) unless base.is_a?(SpecSet)
181
- resolver = new(index, source_requirements, base)
182
+ resolver = new(index, source_requirements, base, ruby_version)
182
183
  result = resolver.start(requirements)
183
184
  SpecSet.new(result)
184
185
  end
185
186
 
186
-
187
- def initialize(index, source_requirements, base)
187
+ def initialize(index, source_requirements, base, ruby_version)
188
188
  @index = index
189
189
  @source_requirements = source_requirements
190
190
  @base = base
191
191
  @resolver = Molinillo::Resolver.new(self, self)
192
192
  @search_for = {}
193
193
  @base_dg = Molinillo::DependencyGraph.new
194
- @base.each { |ls| @base_dg.add_root_vertex ls.name, Dependency.new(ls.name, ls.version) }
194
+ @base.each {|ls| @base_dg.add_vertex(ls.name, Dependency.new(ls.name, ls.version), true) }
195
+ @ruby_version = ruby_version ? Gem::Version.create(ruby_version) : nil
195
196
  end
196
197
 
197
198
  def start(requirements)
@@ -201,10 +202,10 @@ module Bundler
201
202
  rescue Molinillo::VersionConflict => e
202
203
  raise VersionConflict.new(e.conflicts.keys.uniq, e.message)
203
204
  rescue Molinillo::CircularDependencyError => e
204
- names = e.dependencies.sort_by(&:name).map { |d| "gem '#{d.name}'"}
205
- raise CyclicDependencyError, "Your Gemfile requires gems that depend" \
205
+ names = e.dependencies.sort_by(&:name).map {|d| "gem '#{d.name}'" }
206
+ raise CyclicDependencyError, "Your bundle requires gems that depend" \
206
207
  " on each other, creating an infinite loop. Please remove" \
207
- " #{names.count > 1 ? 'either ' : '' }#{names.join(' or ')}" \
208
+ " #{names.count > 1 ? "either " : ""}#{names.join(" or ")}" \
208
209
  " and try again."
209
210
  end
210
211
 
@@ -218,27 +219,27 @@ module Bundler
218
219
  if debug?
219
220
  debug_info = yield
220
221
  debug_info = debug_info.inspect unless debug_info.is_a?(String)
221
- STDERR.puts debug_info.split("\n").map { |s| ' ' * depth + s }
222
+ STDERR.puts debug_info.split("\n").map {|s| " " * depth + s }
222
223
  end
223
224
  end
224
225
 
225
226
  def debug?
226
- ENV['DEBUG_RESOLVER'] || ENV['DEBUG_RESOLVER_TREE']
227
+ ENV["DEBUG_RESOLVER"] || ENV["DEBUG_RESOLVER_TREE"]
227
228
  end
228
229
 
229
230
  def before_resolution
230
- Bundler.ui.info 'Resolving dependencies...', false
231
+ Bundler.ui.info "Resolving dependencies...", false
231
232
  end
232
233
 
233
234
  def after_resolution
234
- Bundler.ui.info ''
235
+ Bundler.ui.info ""
235
236
  end
236
237
 
237
238
  def indicate_progress
238
- Bundler.ui.info '.', false
239
+ Bundler.ui.info ".", false
239
240
  end
240
241
 
241
- private
242
+ private
242
243
 
243
244
  include Molinillo::SpecificationProvider
244
245
 
@@ -265,13 +266,13 @@ module Bundler
265
266
  end
266
267
  nested.last << spec
267
268
  end
268
- groups = nested.map { |a| SpecGroup.new(a) }
269
- !locked_requirement ? groups : groups.select { |sg| locked_requirement.satisfied_by? sg.version }
269
+ groups = nested.map {|a| SpecGroup.new(a) }
270
+ !locked_requirement ? groups : groups.select {|sg| locked_requirement.satisfied_by? sg.version }
270
271
  else
271
272
  []
272
273
  end
273
274
  end
274
- search.select { |sg| sg.for?(platform) }.each { |sg| sg.activate_platform(platform) }
275
+ search.select {|sg| sg.for?(platform, @ruby_version) }.each {|sg| sg.activate_platform(platform) }
275
276
  end
276
277
 
277
278
  def name_for(dependency)
@@ -279,11 +280,15 @@ module Bundler
279
280
  end
280
281
 
281
282
  def name_for_explicit_dependency_source
282
- 'Gemfile'
283
+ Bundler.default_gemfile.basename.to_s
284
+ rescue
285
+ "Gemfile"
283
286
  end
284
287
 
285
288
  def name_for_locking_dependency_source
286
- 'Gemfile.lock'
289
+ Bundler.default_lockfile.basename.to_s
290
+ rescue
291
+ "Gemfile.lock"
287
292
  end
288
293
 
289
294
  def requirement_satisfied_by?(requirement, activated, spec)
@@ -305,10 +310,10 @@ module Bundler
305
310
  def amount_constrained(dependency)
306
311
  @amount_constrained ||= {}
307
312
  @amount_constrained[dependency.name] ||= begin
308
- if base = @base[dependency.name] and !base.empty?
313
+ if (base = @base[dependency.name]) && !base.empty?
309
314
  dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
310
315
  else
311
- base_dep = Dependency.new dependency.name, '>= 0.a'
316
+ base_dep = Dependency.new dependency.name, ">= 0.a"
312
317
  all = search_for(DepProxy.new base_dep, dependency.__platform).size.to_f
313
318
  if all.zero?
314
319
  0
@@ -323,31 +328,31 @@ module Bundler
323
328
 
324
329
  def verify_gemfile_dependencies_are_found!(requirements)
325
330
  requirements.each do |requirement|
326
- next if requirement.name == 'bundler'
327
- if search_for(requirement).empty?
328
- if base = @base[requirement.name] and !base.empty?
329
- version = base.first.version
330
- message = "You have requested:\n" \
331
- " #{requirement.name} #{requirement.requirement}\n\n" \
332
- "The bundle currently has #{requirement.name} locked at #{version}.\n" \
333
- "Try running `bundle update #{requirement.name}`"
334
- elsif requirement.source
335
- name = requirement.name
336
- versions = @source_requirements[name][name].map { |s| s.version }
337
- message = "Could not find gem '#{requirement}' in #{requirement.source}.\n"
338
- if versions.any?
339
- message << "Source contains '#{name}' at: #{versions.join(', ')}"
340
- else
341
- message << "Source does not contain any versions of '#{requirement}'"
342
- end
331
+ next if requirement.name == "bundler"
332
+ next unless search_for(requirement).empty?
333
+ if (base = @base[requirement.name]) && !base.empty?
334
+ version = base.first.version
335
+ message = "You have requested:\n" \
336
+ " #{requirement.name} #{requirement.requirement}\n\n" \
337
+ "The bundle currently has #{requirement.name} locked at #{version}.\n" \
338
+ "Try running `bundle update #{requirement.name}`\n\n" \
339
+ "If you are updating multiple gems in your Gemfile at once,\n" \
340
+ "try passing them all to `bundle update`"
341
+ elsif requirement.source
342
+ name = requirement.name
343
+ versions = @source_requirements[name][name].map(&:version)
344
+ message = "Could not find gem '#{requirement}' in #{requirement.source}.\n"
345
+ if versions.any?
346
+ message << "Source contains '#{name}' at: #{versions.join(", ")}"
343
347
  else
344
- message = "Could not find gem '#{requirement}' in any of the gem sources " \
345
- "listed in your Gemfile or available on this machine."
348
+ message << "Source does not contain any versions of '#{requirement}'"
346
349
  end
347
- raise GemNotFound, message
350
+ else
351
+ message = "Could not find gem '#{requirement}' in any of the gem sources " \
352
+ "listed in your Gemfile or available on this machine."
348
353
  end
354
+ raise GemNotFound, message
349
355
  end
350
356
  end
351
-
352
357
  end
353
358
  end