bundler 1.1.pre.5 → 1.1.pre.7

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 (66) hide show
  1. data/CHANGELOG.md +52 -1
  2. data/ISSUES.md +1 -0
  3. data/Rakefile +3 -3
  4. data/UPGRADING.md +2 -2
  5. data/lib/bundler/cli.rb +6 -5
  6. data/lib/bundler/definition.rb +13 -2
  7. data/lib/bundler/endpoint_specification.rb +19 -0
  8. data/lib/bundler/fetcher.rb +34 -2
  9. data/lib/bundler/gem_helper.rb +6 -4
  10. data/lib/bundler/index.rb +29 -4
  11. data/lib/bundler/installer.rb +2 -1
  12. data/lib/bundler/lazy_specification.rb +4 -2
  13. data/lib/bundler/resolver.rb +14 -16
  14. data/lib/bundler/rubygems_ext.rb +1 -0
  15. data/lib/bundler/rubygems_integration.rb +22 -2
  16. data/lib/bundler/runtime.rb +2 -0
  17. data/lib/bundler/source.rb +52 -44
  18. data/lib/bundler/spec_set.rb +10 -9
  19. data/lib/bundler/templates/newgem/Rakefile.tt +1 -1
  20. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  21. data/lib/bundler/vendor/thor.rb +43 -4
  22. data/lib/bundler/vendor/thor/actions.rb +28 -11
  23. data/lib/bundler/vendor/thor/actions/create_file.rb +2 -2
  24. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  25. data/lib/bundler/vendor/thor/actions/directory.rb +2 -2
  26. data/lib/bundler/vendor/thor/actions/empty_directory.rb +0 -0
  27. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +56 -15
  28. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +13 -8
  29. data/lib/bundler/vendor/thor/base.rb +24 -4
  30. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +0 -0
  31. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +0 -0
  32. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +0 -0
  33. data/lib/bundler/vendor/thor/error.rb +0 -0
  34. data/lib/bundler/vendor/thor/group.rb +273 -0
  35. data/lib/bundler/vendor/thor/invocation.rb +0 -0
  36. data/lib/bundler/vendor/thor/parser.rb +0 -0
  37. data/lib/bundler/vendor/thor/parser/argument.rb +0 -0
  38. data/lib/bundler/vendor/thor/parser/arguments.rb +2 -2
  39. data/lib/bundler/vendor/thor/parser/option.rb +0 -0
  40. data/lib/bundler/vendor/thor/parser/options.rb +17 -16
  41. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  42. data/lib/bundler/vendor/thor/runner.rb +309 -0
  43. data/lib/bundler/vendor/thor/shell.rb +0 -0
  44. data/lib/bundler/vendor/thor/shell/basic.rb +40 -13
  45. data/lib/bundler/vendor/thor/shell/color.rb +0 -0
  46. data/lib/bundler/vendor/thor/task.rb +3 -4
  47. data/lib/bundler/vendor/thor/util.rb +2 -2
  48. data/lib/bundler/vendor/thor/version.rb +1 -1
  49. data/lib/bundler/version.rb +1 -1
  50. data/man/gemfile.5.ronn +3 -0
  51. data/spec/cache/git_spec.rb +5 -2
  52. data/spec/install/gems/dependency_api_spec.rb +69 -0
  53. data/spec/install/gems/simple_case_spec.rb +7 -0
  54. data/spec/install/gems/standalone_spec.rb +62 -0
  55. data/spec/install/git_spec.rb +63 -1
  56. data/spec/other/clean_spec.rb +22 -26
  57. data/spec/other/exec_spec.rb +2 -2
  58. data/spec/other/gem_helper_spec.rb +1 -1
  59. data/spec/runtime/setup_spec.rb +1 -1
  60. data/spec/support/artifice/endpoint.rb +2 -2
  61. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  62. data/spec/support/artifice/endpoint_extra.rb +27 -0
  63. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  64. data/spec/support/helpers.rb +7 -6
  65. metadata +73 -40
  66. data/spec/pack/gems_spec.rb +0 -22
File without changes
@@ -11,6 +11,21 @@ class Thor
11
11
  @base, @padding = nil, 0
12
12
  end
13
13
 
14
+ # Mute everything that's inside given block
15
+ #
16
+ def mute
17
+ @mute = true
18
+ yield
19
+ ensure
20
+ @mute = false
21
+ end
22
+
23
+ # Check if base is muted
24
+ #
25
+ def mute?
26
+ @mute
27
+ end
28
+
14
29
  # Sets the output padding, not allowing less than zero values.
