bundler 1.8.9 → 1.9.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -7
  3. data/CHANGELOG.md +8 -33
  4. data/Rakefile +51 -8
  5. data/lib/bundler/cli/gem.rb +20 -1
  6. data/lib/bundler/cli/install.rb +1 -1
  7. data/lib/bundler/definition.rb +8 -12
  8. data/lib/bundler/dep_proxy.rb +2 -2
  9. data/lib/bundler/installer.rb +12 -18
  10. data/lib/bundler/resolver.rb +168 -383
  11. data/lib/bundler/rubygems_ext.rb +1 -1
  12. data/lib/bundler/rubygems_integration.rb +6 -14
  13. data/lib/bundler/runtime.rb +3 -0
  14. data/lib/bundler/shared_helpers.rb +12 -7
  15. data/lib/bundler/source.rb +0 -5
  16. data/lib/bundler/source/path.rb +2 -1
  17. data/lib/bundler/source/path/installer.rb +0 -2
  18. data/lib/bundler/source/rubygems.rb +9 -11
  19. data/lib/bundler/templates/newgem/Rakefile.tt +0 -1
  20. data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  21. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb +5 -0
  22. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb +266 -0
  23. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb +69 -0
  24. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb +3 -0
  25. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb +90 -0
  26. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb +63 -0
  27. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb +412 -0
  28. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb +43 -0
  29. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb +43 -0
  30. data/lib/bundler/vendor/{thor.rb → thor-0.19.1/lib/thor.rb} +57 -53
  31. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions.rb +34 -34
  32. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_file.rb +7 -7
  33. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_link.rb +2 -2
  34. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/directory.rb +11 -11
  35. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/empty_directory.rb +2 -2
  36. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/file_manipulation.rb +14 -14
  37. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/inject_into_file.rb +24 -24
  38. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/base.rb +71 -71
  39. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/command.rb +8 -8
  40. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/hash_with_indifferent_access.rb +2 -2
  41. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/io_binary_read.rb +1 -1
  42. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/ordered_hash.rb +2 -2
  43. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/error.rb +3 -3
  44. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/group.rb +27 -27
  45. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/invocation.rb +16 -11
  46. data/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb +17 -0
  47. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/basic.rb +2 -2
  48. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/readline.rb +7 -7
  49. data/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb +4 -0
  50. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/argument.rb +7 -7
  51. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/arguments.rb +10 -10
  52. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/option.rb +14 -10
  53. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/options.rb +12 -12
  54. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/rake_compat.rb +14 -14
  55. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/runner.rb +76 -76
  56. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell.rb +18 -18
  57. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/basic.rb +31 -30
  58. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/color.rb +10 -10
  59. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/html.rb +28 -28
  60. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/util.rb +61 -61
  61. data/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb +3 -0
  62. data/lib/bundler/vendored_molinillo.rb +5 -0
  63. data/lib/bundler/vendored_thor.rb +3 -6
  64. data/lib/bundler/version.rb +1 -1
  65. metadata +44 -35
  66. data/lib/bundler/vendor/.document +0 -0
  67. data/lib/bundler/vendor/thor/line_editor.rb +0 -17
  68. data/lib/bundler/vendor/thor/parser.rb +0 -4
  69. data/lib/bundler/vendor/thor/version.rb +0 -3
@@ -72,7 +72,7 @@ module Gem
72
72
  end
73
73
 
74
74
  def to_gemfile(path = nil)
75
- gemfile = "source :gemcutter\n"
75
+ gemfile = "source 'https://rubygems.org'\n"
76
76
  gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
77
77
  unless development_dependencies.empty?
78
78
  gemfile << "\n"
@@ -161,14 +161,12 @@ module Bundler
161
161
  end
162
162
 
163
163
  def with_build_args(args)
164
- ext_lock.synchronize do
165
- old_args = self.build_args
166
- begin
167
- self.build_args = args
168
- yield
169
- ensure
170
- self.build_args = old_args
171
- end
164
+ old_args = self.build_args
165
+ begin
166
+ self.build_args = args
167
+ yield
168
+ ensure
169
+ self.build_args = old_args
172
170
  end
