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.
- checksums.yaml +4 -4
- data/.rubocop.yml +105 -0
- data/.rubocop_todo.yml +120 -0
- data/.travis.yml +8 -23
- data/CHANGELOG.md +69 -0
- data/CODE_OF_CONDUCT.md +6 -4
- data/DEVELOPMENT.md +4 -5
- data/README.md +2 -2
- data/Rakefile +70 -87
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +17 -15
- data/exe/bundle +20 -0
- data/{bin → exe}/bundle_ruby +6 -4
- data/exe/bundler +20 -0
- data/lib/bundler.rb +98 -119
- data/lib/bundler/capistrano.rb +2 -2
- data/lib/bundler/cli.rb +85 -74
- data/lib/bundler/cli/binstubs.rb +1 -2
- data/lib/bundler/cli/cache.rb +0 -1
- data/lib/bundler/cli/check.rb +7 -5
- data/lib/bundler/cli/clean.rb +0 -1
- data/lib/bundler/cli/common.rb +6 -7
- data/lib/bundler/cli/config.rb +69 -56
- data/lib/bundler/cli/console.rb +8 -8
- data/lib/bundler/cli/exec.rb +4 -3
- data/lib/bundler/cli/gem.rb +50 -39
- data/lib/bundler/cli/init.rb +5 -6
- data/lib/bundler/cli/inject.rb +1 -2
- data/lib/bundler/cli/install.rb +18 -21
- data/lib/bundler/cli/lock.rb +8 -3
- data/lib/bundler/cli/open.rb +4 -5
- data/lib/bundler/cli/outdated.rb +7 -8
- data/lib/bundler/cli/package.rb +1 -1
- data/lib/bundler/cli/platform.rb +2 -3
- data/lib/bundler/cli/show.rb +9 -9
- data/lib/bundler/cli/update.rb +2 -3
- data/lib/bundler/cli/viz.rb +1 -2
- data/lib/bundler/constants.rb +1 -1
- data/lib/bundler/current_ruby.rb +38 -3
- data/lib/bundler/definition.rb +83 -88
- data/lib/bundler/dep_proxy.rb +11 -9
- data/lib/bundler/dependency.rb +26 -11
- data/lib/bundler/deployment.rb +2 -2
- data/lib/bundler/deprecate.rb +3 -3
- data/lib/bundler/dsl.rb +63 -44
- data/lib/bundler/env.rb +19 -12
- data/lib/bundler/environment.rb +1 -2
- data/lib/bundler/errors.rb +82 -0
- data/lib/bundler/fetcher.rb +45 -39
- data/lib/bundler/fetcher/base.rb +20 -7
- data/lib/bundler/fetcher/dependency.rb +5 -5
- data/lib/bundler/fetcher/downloader.rb +1 -2
- data/lib/bundler/fetcher/index.rb +4 -7
- data/lib/bundler/friendly_errors.rb +15 -8
- data/lib/bundler/gem_helper.rb +44 -35
- data/lib/bundler/gem_helpers.rb +7 -8
- data/lib/bundler/gem_remote_fetcher.rb +41 -0
- data/lib/bundler/gem_tasks.rb +4 -1
- data/lib/bundler/graph.rb +25 -24
- data/lib/bundler/index.rb +21 -18
- data/lib/bundler/injector.rb +2 -4
- data/lib/bundler/inline.rb +3 -3
- data/lib/bundler/installer.rb +57 -144
- data/lib/bundler/installer/gem_installer.rb +76 -0
- data/lib/bundler/installer/parallel_installer.rb +22 -13
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/lazy_specification.rb +3 -4
- data/lib/bundler/lockfile_parser.rb +21 -19
- data/lib/bundler/match_platform.rb +4 -4
- data/lib/bundler/psyched_yaml.rb +3 -3
- data/lib/bundler/remote_specification.rb +1 -1
- data/lib/bundler/resolver.rb +93 -88
- data/lib/bundler/retry.rb +9 -10
- data/lib/bundler/ruby_dsl.rb +1 -1
- data/lib/bundler/ruby_version.rb +7 -10
- data/lib/bundler/rubygems_ext.rb +32 -27
- data/lib/bundler/{gem_installer.rb → rubygems_gem_installer.rb} +2 -2
- data/lib/bundler/rubygems_integration.rb +85 -70
- data/lib/bundler/runtime.rb +57 -61
- data/lib/bundler/settings.rb +27 -26
- data/lib/bundler/setup.rb +3 -3
- data/lib/bundler/shared_helpers.rb +45 -20
- data/lib/bundler/similarity_detector.rb +19 -21
- data/lib/bundler/source.rb +4 -5
- data/lib/bundler/source/git.rb +29 -31
- data/lib/bundler/source/git/git_proxy.rb +52 -26
- data/lib/bundler/source/path.rb +25 -28
- data/lib/bundler/source/path/installer.rb +4 -4
- data/lib/bundler/source/rubygems.rb +62 -48
- data/lib/bundler/source/rubygems/remote.rb +3 -3
- data/lib/bundler/source_list.rb +4 -4
- data/lib/bundler/spec_set.rb +17 -15
- data/lib/bundler/ssl_certs/certificate_manager.rb +5 -6
- data/lib/bundler/stub_specification.rb +2 -2
- data/lib/bundler/templates/Executable +5 -5
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +42 -6
- data/lib/bundler/templates/newgem/README.md.tt +1 -1
- data/lib/bundler/templates/newgem/Rakefile.tt +4 -2
- data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
- data/lib/bundler/ui.rb +3 -3
- data/lib/bundler/ui/rg_proxy.rb +2 -2
- data/lib/bundler/ui/shell.rb +10 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +82 -71
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +9 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +40 -21
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -0
- data/lib/bundler/vendored_molinillo.rb +1 -1
- data/lib/bundler/vendored_persistent.rb +3 -3
- data/lib/bundler/vendored_thor.rb +2 -2
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +4 -5
- data/man/bundle-config.ronn +4 -2
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +13 -6
- data/man/bundle-lock.ronn +47 -0
- data/man/bundle.ronn +1 -1
- data/man/gemfile.5.ronn +8 -0
- data/man/index.txt +1 -0
- metadata +37 -8
- data/bin/bundle +0 -21
- data/bin/bundler +0 -21
data/lib/bundler/gem_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/vendored_thor" unless defined?(Thor)
|
2
|
+
require "bundler"
|
3
3
|
|
4
4
|
module Bundler
|
5
5
|
class GemHelper
|
@@ -35,35 +35,35 @@ module Bundler
|
|
35
35
|
built_gem_path = nil
|
36
36
|
|
37
37
|
desc "Build #{name}-#{version}.gem into the pkg directory."
|
38
|
-
task
|
38
|
+
task "build" do
|
39
39
|
built_gem_path = build_gem
|
40
40
|
end
|
41
41
|
|
42
42
|
desc "Build and install #{name}-#{version}.gem into system gems."
|
43
|
-
task
|
43
|
+
task "install" => "build" do
|
44
44
|
install_gem(built_gem_path)
|
45
45
|
end
|
46
46
|
|
47
47
|
desc "Build and install #{name}-#{version}.gem into system gems without network access."
|
48
|
-
task
|
48
|
+
task "install:local" => "build" do
|
49
49
|
install_gem(built_gem_path, :local)
|
50
50
|
end
|
51
51
|
|
52
52
|
desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems\n" \
|
53
53
|
"To prevent publishing in Rubygems use `gem_push=no rake release`"
|
54
|
-
task
|
55
|
-
|
54
|
+
task "release", [:remote] => ["build", "release:guard_clean",
|
55
|
+
"release:source_control_push", "release:rubygem_push"] do
|
56
56
|
end
|
57
57
|
|
58
|
-
task
|
58
|
+
task "release:guard_clean" do
|
59
59
|
guard_clean
|
60
60
|
end
|
61
61
|
|
62
|
-
task
|
63
|
-
tag_version { git_push } unless already_tagged?
|
62
|
+
task "release:source_control_push", [:remote] do |_, args|
|
63
|
+
tag_version { git_push(args[:remote]) } unless already_tagged?
|
64
64
|
end
|
65
65
|
|
66
|
-
task
|
66
|
+
task "release:rubygem_push" do
|
67
67
|
rubygem_push(built_gem_path) if gem_push?
|
68
68
|
end
|
69
69
|
|
@@ -72,57 +72,64 @@ module Bundler
|
|
72
72
|
|
73
73
|
def build_gem
|
74
74
|
file_name = nil
|
75
|
-
sh("gem build -V '#{spec_path}'")
|
75
|
+
sh("gem build -V '#{spec_path}'") do
|
76
76
|
file_name = File.basename(built_gem_path)
|
77
|
-
|
78
|
-
FileUtils.mv(built_gem_path,
|
77
|
+
SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
|
78
|
+
FileUtils.mv(built_gem_path, "pkg")
|
79
79
|
Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}."
|
80
|
-
|
81
|
-
File.join(base,
|
80
|
+
end
|
81
|
+
File.join(base, "pkg", file_name)
|
82
82
|
end
|
83
83
|
|
84
84
|
def install_gem(built_gem_path = nil, local = false)
|
85
85
|
built_gem_path ||= build_gem
|
86
|
-
out, _ = sh_with_code("gem install '#{built_gem_path}'#{
|
86
|
+
out, _ = sh_with_code("gem install '#{built_gem_path}'#{" --local" if local}")
|
87
87
|
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
|
88
88
|
Bundler.ui.confirm "#{name} (#{version}) installed."
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
protected
|
92
|
+
|
92
93
|
def rubygem_push(path)
|
93
94
|
if Pathname.new("~/.gem/credentials").expand_path.exist?
|
94
|
-
|
95
|
-
|
95
|
+
allowed_push_host = nil
|
96
|
+
gem_command = "gem push '#{path}'"
|
97
|
+
if gemspec.respond_to?(:metadata)
|
98
|
+
allowed_push_host = @gemspec.metadata["allowed_push_host"]
|
99
|
+
gem_command << " --host #{allowed_push_host}" if allowed_push_host
|
100
|
+
end
|
101
|
+
sh(gem_command)
|
102
|
+
Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}"
|
96
103
|
else
|
97
104
|
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
|
98
105
|
end
|
99
106
|
end
|
100
107
|
|
101
108
|
def built_gem_path
|
102
|
-
Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
|
109
|
+
Dir[File.join(base, "#{name}-*.gem")].sort_by {|f| File.mtime(f) }.last
|
103
110
|
end
|
104
111
|
|
105
|
-
def git_push
|
106
|
-
perform_git_push
|
107
|
-
perform_git_push
|
112
|
+
def git_push(remote = "")
|
113
|
+
perform_git_push remote
|
114
|
+
perform_git_push "#{remote} --tags"
|
108
115
|
Bundler.ui.confirm "Pushed git commits and tags."
|
109
116
|
end
|
110
117
|
|
111
|
-
def perform_git_push(options =
|
118
|
+
def perform_git_push(options = "")
|
112
119
|
cmd = "git push #{options}"
|
113
120
|
out, code = sh_with_code(cmd)
|
114
121
|
raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
|
115
122
|
end
|
116
123
|
|
117
124
|
def already_tagged?
|
118
|
-
if sh(
|
125
|
+
if sh("git tag").split(/\n/).include?(version_tag)
|
119
126
|
Bundler.ui.confirm "Tag #{version_tag} has already been created."
|
120
127
|
true
|
121
128
|
end
|
122
129
|
end
|
123
130
|
|
124
131
|
def guard_clean
|
125
|
-
clean? && committed?
|
132
|
+
clean? && committed? || raise("There are files that need to be committed first.")
|
126
133
|
end
|
127
134
|
|
128
135
|
def clean?
|
@@ -157,24 +164,26 @@ module Bundler
|
|
157
164
|
|
158
165
|
def sh(cmd, &block)
|
159
166
|
out, code = sh_with_code(cmd, &block)
|
160
|
-
code == 0
|
167
|
+
if code == 0
|
168
|
+
out
|
169
|
+
else
|
170
|
+
raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
|
171
|
+
end
|
161
172
|
end
|
162
173
|
|
163
174
|
def sh_with_code(cmd, &block)
|
164
175
|
cmd << " 2>&1"
|
165
|
-
outbuf =
|
176
|
+
outbuf = ""
|
166
177
|
Bundler.ui.debug(cmd)
|
167
|
-
SharedHelpers.chdir(base)
|
178
|
+
SharedHelpers.chdir(base) do
|
168
179
|
outbuf = `#{cmd}`
|
169
|
-
if $? == 0
|
170
|
-
|
171
|
-
end
|
172
|
-
}
|
180
|
+
block.call(outbuf) if $? == 0 && block
|
181
|
+
end
|
173
182
|
[outbuf, $?]
|
174
183
|
end
|
175
184
|
|
176
185
|
def gem_push?
|
177
|
-
! %w
|
186
|
+
! %w(n no nil false off 0).include?(ENV["gem_push"].to_s.downcase)
|
178
187
|
end
|
179
188
|
end
|
180
189
|
end
|
data/lib/bundler/gem_helpers.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
module Bundler
|
2
2
|
module GemHelpers
|
3
|
-
|
4
3
|
GENERIC_CACHE = {}
|
5
4
|
GENERICS = [
|
6
|
-
[Gem::Platform.new(
|
7
|
-
[Gem::Platform.new(
|
8
|
-
[Gem::Platform.new(
|
9
|
-
[Gem::Platform.new(
|
10
|
-
[Gem::Platform.new(
|
11
|
-
[Gem::Platform.new(
|
12
|
-
[Gem::Platform.new(
|
5
|
+
[Gem::Platform.new("java"), Gem::Platform.new("java")],
|
6
|
+
[Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
|
7
|
+
[Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
|
8
|
+
[Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
|
9
|
+
[Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
|
10
|
+
[Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
|
11
|
+
[Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")]
|
13
12
|
]
|
14
13
|
|
15
14
|
def generic(p)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "rubygems/remote_fetcher"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
# Adds support for setting custom HTTP headers when fetching gems from the
|
5
|
+
# server.
|
6
|
+
#
|
7
|
+
# TODO: Get rid of this when and if gemstash only supports RubyGems versions
|
8
|
+
# that contain https://github.com/rubygems/rubygems/commit/3db265cc20b2f813.
|
9
|
+
class GemRemoteFetcher < Gem::RemoteFetcher
|
10
|
+
attr_accessor :headers
|
11
|
+
|
12
|
+
# Extracted from RubyGems 2.4.
|
13
|
+
def fetch_http(uri, last_modified = nil, head = false, depth = 0)
|
14
|
+
fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
|
15
|
+
# beginning of change
|
16
|
+
response = request uri, fetch_type, last_modified do |req|
|
17
|
+
headers.each {|k, v| req.add_field(k, v) } if headers
|
18
|
+
end
|
19
|
+
# end of change
|
20
|
+
|
21
|
+
case response
|
22
|
+
when Net::HTTPOK, Net::HTTPNotModified then
|
23
|
+
response.uri = uri if response.respond_to? :uri
|
24
|
+
head ? response : response.body
|
25
|
+
when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
|
26
|
+
Net::HTTPTemporaryRedirect then
|
27
|
+
raise FetchError.new("too many redirects", uri) if depth > 10
|
28
|
+
|
29
|
+
location = URI.parse response["Location"]
|
30
|
+
|
31
|
+
if https?(uri) && !https?(location)
|
32
|
+
raise FetchError.new("redirecting to non-https resource: #{location}", uri)
|
33
|
+
end
|
34
|
+
|
35
|
+
fetch_http(location, last_modified, head, depth + 1)
|
36
|
+
else
|
37
|
+
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/bundler/gem_tasks.rb
CHANGED
data/lib/bundler/graph.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "set"
|
2
2
|
module Bundler
|
3
3
|
class Graph
|
4
4
|
GRAPH_NAME = :Gemfile
|
@@ -12,7 +12,7 @@ module Bundler
|
|
12
12
|
@without_groups = without.map(&:to_sym)
|
13
13
|
|
14
14
|
@groups = []
|
15
|
-
@relations = Hash.new {|h, k| h[k] = Set.new}
|
15
|
+
@relations = Hash.new {|h, k| h[k] = Set.new }
|
16
16
|
@node_options = {}
|
17
17
|
@edge_options = {}
|
18
18
|
|
@@ -26,11 +26,11 @@ module Bundler
|
|
26
26
|
GraphVizClient.new(self).run
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
private
|
30
30
|
|
31
31
|
def _populate_relations
|
32
32
|
parent_dependencies = _groups.values.to_set.flatten
|
33
|
-
|
33
|
+
loop do
|
34
34
|
if parent_dependencies.empty?
|
35
35
|
break
|
36
36
|
else
|
@@ -54,7 +54,7 @@ module Bundler
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def _groups
|
57
|
-
relations = Hash.new {|h, k| h[k] = Set.new}
|
57
|
+
relations = Hash.new {|h, k| h[k] = Set.new }
|
58
58
|
@env.current_dependencies.each do |dependency|
|
59
59
|
dependency.groups.each do |group|
|
60
60
|
next if @without_groups.include?(group)
|
@@ -75,7 +75,7 @@ module Bundler
|
|
75
75
|
when :node
|
76
76
|
if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
|
77
77
|
label = symbol_or_string_or_dependency.name.dup
|
78
|
-
label << "\n#{symbol_or_string_or_dependency.to_spec.version
|
78
|
+
label << "\n#{symbol_or_string_or_dependency.to_spec.version}" if @show_version
|
79
79
|
else
|
80
80
|
label = symbol_or_string_or_dependency.to_s
|
81
81
|
end
|
@@ -95,19 +95,19 @@ module Bundler
|
|
95
95
|
# method borrow from rubygems/dependency.rb
|
96
96
|
# redefinition of matching_specs will also redefine to_spec and to_specs
|
97
97
|
Gem::Dependency.class_eval do
|
98
|
-
def matching_specs
|
99
|
-
matches = Bundler.load.specs.select
|
100
|
-
|
101
|
-
requirement.satisfied_by?
|
102
|
-
|
98
|
+
def matching_specs(platform_only = false)
|
99
|
+
matches = Bundler.load.specs.select do |spec|
|
100
|
+
name == spec.name &&
|
101
|
+
requirement.satisfied_by?(spec.version)
|
102
|
+
end
|
103
103
|
|
104
104
|
if platform_only
|
105
|
-
matches.
|
106
|
-
|
107
|
-
|
105
|
+
matches.select! do |spec|
|
106
|
+
Gem::Platform.match spec.platform
|
107
|
+
end
|
108
108
|
end
|
109
109
|
|
110
|
-
matches = matches.sort_by
|
110
|
+
matches = matches.sort_by(&:sort_obj) # HACK: shouldn't be needed
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -124,9 +124,9 @@ module Bundler
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def g
|
127
|
-
@g ||= ::GraphViz.digraph(@graph_name,
|
127
|
+
@g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g|
|
128
128
|
g.edge[:weight] = 2
|
129
|
-
g.edge[:fontname] = g.node[:fontname] =
|
129
|
+
g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif"
|
130
130
|
g.edge[:fontsize] = 12
|
131
131
|
end
|
132
132
|
end
|
@@ -134,19 +134,20 @@ module Bundler
|
|
134
134
|
def run
|
135
135
|
@groups.each do |group|
|
136
136
|
g.add_nodes(
|
137
|
-
group,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
group, {
|
138
|
+
:style => "filled",
|
139
|
+
:fillcolor => "#B9B9D5",
|
140
|
+
:shape => "box3d",
|
141
|
+
:fontsize => 16
|
142
|
+
}.merge(@node_options[group])
|
142
143
|
)
|
143
144
|
end
|
144
145
|
|
145
146
|
@relations.each do |parent, children|
|
146
147
|
children.each do |child|
|
147
148
|
if @groups.include?(parent)
|
148
|
-
g.add_nodes(child, {:style =>
|
149
|
-
g.add_edges(parent, child, {:constraint => false}.merge(@edge_options["#{parent}_#{child}"]))
|
149
|
+
g.add_nodes(child, { :style => "filled", :fillcolor => "#B9B9D5" }.merge(@node_options[child]))
|
150
|
+
g.add_edges(parent, child, { :constraint => false }.merge(@edge_options["#{parent}_#{child}"]))
|
150
151
|
else
|
151
152
|
g.add_nodes(child, @node_options[child])
|
152
153
|
g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
|
data/lib/bundler/index.rb
CHANGED
@@ -11,21 +11,24 @@ module Bundler
|
|
11
11
|
end
|
12
12
|
|
13
13
|
attr_reader :specs, :all_specs, :sources
|
14
|
-
protected
|
14
|
+
protected :specs, :all_specs
|
15
|
+
|
16
|
+
RUBY = "ruby".freeze
|
17
|
+
NULL = "\0".freeze
|
15
18
|
|
16
19
|
def initialize
|
17
20
|
@sources = []
|
18
21
|
@cache = {}
|
19
|
-
@specs = Hash.new {
|
20
|
-
@all_specs = Hash.new {
|
22
|
+
@specs = Hash.new {|h, k| h[k] = {} }
|
23
|
+
@all_specs = Hash.new {|h, k| h[k] = [] }
|
21
24
|
end
|
22
25
|
|
23
26
|
def initialize_copy(o)
|
24
27
|
super
|
25
28
|
@sources = @sources.dup
|
26
29
|
@cache = {}
|
27
|
-
@specs = Hash.new {
|
28
|
-
@all_specs = Hash.new {
|
30
|
+
@specs = Hash.new {|h, k| h[k] = {} }
|
31
|
+
@all_specs = Hash.new {|h, k| h[k] = [] }
|
29
32
|
|
30
33
|
o.specs.each do |name, hash|
|
31
34
|
@specs[name] = hash.dup
|
@@ -36,7 +39,7 @@ module Bundler
|
|
36
39
|
end
|
37
40
|
|
38
41
|
def inspect
|
39
|
-
"#<#{self.class}:0x#{object_id} sources=#{sources.map
|
42
|
+
"#<#{self.class}:0x#{object_id} sources=#{sources.map(&:inspect)} specs.size=#{specs.size}>"
|
40
43
|
end
|
41
44
|
|
42
45
|
def empty?
|
@@ -56,7 +59,7 @@ module Bundler
|
|
56
59
|
# about, returning all of the results.
|
57
60
|
def search(query, base = nil)
|
58
61
|
results = local_search(query, base)
|
59
|
-
seen = Set.new(results.map {
|
62
|
+
seen = Set.new(results.map {|spec| [spec.name, spec.version, spec.platform] })
|
60
63
|
|
61
64
|
@sources.each do |source|
|
62
65
|
source.search(query, base).each do |spec|
|
@@ -68,7 +71,7 @@ module Bundler
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
71
|
-
results.sort_by {|s| [s.version, s.platform.to_s ==
|
74
|
+
results.sort_by {|s| [s.version, s.platform.to_s == RUBY ? NULL : s.platform.to_s] }
|
72
75
|
end
|
73
76
|
|
74
77
|
def local_search(query, base = nil)
|
@@ -76,12 +79,13 @@ module Bundler
|
|
76
79
|
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
|
77
80
|
when String then specs_by_name(query)
|
78
81
|
when Gem::Dependency then search_by_dependency(query, base)
|
82
|
+
when DepProxy then search_by_dependency(query.dep, base)
|
79
83
|
else
|
80
84
|
raise "You can't search for a #{query.inspect}."
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
|
-
|
88
|
+
alias_method :[], :search
|
85
89
|
|
86
90
|
def <<(spec)
|
87
91
|
@specs[spec.name]["#{spec.version}-#{spec.platform}"] = spec
|
@@ -98,13 +102,13 @@ module Bundler
|
|
98
102
|
# returns a list of the dependencies
|
99
103
|
def unmet_dependency_names
|
100
104
|
names = dependency_names
|
101
|
-
names.delete_if{|n| n == "bundler" }
|
102
|
-
names.select{|n| search(n).empty? }
|
105
|
+
names.delete_if {|n| n == "bundler" }
|
106
|
+
names.select {|n| search(n).empty? }
|
103
107
|
end
|
104
108
|
|
105
109
|
def dependency_names
|
106
110
|
names = []
|
107
|
-
each{|s| names.push(*s.dependencies.map
|
111
|
+
each {|s| names.push(*s.dependencies.map(&:name)) }
|
108
112
|
names.uniq
|
109
113
|
end
|
110
114
|
|
@@ -127,10 +131,10 @@ module Bundler
|
|
127
131
|
end
|
128
132
|
end
|
129
133
|
|
130
|
-
def ==(
|
134
|
+
def ==(other)
|
131
135
|
all? do |spec|
|
132
|
-
other_spec =
|
133
|
-
(spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
|
136
|
+
other_spec = other[spec].first
|
137
|
+
other_spec && (spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
|
134
138
|
end
|
135
139
|
end
|
136
140
|
|
@@ -165,7 +169,7 @@ module Bundler
|
|
165
169
|
only_prerelease = specs.all? {|spec| spec.version.prerelease? }
|
166
170
|
|
167
171
|
unless wants_prerelease || only_prerelease
|
168
|
-
found.reject! {
|
172
|
+
found.reject! {|spec| spec.version.prerelease? }
|
169
173
|
end
|
170
174
|
|
171
175
|
found
|
@@ -177,7 +181,7 @@ module Bundler
|
|
177
181
|
spec ? [spec] : []
|
178
182
|
end
|
179
183
|
|
180
|
-
if RUBY_VERSION <
|
184
|
+
if RUBY_VERSION < "1.9"
|
181
185
|
def same_version?(a, b)
|
182
186
|
regex = /^(.*?)(?:\.0)*$/
|
183
187
|
a.to_s[regex, 1] == b.to_s[regex, 1]
|
@@ -192,6 +196,5 @@ module Bundler
|
|
192
196
|
return false unless dep.name == spec.name
|
193
197
|
dep.requirement.satisfied_by?(spec.version)
|
194
198
|
end
|
195
|
-
|
196
199
|
end
|
197
200
|
end
|