15
30
  #
16
31
  def padding=(value)
@@ -24,7 +39,7 @@ class Thor
24
39
  #
25
40
  def ask(statement, color=nil)
26
41
  say("#{statement} ", color)
27
- $stdin.gets.strip
42
+ stdin.gets.strip
28
43
  end
29
44
 
30
45
  # Say (print) something to the user. If the sentence ends with a whitespace
@@ -41,11 +56,11 @@ class Thor
41
56
  spaces = " " * padding
42
57
 
43
58
  if force_new_line
44
- $stdout.puts(spaces + message)
59
+ stdout.puts(spaces + message)
45
60
  else
46
- $stdout.print(spaces + message)
61
+ stdout.print(spaces + message)
47
62
  end
48
- $stdout.flush
63
+ stdout.flush
49
64
  end
50
65
 
51
66
  # Say a status with the given color and appends the message. Since this
@@ -61,15 +76,15 @@ class Thor
61
76
  status = status.to_s.rjust(12)
62
77
  status = set_color status, color, true if color
63
78
 
64
- $stdout.puts "#{status}#{spaces}#{message}"
65
- $stdout.flush
79
+ stdout.puts "#{status}#{spaces}#{message}"
80
+ stdout.flush
66
81
  end
67
82
 
68
83
  # Make a question the to user and returns true if the user replies "y" or
69
84
  # "yes".
70
85
  #
71
86
  def yes?(statement, color=nil)
72
- ask(statement, color) =~ is?(:yes)
87
+ !!(ask(statement, color) =~ is?(:yes))
73
88
  end
74
89
 
75
90
  # Make a question the to user and returns true if the user replies "n" or
@@ -113,7 +128,7 @@ class Thor
113
128
  end
114
129
 
115
130
  sentence = truncate(sentence, options[:truncate]) if options[:truncate]
116
- $stdout.puts sentence
131
+ stdout.puts sentence
117
132
  end
118
133
  end
119
134
 
@@ -139,9 +154,9 @@ class Thor
139
154
 
140
155
  paras.each do |para|
141
156
  para.split("\n").each do |line|
142
- $stdout.puts line.insert(0, " " * ident)
157
+ stdout.puts line.insert(0, " " * ident)
143
158
  end
144
- $stdout.puts unless para == paras.last
159
+ stdout.puts unless para == paras.last
145
160
  end
146
161
  end
147
162
 
@@ -180,12 +195,12 @@ class Thor
180
195
  end
181
196
 
182
197
  # Called if something goes wrong during the execution. This is used by Thor
183
- # internally and should not be used inside your scripts. If someone went
198
+ # internally and should not be used inside your scripts. If something went
184
199
  # wrong, you can always raise an exception. If you raise a Thor::Error, it
185
200
  # will be rescued and wrapped in the method below.
186
201
  #
187
202
  def error(statement)
188
- $stderr.puts statement
203
+ stderr.puts statement
189
204
  end
190
205
 
191
206
  # Apply color to the given string with optional bold. Disabled in the
@@ -197,6 +212,18 @@ class Thor
197
212
 
198
213
  protected
199
214
 
215
+ def stdout
216
+ $stdout
217
+ end
218
+
219
+ def stdin
220
+ $stdin
221
+ end
222
+
223
+ def stderr
224
+ $stderr
225
+ end
226
+
200
227
  def is?(value) #:nodoc:
201
228
  value = value.to_s
202
229
 
@@ -229,7 +256,7 @@ HELP
229
256
  end
230
257
 
231
258
  def quiet? #:nodoc:
232
- base && base.options[:quiet]
259
+ mute? || (base && base.options[:quiet])
233
260
  end
234
261
 
235
262
  # This code was copied from Rake, available under MIT-LICENSE
File without changes
@@ -65,10 +65,9 @@ class Thor
65
65
  @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
66
66
  end
67
67
 
68
- # Given a target, checks if this class name is not a private/protected method.
68
+ # Given a target, checks if this class name is a public method.
69
69
  def public_method?(instance) #:nodoc:
70
- collection = instance.private_methods + instance.protected_methods
71
- (collection & [name.to_s, name.to_sym]).empty?
70
+ !(instance.public_methods & [name.to_s, name.to_sym]).empty?
72
71
  end
73
72
 
74
73
  def sans_backtrace(backtrace, caller) #:nodoc:
@@ -111,4 +110,4 @@ class Thor
111
110
  end
112
111
  end
113
112
  end
114
- end
113
+ end
@@ -8,11 +8,11 @@ class Thor
8
8
  #