173
171
  end
174
172
 
@@ -585,12 +583,6 @@ module Bundler
585
583
  def ext_lock
586
584
  Gem::Ext::Builder::CHDIR_MONITOR
587
585
  end
588
-
589
- def find_name(name)
590
- Gem::Specification.stubs.find_all do |spec|
591
- spec.name == name
592
- end.map(&:to_spec)
593
- end
594
586
  end
595
587
 
596
588
  end
@@ -88,6 +88,9 @@ module Bundler
88
88
  raise if $1 != namespaced_file
89
89
  end
90
90
  end
91
+ rescue => e
92
+ Bundler.ui.debug e
93
+ Bundler.ui.warn "Unable to require #{required_file}. #{e.class}: #{e.message}."
91
94
  end
92
95
  end
93
96
  end
@@ -35,27 +35,32 @@ module Bundler
35
35
  end
36
36
 
37
37
  def default_bundle_dir
38
- bundle_dir = find_directory(".bundle")
39
- return nil unless bundle_dir
40
-
41
38
  global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle")
42
- return nil if bundle_dir == global_bundle_dir
39
+ bundle_dir = find_directory(".bundle")
43
40
 
44
- Pathname.new(bundle_dir)
41
+ if bundle_dir && bundle_dir != global_bundle_dir
42
+ Pathname.new(bundle_dir)
43
+ else
44
+ nil
45
+ end
45
46
  end
46
47
 
47
48
  def in_bundle?
48
49
  find_gemfile
49
50
  end
50
51
 
52
+ def chdir_monitor
53
+ Bundler.rubygems.ext_lock
54
+ end
55
+
51
56
  def chdir(dir, &blk)
52
- Bundler.rubygems.ext_lock.synchronize do
57
+ chdir_monitor.synchronize do
53
58
  Dir.chdir dir, &blk
54
59
  end
55
60
  end
56
61
 
57
62
  def pwd
58
- Bundler.rubygems.ext_lock.synchronize do
63
+ chdir_monitor.synchronize do
59
64
  Dir.pwd
60
65
  end
61
66
  end
@@ -37,10 +37,5 @@ module Bundler
37
37
  def can_lock?(spec)
38
38
  spec.source == self
39
39
  end
40
-
41
- def include?(other)
42
- other == self
43
- end
44
-
45
40
  end
46
41
  end
@@ -130,7 +130,8 @@ module Bundler
130
130
  index = Index.new
131
131
 
132
132
  if File.directory?(expanded_path)
133
- Dir["#{expanded_path}/#{@glob}"].each do |file|
133
+ # We sort depth-first since `<<` will override the earlier-found specs
134
+ Dir["#{expanded_path}/#{@glob}"].sort_by { |p| -p.split(File::SEPARATOR).size }.each do |file|
134
135
  spec = Bundler.load_gemspec(file)
135
136
  if spec
136
137
  spec.loaded_from = file.to_s
@@ -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"
@@ -36,15 +36,11 @@ module Bundler
36
36
  end
37
37
 
38
38
  def eql?(o)
39
- o.is_a?(Rubygems) && o.credless_remotes == credless_remotes
39
+ o.is_a?(Rubygems) && remotes_equal?(o.remotes)
40
40
  end
41
41
 
42
42
  alias == eql?
43
43
 
44
- def include?(o)
45
- o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
46
- end
47
-
48
44
  def can_lock?(spec)
49
45
  spec.source.is_a?(Rubygems)
50
46
  end
@@ -204,12 +200,6 @@ module Bundler
204
200
 
205
201
  protected
206
202
 
207
- def credless_remotes
208
- remotes.map(&method(:suppress_configured_credentials))
209
- end
210
-
211
- private
212
-
213
203
  def source_uris_for_spec(spec)
214
204
  specs.search_all(spec.name).inject([]) do |uris, s|
215
205
  uris << s.source_uri.without_credentials if s.source_uri
