rkh-bundler 1.2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +42 -0
- data/CHANGELOG.md +1105 -0
- data/ISSUES.md +67 -0
- data/LICENSE +23 -0
- data/README.md +31 -0
- data/Rakefile +208 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +31 -0
- data/bundler.gemspec +31 -0
- data/lib/bundler.rb +353 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +693 -0
- data/lib/bundler/definition.rb +568 -0
- data/lib/bundler/dep_proxy.rb +43 -0
- data/lib/bundler/dependency.rb +134 -0
- data/lib/bundler/deployment.rb +58 -0
- data/lib/bundler/dsl.rb +256 -0
- data/lib/bundler/endpoint_specification.rb +78 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/fetcher.rb +225 -0
- data/lib/bundler/gem_helper.rb +162 -0
- data/lib/bundler/gem_helpers.rb +23 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +148 -0
- data/lib/bundler/index.rb +187 -0
- data/lib/bundler/installer.rb +190 -0
- data/lib/bundler/lazy_specification.rb +79 -0
- data/lib/bundler/lockfile_parser.rb +127 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +15 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +486 -0
- data/lib/bundler/ruby_version.rb +94 -0
- data/lib/bundler/rubygems_ext.rb +153 -0
- data/lib/bundler/rubygems_integration.rb +394 -0
- data/lib/bundler/runtime.rb +233 -0
- data/lib/bundler/settings.rb +128 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +71 -0
- data/lib/bundler/source.rb +869 -0
- data/lib/bundler/spec_set.rb +137 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
- data/lib/bundler/templates/newgem/README.md.tt +29 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +17 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
- data/lib/bundler/ui.rb +88 -0
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +468 -0
- data/lib/bundler/vendor/thor.rb +358 -0
- data/lib/bundler/vendor/thor/actions.rb +314 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/base.rb +576 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +30 -0
- data/lib/bundler/vendor/thor/group.rb +273 -0
- data/lib/bundler/vendor/thor/invocation.rb +168 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
- data/lib/bundler/vendor/thor/parser/option.rb +120 -0
- data/lib/bundler/vendor/thor/parser/options.rb +172 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +309 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/shell/html.rb +121 -0
- data/lib/bundler/vendor/thor/task.rb +113 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/vendored_thor.rb +7 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/man/bundle-config.ronn +130 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +335 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +83 -0
- data/man/gemfile.5.ronn +324 -0
- data/man/index.txt +6 -0
- data/spec/bundler/dsl_spec.rb +48 -0
- data/spec/bundler/gem_helper_spec.rb +174 -0
- data/spec/bundler/source_spec.rb +25 -0
- data/spec/cache/gems_spec.rb +239 -0
- data/spec/cache/git_spec.rb +124 -0
- data/spec/cache/path_spec.rb +103 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +211 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +402 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +313 -0
- data/spec/install/gems/groups_spec.rb +268 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +208 -0
- data/spec/install/gems/post_install_spec.rb +47 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +814 -0
- data/spec/install/gems/standalone_spec.rb +260 -0
- data/spec/install/gems/sudo_spec.rb +74 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +170 -0
- data/spec/install/git_spec.rb +796 -0
- data/spec/install/invalid_spec.rb +35 -0
- data/spec/install/path_spec.rb +405 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/lock/lockfile_spec.rb +809 -0
- data/spec/other/check_spec.rb +265 -0
- data/spec/other/clean_spec.rb +492 -0
- data/spec/other/config_spec.rb +138 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +229 -0
- data/spec/other/ext_spec.rb +37 -0
- data/spec/other/help_spec.rb +39 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +87 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/outdated_spec.rb +93 -0
- data/spec/other/platform_spec.rb +881 -0
- data/spec/other/show_spec.rb +88 -0
- data/spec/quality_spec.rb +62 -0
- data/spec/realworld/edgecases_spec.rb +177 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +120 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +261 -0
- data/spec/runtime/setup_spec.rb +755 -0
- data/spec/runtime/with_clean_env_spec.rb +80 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint.rb +54 -0
- data/spec/support/artifice/endpoint_500.rb +37 -0
- data/spec/support/artifice/endpoint_api_missing.rb +16 -0
- data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint_extra.rb +27 -0
- data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
- data/spec/support/artifice/endpoint_fallback.rb +18 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +15 -0
- data/spec/support/builders.rb +604 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +317 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +73 -0
- data/spec/support/platforms.rb +86 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +37 -0
- data/spec/support/rubygems_hax/platform.rb +22 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +134 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +338 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bundler
|
2
|
+
module GemHelpers
|
3
|
+
|
4
|
+
GENERIC_CACHE = {}
|
5
|
+
GENERICS = [
|
6
|
+
Gem::Platform.new('java'),
|
7
|
+
Gem::Platform.new('mswin32'),
|
8
|
+
Gem::Platform.new('x86-mingw32'),
|
9
|
+
Gem::Platform::RUBY
|
10
|
+
]
|
11
|
+
|
12
|
+
def generic(p)
|
13
|
+
return p if p == Gem::Platform::RUBY
|
14
|
+
|
15
|
+
GENERIC_CACHE[p] ||= begin
|
16
|
+
found = GENERICS.find do |p2|
|
17
|
+
p2.is_a?(Gem::Platform) && p.os == p2.os
|
18
|
+
end
|
19
|
+
found || Gem::Platform::RUBY
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'set'
|
2
|
+
module Bundler
|
3
|
+
class Graph
|
4
|
+
GRAPH_NAME = :Gemfile
|
5
|
+
|
6
|
+
def initialize(env, output_file, show_version = false, show_requirements = false, output_format = "png")
|
7
|
+
@env = env
|
8
|
+
@output_file = output_file
|
9
|
+
@show_version = show_version
|
10
|
+
@show_requirements = show_requirements
|
11
|
+
@output_format = output_format
|
12
|
+
|
13
|
+
@groups = []
|
14
|
+
@relations = Hash.new {|h, k| h[k] = Set.new}
|
15
|
+
@node_options = {}
|
16
|
+
@edge_options = {}
|
17
|
+
|
18
|
+
_populate_relations
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :groups, :relations, :node_options, :edge_options, :output_file, :output_format
|
22
|
+
|
23
|
+
def viz
|
24
|
+
GraphVizClient.new(self).run
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def _populate_relations
|
30
|
+
relations = Hash.new {|h, k| h[k] = Set.new}
|
31
|
+
parent_dependencies = _groups.values.to_set.flatten
|
32
|
+
while true
|
33
|
+
if parent_dependencies.empty?
|
34
|
+
break
|
35
|
+
else
|
36
|
+
tmp = Set.new
|
37
|
+
parent_dependencies.each do |dependency|
|
38
|
+
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
|
39
|
+
relations[dependency.name] += child_dependencies.to_set
|
40
|
+
@relations[dependency.name] += child_dependencies.map(&:name).to_set
|
41
|
+
tmp += child_dependencies
|
42
|
+
|
43
|
+
@node_options[dependency.name] = _make_label(dependency, :node)
|
44
|
+
child_dependencies.each do |c_dependency|
|
45
|
+
@edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
parent_dependencies = tmp
|
49
|
+
end
|
50
|
+
end
|
51
|
+
@relations
|
52
|
+
end
|
53
|
+
|
54
|
+
def _groups
|
55
|
+
relations = Hash.new {|h, k| h[k] = Set.new}
|
56
|
+
@env.current_dependencies.each do |dependency|
|
57
|
+
dependency.groups.each do |group|
|
58
|
+
relations[group.to_s].add(dependency)
|
59
|
+
@relations[group.to_s].add(dependency.name)
|
60
|
+
|
61
|
+
@node_options[group.to_s] ||= _make_label(group, :node)
|
62
|
+
@edge_options["#{group}_#{dependency.name}"] = _make_label(dependency, :edge)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
@groups = relations.keys
|
66
|
+
relations
|
67
|
+
end
|
68
|
+
|
69
|
+
def _make_label(symbol_or_string_or_dependency, element_type)
|
70
|
+
case element_type.to_sym
|
71
|
+
when :node
|
72
|
+
if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
|
73
|
+
label = symbol_or_string_or_dependency.name.dup
|
74
|
+
label << "\n#{symbol_or_string_or_dependency.to_spec.version.to_s}" if @show_version
|
75
|
+
else
|
76
|
+
label = symbol_or_string_or_dependency.to_s
|
77
|
+
end
|
78
|
+
when :edge
|
79
|
+
label = nil
|
80
|
+
if symbol_or_string_or_dependency.respond_to?(:requirements_list) && @show_requirements
|
81
|
+
tmp = symbol_or_string_or_dependency.requirements_list.join(", ")
|
82
|
+
label = tmp if tmp != ">= 0"
|
83
|
+
end
|
84
|
+
else
|
85
|
+
raise ArgumentError, "2nd argument is invalid"
|
86
|
+
end
|
87
|
+
label.nil? ? {} : { :label => label }
|
88
|
+
end
|
89
|
+
|
90
|
+
class GraphVizClient
|
91
|
+
def initialize(graph_instance)
|
92
|
+
@graph_name = graph_instance.class::GRAPH_NAME
|
93
|
+
@groups = graph_instance.groups
|
94
|
+
@relations = graph_instance.relations
|
95
|
+
@node_options = graph_instance.node_options
|
96
|
+
@edge_options = graph_instance.edge_options
|
97
|
+
@output_file = graph_instance.output_file
|
98
|
+
@output_format = graph_instance.output_format
|
99
|
+
end
|
100
|
+
|
101
|
+
def g
|
102
|
+
require 'graphviz'
|
103
|
+
@g ||= ::GraphViz.digraph(@graph_name, {:concentrate => true, :normalize => true, :nodesep => 0.55}) do |g|
|
104
|
+
g.edge[:weight] = 2
|
105
|
+
g.edge[:fontname] = g.node[:fontname] = 'Arial, Helvetica, SansSerif'
|
106
|
+
g.edge[:fontsize] = 12
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def run
|
111
|
+
@groups.each do |group|
|
112
|
+
g.add_nodes(
|
113
|
+
group,
|
114
|
+
{:style => 'filled',
|
115
|
+
:fillcolor => '#B9B9D5',
|
116
|
+
:shape => "box3d",
|
117
|
+
:fontsize => 16}.merge(@node_options[group])
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
@relations.each do |parent, children|
|
122
|
+
children.each do |child|
|
123
|
+
if @groups.include?(parent)
|
124
|
+
g.add_nodes(child, {:style => 'filled', :fillcolor => '#B9B9D5'}.merge(@node_options[child]))
|
125
|
+
g.add_edges(parent, child, {:constraint => false}.merge(@edge_options["#{parent}_#{child}"]))
|
126
|
+
else
|
127
|
+
g.add_nodes(child, @node_options[child])
|
128
|
+
g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
if @output_format.to_s == "debug"
|
134
|
+
$stdout.puts g.output :none => String
|
135
|
+
Bundler.ui.info "debugging bundle viz..."
|
136
|
+
else
|
137
|
+
begin
|
138
|
+
g.output @output_format.to_sym => "#{@output_file}.#{@output_format}"
|
139
|
+
Bundler.ui.info "#{@output_file}.#{@output_format}"
|
140
|
+
rescue ArgumentError => e
|
141
|
+
$stderr.puts "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb"
|
142
|
+
raise e
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Index
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def self.build
|
8
|
+
i = new
|
9
|
+
yield i
|
10
|
+
i
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :specs, :sources
|
14
|
+
protected :specs
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@sources = []
|
18
|
+
@cache = {}
|
19
|
+
@specs = Hash.new { |h,k| h[k] = [] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize_copy(o)
|
23
|
+
super
|
24
|
+
@sources = @sources.dup
|
25
|
+
@cache = {}
|
26
|
+
@specs = Hash.new { |h,k| h[k] = [] }
|
27
|
+
|
28
|
+
o.specs.each do |name, array|
|
29
|
+
@specs[name] = array.dup
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
"<Index sources=#{sources.map{|s| s.inspect}} specs.size=#{specs.size}>"
|
35
|
+
end
|
36
|
+
|
37
|
+
def empty?
|
38
|
+
each { return false }
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Search this index's specs, and any source indexes that this index knows
|
43
|
+
# about, returning all of the results.
|
44
|
+
def search(query, base = nil)
|
45
|
+
results = local_search(query, base)
|
46
|
+
seen = Set.new(results.map { |spec| [spec.name, spec.version, spec.platform] })
|
47
|
+
|
48
|
+
@sources.each do |source|
|
49
|
+
source.search(query, base).each do |spec|
|
50
|
+
results << spec unless seen.include?([spec.name, spec.version, spec.platform])
|
51
|
+
seen << [spec.name, spec.version, spec.platform]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
results
|
56
|
+
end
|
57
|
+
|
58
|
+
def local_search(query, base = nil)
|
59
|
+
case query
|
60
|
+
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
|
61
|
+
when String then specs_by_name(query)
|
62
|
+
when Gem::Dependency then search_by_dependency(query, base)
|
63
|
+
else
|
64
|
+
raise "You can't search for a #{query.inspect}."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def source_types
|
69
|
+
sources.map{|s| s.class }.uniq
|
70
|
+
end
|
71
|
+
|
72
|
+
alias [] search
|
73
|
+
|
74
|
+
def <<(spec)
|
75
|
+
arr = specs_by_name(spec.name)
|
76
|
+
|
77
|
+
arr.delete_if do |s|
|
78
|
+
same_version?(s.version, spec.version) && s.platform == spec.platform
|
79
|
+
end
|
80
|
+
|
81
|
+
arr << spec
|
82
|
+
spec
|
83
|
+
end
|
84
|
+
|
85
|
+
def each(&blk)
|
86
|
+
specs.values.each do |specs|
|
87
|
+
specs.each(&blk)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# returns a list of the dependencies
|
92
|
+
def unmet_dependency_names
|
93
|
+
dependency_names = specs.values.map do |array_of_s|
|
94
|
+
array_of_s.map do |s|
|
95
|
+
s.dependencies.map{|d| d.name }
|
96
|
+
end
|
97
|
+
end.flatten.uniq
|
98
|
+
dependency_names.select{|name| specs_by_name(name).empty? }
|
99
|
+
end
|
100
|
+
|
101
|
+
def use(other, override_dupes = false)
|
102
|
+
return unless other
|
103
|
+
other.each do |s|
|
104
|
+
if (dupes = search_by_spec(s)) && dupes.any?
|
105
|
+
next unless override_dupes
|
106
|
+
@specs[s.name] -= dupes
|
107
|
+
end
|
108
|
+
@specs[s.name] << s
|
109
|
+
end
|
110
|
+
self
|
111
|
+
end
|
112
|
+
|
113
|
+
def size
|
114
|
+
@sources.inject(@specs.size) do |size, source|
|
115
|
+
size += source.size
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def ==(o)
|
120
|
+
all? do |spec|
|
121
|
+
other_spec = o[spec].first
|
122
|
+
(spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_source(index)
|
127
|
+
if index.is_a?(Index)
|
128
|
+
@sources << index
|
129
|
+
@sources.uniq! # need to use uniq! here instead of checking for the item before adding
|
130
|
+
else
|
131
|
+
raise ArgumentError, "Source must be an index, not #{index.class}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def specs_by_name(name)
|
138
|
+
@specs[name]
|
139
|
+
end
|
140
|
+
|
141
|
+
def search_by_dependency(dependency, base = nil)
|
142
|
+
@cache[base || false] ||= {}
|
143
|
+
@cache[base || false][dependency] ||= begin
|
144
|
+
specs = specs_by_name(dependency.name) + (base || [])
|
145
|
+
found = specs.select do |spec|
|
146
|
+
if base # allow all platforms when searching from a lockfile
|
147
|
+
dependency.matches_spec?(spec)
|
148
|
+
else
|
149
|
+
dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
wants_prerelease = dependency.requirement.prerelease?
|
154
|
+
only_prerelease = specs.all? {|spec| spec.version.prerelease? }
|
155
|
+
|
156
|
+
unless wants_prerelease || only_prerelease
|
157
|
+
found.reject! { |spec| spec.version.prerelease? }
|
158
|
+
end
|
159
|
+
|
160
|
+
found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def search_by_spec(spec)
|
165
|
+
specs_by_name(spec.name).select do |s|
|
166
|
+
same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
if RUBY_VERSION < '1.9'
|
171
|
+
def same_version?(a, b)
|
172
|
+
regex = /^(.*?)(?:\.0)*$/
|
173
|
+
a.to_s[regex, 1] == b.to_s[regex, 1]
|
174
|
+
end
|
175
|
+
else
|
176
|
+
def same_version?(a, b)
|
177
|
+
a == b
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def spec_satisfies_dependency?(spec, dep)
|
182
|
+
return false unless dep.name === spec.name
|
183
|
+
dep.requirement.satisfied_by?(spec.version)
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'rubygems/dependency_installer'
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
class Installer < Environment
|
6
|
+
class << self
|
7
|
+
attr_accessor :post_install_messages
|
8
|
+
end
|
9
|
+
|
10
|
+
# Begins the installation process for Bundler.
|
11
|
+
# For more information see the #run method on this class.
|
12
|
+
def self.install(root, definition, options = {})
|
13
|
+
installer = new(root, definition)
|
14
|
+
installer.run(options)
|
15
|
+
installer
|
16
|
+
end
|
17
|
+
|
18
|
+
# Runs the install procedures for a specific Gemfile.
|
19
|
+
#
|
20
|
+
# Firstly, this method will check to see if Bundler.bundle_path exists
|
21
|
+
# and if not then will create it. This is usually the location of gems
|
22
|
+
# on the system, be it RVM or at a system path.
|
23
|
+
#
|
24
|
+
# Secondly, it checks if Bundler has been configured to be "frozen"
|
25
|
+
# Frozen ensures that the Gemfile and the Gemfile.lock file are matching.
|
26
|
+
# This stops a situation where a developer may update the Gemfile but may not run
|
27
|
+
# `bundle install`, which leads to the Gemfile.lock file not being correctly updated.
|
28
|
+
# If this file is not correctly updated then any other developer running
|
29
|
+
# `bundle install` will potentially not install the correct gems.
|
30
|
+
#
|
31
|
+
# Thirdly, Bundler checks if there are any dependencies specified in the Gemfile using
|
32
|
+
# Bundler::Environment#dependencies. If there are no dependencies specified then
|
33
|
+
# Bundler returns a warning message stating so and this method returns.
|
34
|
+
#
|
35
|
+
# Fourthly, Bundler checks if the default lockfile (Gemfile.lock) exists, and if so
|
36
|
+
# then proceeds to set up a defintion based on the default gemfile (Gemfile) and the
|
37
|
+
# default lock file (Gemfile.lock). However, this is not the case if the platform is different
|
38
|
+
# to that which is specified in Gemfile.lock, or if there are any missing specs for the gems.
|
39
|
+
#
|
40
|
+
# Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote.
|
41
|
+
# This then leads into the gems being installed, along with stubs for their executables,
|
42
|
+
# but only if the --binstubs option has been passed or Bundler.options[:bin] has been set
|
43
|
+
# earlier.
|
44
|
+
#
|
45
|
+
# Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time
|
46
|
+
# that a user runs `bundle install` they will receive any updates from this process.
|
47
|
+
#
|
48
|
+
# Finally: TODO add documentation for how the standalone process works.
|
49
|
+
def run(options)
|
50
|
+
# Create the BUNDLE_PATH directory
|
51
|
+
begin
|
52
|
+
Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist?
|
53
|
+
rescue Errno::EEXIST
|
54
|
+
raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
|
55
|
+
"because of an invalid symlink. Remove the symlink so the directory can be created."
|
56
|
+
end
|
57
|
+
|
58
|
+
if Bundler.settings[:frozen]
|
59
|
+
@definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
|
60
|
+
end
|
61
|
+
|
62
|
+
if dependencies.empty?
|
63
|
+
Bundler.ui.warn "The Gemfile specifies no dependencies"
|
64
|
+
lock
|
65
|
+
return
|
66
|
+
end
|
67
|
+
|
68
|
+
if Bundler.default_lockfile.exist? && !options["update"]
|
69
|
+
begin
|
70
|
+
tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
|
71
|
+
local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
|
72
|
+
rescue BundlerError
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Since we are installing, we can resolve the definition
|
77
|
+
# using remote specs
|
78
|
+
unless local
|
79
|
+
options["local"] ?
|
80
|
+
@definition.resolve_with_cache! :
|
81
|
+
@definition.resolve_remotely!
|
82
|
+
end
|
83
|
+
|
84
|
+
# Must install gems in the order that the resolver provides
|
85
|
+
# as dependencies might actually affect the installation of
|
86
|
+
# the gem.
|
87
|
+
Installer.post_install_messages = {}
|
88
|
+
specs.each do |spec|
|
89
|
+
install_gem_from_spec(spec, options[:standalone])
|
90
|
+
end
|
91
|
+
|
92
|
+
lock
|
93
|
+
generate_standalone(options[:standalone]) if options[:standalone]
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def install_gem_from_spec(spec, standalone = false)
|
99
|
+
# Download the gem to get the spec, because some specs that are returned
|
100
|
+
# by rubygems.org are broken and wrong.
|
101
|
+
Bundler::Fetcher.fetch(spec) if spec.source.is_a?(Bundler::Source::Rubygems)
|
102
|
+
|
103
|
+
# Fetch the build settings, if there are any
|
104
|
+
settings = Bundler.settings["build.#{spec.name}"]
|
105
|
+
Bundler.rubygems.with_build_args [settings] do
|
106
|
+
spec.source.install(spec)
|
107
|
+
Bundler.ui.debug "from #{spec.loaded_from} "
|
108
|
+
end
|
109
|
+
|
110
|
+
# newline comes after installing, some gems say "with native extensions"
|
111
|
+
Bundler.ui.info ""
|
112
|
+
if Bundler.settings[:bin]
|
113
|
+
standalone ? generate_standalone_bundler_executable_stubs(spec) : generate_bundler_executable_stubs(spec)
|
114
|
+
end
|
115
|
+
|
116
|
+
FileUtils.rm_rf(Bundler.tmp)
|
117
|
+
rescue Exception => e
|
118
|
+
# install hook failed
|
119
|
+
raise e if e.is_a?(Bundler::InstallHookError)
|
120
|
+
|
121
|
+
# other failure, likely a native extension build failure
|
122
|
+
Bundler.ui.info ""
|
123
|
+
Bundler.ui.warn "#{e.class}: #{e.message}"
|
124
|
+
msg = "An error occurred while installing #{spec.name} (#{spec.version}),"
|
125
|
+
msg << " and Bundler cannot continue.\nMake sure that `gem install"
|
126
|
+
msg << " #{spec.name} -v '#{spec.version}'` succeeds before bundling."
|
127
|
+
raise Bundler::InstallError, msg
|
128
|
+
end
|
129
|
+
|
130
|
+
def generate_bundler_executable_stubs(spec)
|
131
|
+
bin_path = Bundler.bin_path
|
132
|
+
template = File.read(File.expand_path('../templates/Executable', __FILE__))
|
133
|
+
relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
|
134
|
+
ruby_command = Thor::Util.ruby_command
|
135
|
+
|
136
|
+
spec.executables.each do |executable|
|
137
|
+
next if executable == "bundle"
|
138
|
+
File.open "#{bin_path}/#{executable}", 'w', 0755 do |f|
|
139
|
+
f.puts ERB.new(template, nil, '-').result(binding)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def generate_standalone_bundler_executable_stubs(spec)
|
145
|
+
bin_path = Bundler.bin_path
|
146
|
+
template = File.read(File.expand_path('../templates/Executable.standalone', __FILE__))
|
147
|
+
ruby_command = Thor::Util.ruby_command
|
148
|
+
|
149
|
+
spec.executables.each do |executable|
|
150
|
+
next if executable == "bundle"
|
151
|
+
standalone_path = Pathname(Bundler.settings[:path]).expand_path.relative_path_from(bin_path)
|
152
|
+
executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
|
153
|
+
File.open "#{bin_path}/#{executable}", 'w', 0755 do |f|
|
154
|
+
f.puts ERB.new(template, nil, '-').result(binding)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def generate_standalone(groups)
|
160
|
+
standalone_path = Bundler.settings[:path]
|
161
|
+
bundler_path = File.join(standalone_path, "bundler")
|
162
|
+
FileUtils.mkdir_p(bundler_path)
|
163
|
+
|
164
|
+
paths = []
|
165
|
+
|
166
|
+
if groups.empty?
|
167
|
+
specs = Bundler.definition.requested_specs
|
168
|
+
else
|
169
|
+
specs = Bundler.definition.specs_for groups.map { |g| g.to_sym }
|
170
|
+
end
|
171
|
+
|
172
|
+
specs.each do |spec|
|
173
|
+
next if spec.name == "bundler"
|
174
|
+
|
175
|
+
spec.require_paths.each do |path|
|
176
|
+
full_path = File.join(spec.full_gem_path, path)
|
177
|
+
paths << Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
File.open File.join(bundler_path, "setup.rb"), "w" do |file|
|
183
|
+
file.puts "path = File.expand_path('..', __FILE__)"
|
184
|
+
paths.each do |path|
|
185
|
+
file.puts %{$:.unshift File.expand_path("\#{path}/#{path}")}
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|