9
9
  # 1) Methods to convert thor namespaces to constants and vice-versa.
10
10
  #
11
- # Thor::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
11
+ # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
12
12
  #
13
13
  # 2) Loading thor files and sandboxing:
14
14
  #
15
- # Thor::Utils.load_thorfile("~/.thor/foo")
15
+ # Thor::Util.load_thorfile("~/.thor/foo")
16
16
  #
17
17
  module Util
18
18
 
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.14.0".freeze
2
+ VERSION = "0.14.6".freeze
3
3
  end
@@ -2,5 +2,5 @@ module Bundler
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of bundler and we are unsure how to
4
4
  # handle this better.
5
- VERSION = "1.1.pre.5" unless defined?(::Bundler::VERSION)
5
+ VERSION = "1.1.pre.7" unless defined?(::Bundler::VERSION)
6
6
  end
@@ -55,6 +55,9 @@ This defaults to the name of the gem itself. For instance, these are identical:
55
55
  gem "nokogiri"
56
56
  gem "nokogiri", :require => "nokogiri"
57
57
 
58
+ Specify `:require => false` to prevent bundler from requiring the gem, but still
59
+ install it and maintain dependencies.
60
+
58
61
  ### GROUPS (:group or :groups)
59
62
 
60
63
  Each _gem_ `MAY` specify membership in one or more groups. Any _gem_ that does
@@ -4,6 +4,9 @@ describe "bundle cache with git" do
4
4
  source = Bundler::Source::Git.new("uri" => "git@github.com:bundler.git")
5
5
  source.send(:base_name).should == "bundler"
6
6
  end
7
- end
8
-
9
7
 
8
+ it "base_name should strip network share paths" do
9
+ source = Bundler::Source::Git.new("uri" => "//MachineName/ShareFolder")
10
+ source.send(:base_name).should == "ShareFolder"
11
+ end
12
+ end
@@ -68,6 +68,22 @@ describe "gemcutter's dependency API" do
68
68
  should_be_installed "rack 1.0.0"
69
69
  end
70
70
 
71
+ it "handles git dependencies that are in rubygems" do
72
+ build_git "foo" do |s|
73
+ s.executables = "foobar"
74
+ s.add_dependency "rails", "2.3.2"
75
+ end
76
+
77
+ install_gemfile <<-G
78
+ source "file://#{gem_repo1}"
79
+ git "#{lib_path('foo-1.0')}" do
80
+ gem 'foo'
81
+ end
82
+ G
83
+
84
+ should_be_installed("rails 2.3.2")
85
+ end
86
+
71
87
  it "falls back when the API errors out" do
72
88
  simulate_platform mswin
73
89
 
@@ -137,4 +153,57 @@ describe "gemcutter's dependency API" do
137
153
  out.should include("Fetching source index for #{source_uri}")
138
154
  should_be_installed "rack 1.0.0"
139
155
  end
156
+
157
+ it "fetches again when more dependencies are found in subsequent sources" do
158
+ build_repo2 do
159
+ build_gem "back_deps" do |s|
160
+ s.add_dependency "foo"
161
+ end
162
+ FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
163
+ end
164
+
165
+ gemfile <<-G
166
+ source "#{source_uri}"
167
+ source "#{source_uri}/extra"
168
+ gem "back_deps"
169
+ G
170
+
171
+ bundle :install, :artifice => "endpoint_extra"
172
+ should_be_installed "back_deps 1.0"
173
+ end
174
+
175
+ it "does not fetch every specs if the index of gems is large when doing back deps" do
176
+ build_repo2 do
177
+ build_gem "back_deps" do |s|
178
+ s.add_dependency "foo"
179
+ end
180
+ build_gem "missing"
181
+ # need to hit the limit
182
+ 1.upto(Bundler::Source::Rubygems::FORCE_MODERN_INDEX_LIMIT) do |i|
183
+ build_gem "gem#{i}"
184
+ end
185
+
186
+ FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
187
+ end
188
+
189
+ gemfile <<-G
190
+ source "#{source_uri}"
191
+ source "#{source_uri}/extra"
192
+ gem "back_deps"
193
+ G
194
+
195
+ bundle :install, :artifice => "endpoint_extra_missing"
196
+ should_be_installed "back_deps 1.0"
197
+ end
198
+
199
+ it "uses the endpoint if all sources support it" do
200
+ gemfile <<-G
201
+ source "#{source_uri}"
202
+
203
+ gem 'foo'
204
+ G
205
+
206
+ bundle :install, :artifice => "endpoint_api_missing"
207
+ should_be_installed "foo 1.0"
208
+ end
140
209
  end