@@ -217,6 +207,8 @@ module Bundler
217
207
  end
218
208
  end
219
209
 
210
+ private
211
+
220
212
  def loaded_from(spec)
221
213
  "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
222
214
  end
@@ -315,6 +307,8 @@ module Bundler
315
307
  # the gemspecs of those gems, if the non-api sites contain more than
316
308
  # about 100 gems, we just treat all sites as non-api for speed.
317
309
  allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
310
+ Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
311
+ " Downloading full index instead..." unless allow_api
318
312
 
319
313
  if allow_api
320
314
  api_fetchers.each do |f|
@@ -376,6 +370,10 @@ module Bundler
376
370
  spec.loaded_from && spec.loaded_from.include?("specifications/default/")
377
371
  end
378
372
 
373
+ def remotes_equal?(other_remotes)
374
+ remotes.map(&method(:suppress_configured_credentials)) == other_remotes.map(&method(:suppress_configured_credentials))
375
+ end
376
+
379
377
  end
380
378
  end
381
379
  end
@@ -14,7 +14,6 @@ RSpec::Core::RakeTask.new(:spec)
14
14
 
15
15
  task :default => :spec
16
16
  <% end -%>
17
-
18
17
  <% if config[:ext] -%>
19
18
  require "rake/extensiontask"
20
19
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
29
29
  end
30
30
 
31
- spec.add_development_dependency "bundler", "~> <%= Bundler::VERSION.split(".")[0..1].join(".") %>"
31
+ spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>"
32
32
  spec.add_development_dependency "rake", "~> 10.0"
33
33
  <%- if config[:ext] -%>
34
34
  spec.add_development_dependency "rake-compiler"