@@ -293,6 +293,13 @@ describe "bundle install with gem sources" do
293
293
  bundle :install, :expect_err => true
294
294
  out.should =~ /Your Gemfile doesn't have any sources/i
295
295
  end
296
+
297
+ it "creates a Gemfile.lock on a blank Gemfile" do
298
+ install_gemfile <<-G
299
+ G
300
+
301
+ File.exists?(bundled_app("Gemfile.lock")).should be_true
302
+ end
296
303
  end
297
304
 
298
305
  describe "when prerelease gems are available" do
@@ -159,4 +159,66 @@ describe "bundle install --standalone" do
159
159
  err.should =~ /no such file to load.*spec/
160
160
  end
161
161
  end
162
+
163
+ describe "with gemcutter's dependency API" do
164
+ let(:source_uri) { "http://localgemserver.test" }
165
+
166
+ describe "simple gems" do
167
+ before do
168
+ gemfile <<-G
169
+ source "#{source_uri}"
170
+ gem "rails"
171
+ G
172
+ end
173
+
174
+ it "should run without errors" do
175
+ bundle "install --standalone", :artifice => "endpoint", :exitstatus => true
176
+
177
+ @exitstatus.should == 0
178
+ end
179
+
180
+ it "still makes the gems available to normal bundler" do
181
+ bundle "install --standalone", :artifice => "endpoint"
182
+
183
+ should_be_installed "actionpack 2.3.2", "rails 2.3.2"
184
+ end
185
+
186
+ it "generates a bundle/bundler/setup.rb" do
187
+ bundle "install --standalone", :artifice => "endpoint"
188
+
189
+ bundled_app("bundle/bundler/setup.rb").should exist
190
+ end
191
+
192
+ it "makes the gems available without bundler" do
193
+ bundle "install --standalone", :artifice => "endpoint"
194
+
195
+ ruby <<-RUBY, :no_lib => true
196
+ $:.unshift File.expand_path("bundle")
197
+ require "bundler/setup"
198
+
199
+ require "actionpack"
200
+ puts ACTIONPACK
201
+ RUBY
202
+
203
+ out.should == "2.3.2"
204
+ end
205
+
206
+ it "works on a different system" do
207
+ bundle "install --standalone", :artifice => "endpoint"
208
+
209
+ FileUtils.mv(bundled_app, "#{bundled_app}2")
210
+ Dir.chdir("#{bundled_app}2")
211
+
212
+ ruby <<-RUBY, :no_lib => true
213
+ $:.unshift File.expand_path("bundle")
214
+ require "bundler/setup"
215
+
216
+ require "actionpack"
217
+ puts ACTIONPACK
218
+ RUBY
219
+
220
+ out.should == "2.3.2"
221
+ end
222
+ end
223
+ end
162
224
  end
@@ -403,7 +403,7 @@ describe "bundle install with git sources" do
403
403
  gem "has_submodule"
404
404
  end
405
405
  G
406
- out.should =~ /Could not find gem 'submodule'/
406
+ out.should =~ /could not find gem 'submodule'/i
407
407
 
408
408
  should_not_be_installed "has_submodule 1.0", :expect_err => true
409
409
  end
@@ -567,4 +567,66 @@ describe "bundle install with git sources" do
567
567
  exitstatus.should == 0
568
568
  end
569
569
  end
570
+
571
+ describe "gem install hooks" do
572
+ it "runs pre-install hooks" do
573
+ build_git "foo"
574
+ gemfile <<-G
575
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
576
+ G
577
+
578
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
579
+ h.write <<-H
580
+ require 'rubygems'
581
+ Gem.pre_install_hooks << lambda do |inst|
582
+ STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
583
+ end
584
+ H
585
+ end
586
+
587
+ bundle :install, :expect_err => true,
588
+ :requires => [lib_path('install_hooks.rb')]
589
+ err.should == "Ran pre-install hook: foo-1.0"
590
+ end
591
+
592
+ it "runs post-install hooks" do
593
+ build_git "foo"
594
+ gemfile <<-G
595
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
596
+ G
597
+
598
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
599
+ h.write <<-H
600
+ require 'rubygems'
601
+ Gem.post_install_hooks << lambda do |inst|
602
+ STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
603
+ end
604
+ H
605
+ end
606
+
607
+ bundle :install, :expect_err => true,
608
+ :requires => [lib_path('install_hooks.rb')]
609
+ err.should == "Ran post-install hook: foo-1.0"
610
+ end
611
+
612
+ it "complains if the install hook fails" do
613
+ build_git "foo"
614
+ gemfile <<-G
615
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
616
+ G
617
+
618
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
619
+ h.write <<-H
620
+ require 'rubygems'
621
+ Gem.pre_install_hooks << lambda do |inst|
622
+ false
623
+ end
624
+ H
625
+ end
626
+
627
+ bundle :install, :expect_err => true,
628
+ :requires => [lib_path('install_hooks.rb')]
629
+ err.should include("failed for foo-1.0")
630
+ end
631
+ end
570
632
  end