@@ -0,0 +1,5 @@
1
+ require 'molinillo/gem_metadata'
2
+ require 'molinillo/errors'
3
+ require 'molinillo/resolver'
4
+ require 'molinillo/modules/ui'
5
+ require 'molinillo/modules/specification_provider'
@@ -0,0 +1,266 @@
1
+ require 'set'
2
+ require 'tsort'
3
+
4
+ module Bundler::Molinillo
5
+ # A directed acyclic graph that is tuned to hold named dependencies
6
+ class DependencyGraph
7
+ include Enumerable
8
+
9
+ # Enumerates through the vertices of the graph.
10
+ # @return [Array<Vertex>] The graph's vertices.
11
+ def each
12
+ vertices.values.each { |v| yield v }
13
+ end
14
+
15
+ include TSort
16
+
17
+ alias_method :tsort_each_node, :each
18
+
19
+ def tsort_each_child(vertex, &block)
20
+ vertex.successors.each(&block)
21
+ end
22
+
23
+ # Topologically sorts the given vertices.
24
+ # @param [Enumerable<Vertex>] vertices the vertices to be sorted, which must
25
+ # all belong to the same graph.
26
+ # @return [Array<Vertex>] The sorted vertices.
27
+ def self.tsort(vertices)
28
+ TSort.tsort(
29
+ lambda { |b| vertices.each(&b) },
30
+ lambda { |v, &b| (v.successors & vertices).each(&b) }
31
+ )
32
+ end
33
+
34
+ # A directed edge of a {DependencyGraph}
35
+ # @attr [Vertex] origin The origin of the directed edge
36
+ # @attr [Vertex] destination The destination of the directed edge
37
+ # @attr [Array] requirements The requirements the directed edge represents
38
+ Edge = Struct.new(:origin, :destination, :requirements)
39
+
40
+ # @return [{String => Vertex}] vertices that have no {Vertex#predecessors},
41
+ # keyed by by {Vertex#name}
42
+ attr_reader :root_vertices
43
+ # @return [{String => Vertex}] the vertices of the dependency graph, keyed
44
+ # by {Vertex#name}
45
+ attr_reader :vertices
46
+ # @return [Set<Edge>] the edges of the dependency graph
47
+ attr_reader :edges
48
+
49
+ def initialize
50
+ @vertices = {}
51
+ @edges = Set.new
52
+ @root_vertices = {}
53
+ end
54
+
55
+ # Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices}
56
+ # have the correct {Vertex#graph} set
57
+ def initialize_copy(other)
58
+ super
59
+ @vertices = other.vertices.reduce({}) do |vertices, (name, vertex)|
60
+ vertices.tap do |hash|
61
+ hash[name] = vertex.dup.tap { |v| v.graph = self }
62
+ end
63
+ end
64
+ @root_vertices = Hash[vertices.select { |n, _v| other.root_vertices[n] }]
65
+ @edges = other.edges.map do |edge|
66
+ Edge.new(
67
+ vertex_named(edge.origin.name),
68
+ vertex_named(edge.destination.name),
69
+ edge.requirements.dup
70
+ )
71
+ end
72
+ end
73
+
74
+ # @return [String] a string suitable for debugging
75
+ def inspect
76
+ "#{self.class}:#{vertices.values.inspect}"
77
+ end
78
+
79
+ # @return [Boolean] whether the two dependency graphs are equal, determined
80
+ # by a recursive traversal of each {#root_vertices} and its
81
+ # {Vertex#successors}
82
+ def ==(other)
83
+ root_vertices == other.root_vertices
84
+ end
85
+
86
+ # @param [String] name
87
+ # @param [Object] payload
88
+ # @param [Array<String>] parent_names
89
+ # @param [Object] requirement the requirement that is requiring the child
90
+ # @return [void]
91
+ def add_child_vertex(name, payload, parent_names, requirement)
92
+ is_root = parent_names.include?(nil)
93
+ parent_nodes = parent_names.compact.map { |n| vertex_named(n) }
94
+ vertex = vertex_named(name) || if is_root
95
+ add_root_vertex(name, payload)
96
+ else
97
+ add_vertex(name, payload)
98
+ end
99
+ vertex.payload ||= payload
100
+ parent_nodes.each do |parent_node|
101
+ add_edge(parent_node, vertex, requirement)
102
+ end
103
+ vertex
104
+ end
105
+
106
+ # @param [String] name
107
+ # @param [Object] payload
108
+ # @return [Vertex] the vertex that was added to `self`
109
+ def add_vertex(name, payload)
110
+ vertex = vertices[name] ||= Vertex.new(self, name, payload)
111
+ vertex.tap { |v| v.payload = payload }
112
+ end
113
+
114
+ # @param [String] name
115
+ # @param [Object] payload
116
+ # @return [Vertex] the vertex that was added to `self`
117
+ def add_root_vertex(name, payload)
118
+ add_vertex(name, payload).tap { |v| root_vertices[name] = v }
119
+ end
120
+
121
+ # Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
122
+ # removing any non-root vertices that were orphaned in the process
123
+ # @param [String] name
124
+ # @return [void]
125
+ def detach_vertex_named(name)
126
+ vertex = vertex_named(name)
127
+ return unless vertex
128
+ successors = vertex.successors
129
+ vertices.delete(name)
130
+ edges.reject! { |e| e.origin == vertex || e.destination == vertex }
131
+ successors.each { |v| detach_vertex_named(v.name) unless root_vertices[v.name] || v.predecessors.any? }
132
+ end
133
+
134
+ # @param [String] name
135
+ # @return [Vertex,nil] the vertex with the given name
136
+ def vertex_named(name)
137
+ vertices[name]
138
+ end
139
+
140
+ # @param [String] name
141
+ # @return [Vertex,nil] the root vertex with the given name
142
+ def root_vertex_named(name)
143
+ root_vertices[name]
144
+ end
145
+
146
+ # Adds a new {Edge} to the dependency graph
147
+ # @param [Vertex] origin
148
+ # @param [Vertex] destination
149
+ # @param [Object] requirement the requirement that this edge represents
150
+ # @return [Edge] the added edge
151
+ def add_edge(origin, destination, requirement)
152
+ if origin == destination || destination.path_to?(origin)
153
+ raise CircularDependencyError.new([origin, destination])
154
+ end
155
+ Edge.new(origin, destination, [requirement]).tap { |e| edges << e }
156
+ end
157
+
158
+ # A vertex in a {DependencyGraph} that encapsulates a {#name} and a
159
+ # {#payload}
160
+ class Vertex
161
+ # @return [DependencyGraph] the graph this vertex is a node of
162
+ attr_accessor :graph
163
+
164
+ # @return [String] the name of the vertex
165
+ attr_accessor :name
166
+
167
+ # @return [Object] the payload the vertex holds
168
+ attr_accessor :payload
169
+
170
+ # @return [Arrary<Object>] the explicit requirements that required
171
+ # this vertex
172
+ attr_reader :explicit_requirements
173
+
174
+ # @param [DependencyGraph] graph see {#graph}
175
+ # @param [String] name see {#name}
176
+ # @param [Object] payload see {#payload}
177
+ def initialize(graph, name, payload)
178
+ @graph = graph
179
+ @name = name
180
+ @payload = payload
181
+ @explicit_requirements = []
182
+ end
183
+
184
+ # @return [Array<Object>] all of the requirements that required
185
+ # this vertex
186
+ def requirements
187
+ incoming_edges.map(&:requirements).flatten + explicit_requirements
188
+ end
189
+
190
+ # @return [Array<Edge>] the edges of {#graph} that have `self` as their
191
+ # {Edge#origin}
192
+ def outgoing_edges
193
+ graph.edges.select { |e| e.origin.shallow_eql?(self) }
194
+ end
195
+
196
+ # @return [Array<Edge>] the edges of {#graph} that have `self` as their
197
+ # {Edge#destination}
198
+ def incoming_edges
199
+ graph.edges.select { |e| e.destination.shallow_eql?(self) }
200
+ end
201
+
202
+ # @return [Set<Vertex>] the vertices of {#graph} that have an edge with
203
+ # `self` as their {Edge#destination}
204
+ def predecessors
205
+ incoming_edges.map(&:origin).to_set
206
+ end
207
+
208
+ # @return [Set<Vertex>] the vertices of {#graph} that have an edge with
209
+ # `self` as their {Edge#origin}
210
+ def successors
211
+ outgoing_edges.map(&:destination).to_set
212
+ end
213
+
214
+ # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
215
+ # {#ancestor?}
216
+ def recursive_successors
217
+ successors + successors.map(&:recursive_successors).reduce(Set.new, &:+)
218
+ end
219
+
220
+ # @return [String] a string suitable for debugging
221
+ def inspect
222
+ "#{self.class}:#{name}(#{payload.inspect})"
223
+ end
224
+
225
+ # @return [Boolean] whether the two vertices are equal, determined
226
+ # by a recursive traversal of each {Vertex#successors}
227
+ def ==(other)
228
+ shallow_eql?(other) &&
229
+ successors == other.successors
230
+ end
231
+
232
+ # @return [Boolean] whether the two vertices are equal, determined
233
+ # solely by {#name} and {#payload} equality
234
+ def shallow_eql?(other)
235
+ other &&
236
+ name == other.name &&
237
+ payload == other.payload
238
+ end
239
+
240
+ alias_method :eql?, :==
241
+
242
+ # @return [Fixnum] a hash for the vertex based upon its {#name}
243
+ def hash
244
+ name.hash
245
+ end
246
+
247
+ # Is there a path from `self` to `other` following edges in the
248
+ # dependency graph?
249
+ # @return true iff there is a path following edges within this {#graph}
250
+ def path_to?(other)
251
+ successors.include?(other) || successors.any? { |v| v.path_to?(other) }
252
+ end
253
+
254
+ alias_method :descendent?, :path_to?
255
+
256
+ # Is there a path from `other` to `self` following edges in the
257
+ # dependency graph?
258
+ # @return true iff there is a path following edges within this {#graph}
259
+ def ancestor?(other)
260
+ predecessors.include?(other) || predecessors.any? { |v| v.ancestor?(other) }
261
+ end
262
+
263
+ alias_method :is_reachable_from?, :ancestor?
264
+ end
265
+ end
266
+ end