@@ -1,6 +1,20 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "bundle clean" do
4
+ def should_have_gems(*gems)
5
+ gems.each do |g|
6
+ vendored_gems("gems/#{g}").should exist
7
+ vendored_gems("specifications/#{g}.gemspec").should exist
8
+ vendored_gems("cache/#{g}.gem").should exist
9
+ end
10
+ end
11
+
12
+ def should_not_have_gem(rubygem)
13
+ vendored_gems("gems/#{rubygem}").should_not exist
14
+ vendored_gems("specifications/#{rubygem}.gemspec").should_not exist
15
+ vendored_gems("cache/#{rubygem}.gem").should_not exist
16
+ end
17
+
4
18
  it "removes unused gems that are different" do
5
19
  gemfile = <<-G
6
20
  source "file://#{gem_repo1}"
@@ -21,13 +35,8 @@ describe "bundle clean" do
21
35
 
22
36
  out.should == "Removing foo (1.0)"
23
37
 
24
- vendored_gems("gems/thin-1.0").should exist
25
- vendored_gems("gems/rack-1.0.0").should exist
26
- vendored_gems("gems/foo-1.0").should_not exist
27
-
28
- vendored_gems("specifications/thin-1.0.gemspec").should exist
29
- vendored_gems("specifications/rack-1.0.0.gemspec").should exist
30
- vendored_gems("specifications/foo-1.0.gemspec").should_not exist
38
+ should_have_gems 'thin-1.0', 'rack-1.0.0'
39
+ should_not_have_gem 'foo-1.0'
31
40
 
32
41
  vendored_gems("bin/rackup").should exist
33
42
  end
@@ -53,13 +62,8 @@ describe "bundle clean" do
53
62
 
54
63
  out.should == "Removing rack (0.9.1)"
55
64
 
56
- vendored_gems("gems/foo-1.0").should exist
57
- vendored_gems("gems/rack-1.0.0").should exist
58
- vendored_gems("gems/rack-0.9.1").should_not exist
59
-
60
- vendored_gems("specifications/foo-1.0.gemspec").should exist
61
- vendored_gems("specifications/rack-1.0.0.gemspec").should exist
62
- vendored_gems("specifications/rack-0.9.1.gemspec").should_not exist
65
+ should_have_gems 'foo-1.0', 'rack-1.0.0'
66
+ should_not_have_gem 'rack-0.9.1'
63
67
 
64
68
  vendored_gems("bin/rackup").should exist
65
69
  end
@@ -85,13 +89,8 @@ describe "bundle clean" do
85
89
 
86
90
  out.should == "Removing rack (1.0.0)"
87
91
 
88
- vendored_gems("gems/foo-1.0").should exist
89
- vendored_gems("gems/rack-0.9.1").should exist
90
- vendored_gems("gems/rack-1.0.0").should_not exist
91
-
92
- vendored_gems("specifications/foo-1.0.gemspec").should exist
93
- vendored_gems("specifications/rack-0.9.1.gemspec").should exist
94
- vendored_gems("specifications/rack-1.0.0.gemspec").should_not exist
92
+ should_have_gems 'foo-1.0', 'rack-0.9.1'
93
+ should_not_have_gem 'rack-1.0.0'
95
94
 
96
95
  vendored_gems("bin/rackup").should exist
97
96
  end
@@ -113,11 +112,8 @@ describe "bundle clean" do
113
112
 
114
113
  out.should == "Removing rack (1.0.0)"
115
114
 
116
- vendored_gems("gems/foo-1.0").should exist
117
- vendored_gems("gems/rack-1.0.0").should_not exist
118
-
119
- vendored_gems("specifications/foo-1.0.gemspec").should exist
120
- vendored_gems("specifications/rack-1.0.0.gemspec").should_not exist
115
+ should_have_gems 'foo-1.0'
116
+ should_not_have_gem 'rack-1.0.0'
121
117
 
122
118
  vendored_gems("bin/rackup").should_not exist
123
119
  end