bundler 1.1.5 → 1.2.0.pre

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 (46) hide show
  1. data/.travis.yml +10 -7
  2. data/CHANGELOG.md +27 -8
  3. data/ISSUES.md +20 -16
  4. data/README.md +2 -0
  5. data/Rakefile +6 -5
  6. data/bin/bundle +5 -3
  7. data/lib/bundler.rb +33 -13
  8. data/lib/bundler/capistrano.rb +1 -1
  9. data/lib/bundler/cli.rb +108 -20
  10. data/lib/bundler/definition.rb +76 -20
  11. data/lib/bundler/deployment.rb +4 -4
  12. data/lib/bundler/dsl.rb +26 -25
  13. data/lib/bundler/fetcher.rb +4 -13
  14. data/lib/bundler/gem_helper.rb +17 -5
  15. data/lib/bundler/graph.rb +10 -10
  16. data/lib/bundler/installer.rb +34 -2
  17. data/lib/bundler/ruby_version.rb +94 -0
  18. data/lib/bundler/runtime.rb +1 -1
  19. data/lib/bundler/settings.rb +18 -13
  20. data/lib/bundler/source.rb +316 -150
  21. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  22. data/lib/bundler/vendor/thor/parser/options.rb +0 -3
  23. data/lib/bundler/vendored_thor.rb +1 -2
  24. data/lib/bundler/version.rb +1 -1
  25. data/man/bundle-config.ronn +8 -0
  26. data/man/bundle-install.ronn +6 -0
  27. data/man/bundle-package.ronn +3 -3
  28. data/man/gemfile.5.ronn +16 -3
  29. data/spec/bundler/dsl_spec.rb +23 -26
  30. data/spec/bundler/gem_helper_spec.rb +31 -0
  31. data/spec/cache/gems_spec.rb +10 -1
  32. data/spec/cache/git_spec.rb +114 -2
  33. data/spec/cache/path_spec.rb +85 -9
  34. data/spec/install/gems/dependency_api_spec.rb +21 -42
  35. data/spec/install/git_spec.rb +149 -1
  36. data/spec/lock/lockfile_spec.rb +1 -1
  37. data/spec/other/config_spec.rb +120 -22
  38. data/spec/other/newgem_spec.rb +2 -0
  39. data/spec/other/platform_spec.rb +881 -0
  40. data/spec/support/helpers.rb +12 -1
  41. data/spec/support/platforms.rb +33 -0
  42. data/spec/support/rubygems_hax/platform.rb +12 -1
  43. data/spec/update/gems_spec.rb +12 -0
  44. metadata +9 -8
  45. data/lib/bundler/vendored_persistent.rb +0 -3
  46. data/spec/install/deprecated_spec.rb +0 -36
@@ -24,6 +24,6 @@ TODO: Write usage instructions here
24
24
 
25
25
  1. Fork it
26
26
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Added some feature'`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create new Pull Request
@@ -1,7 +1,4 @@
1
1
  class Thor
2
- # This is a modified version of Daniel Berger's Getopt::Long class, licensed
3
- # under Ruby's license.
4
- #
5
2
  class Options < Arguments #:nodoc:
6
3
  LONG_RE = /^(--\w+(?:-\w+)*)$/
7
4
  SHORT_RE = /^(-[a-z])$/i
@@ -2,7 +2,6 @@ if defined?(Thor)
2
2
  Bundler.ui.warn "Thor has already been required. " +
3
3
  "This may cause Bundler to malfunction in unexpected ways."
4
4
  end
5
- vendor = File.expand_path('../vendor', __FILE__)
6
- $:.unshift(vendor) unless $:.include?(vendor)
5
+ $:.unshift File.expand_path('../vendor', __FILE__)
7
6
  require 'thor'
8
7
  require 'thor/actions'
@@ -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.5" unless defined?(::Bundler::VERSION)
5
+ VERSION = "1.2.0.pre" unless defined?(::Bundler::VERSION)
6
6
  end
@@ -23,6 +23,14 @@ Executing `bundle config <name> <value>` will set that configuration to the
23
23
  value specified for all bundles executed as the current user. The configuration
24
24
  will be stored in `~/.bundle/config`.
25
25
 
26
+ Executing `bundle config --global <name> <value>` works the same as above.
27
+
28
+ Executing `bundle config --local <name> <value>` will set that configuration to
29
+ the local application. The configuration will be stored in `app/.bundle/config`.
30
+
31
+ Executing `bundle config --delete <name>` will delete the configuration in both
32
+ local and global sources.
33
+
26
34
  ## BUILD OPTIONS
27
35
 
28
36
  You can use `bundle config` to give bundler the flags to pass to the gem
@@ -10,6 +10,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
10
10
  [--binstubs[=DIRECTORY]]
11
11
  [--standalone[=GROUP1[ GROUP2...]]]
12
12
  [--quiet]
13
+ [--no-cache]
13
14
 
14
15
  ## DESCRIPTION
15
16
 
@@ -81,6 +82,11 @@ update process below under [CONSERVATIVE UPDATING][].
81
82
  `bundle` directory and installs the bundle there. It also generates
82
83
  a `bundle/bundler/setup.rb` file to replace Bundler's own setup.
83
84
 
85
+ * `--no-cache`:
86
+ Do not update the cache in `vendor/cache` with the newly bundled gems. This
87
+ does not remove any existing cached gems, only stops the newly bundled gems
88
+ from being cached during the install.
89
+
84
90
  ## DEPLOYMENT MODE
85
91
 
86
92
  Bundler's defaults are optimized for development. To switch to
@@ -13,9 +13,9 @@ use the gems in the cache in preference to the ones on `rubygems.org`.
13
13
 
14
14
  ## GIT AND PATH GEMS
15
15
 
16
- In Bundler 1.0, the `bundle package` command only packages `.gem` files,
17
- not gems specified using the `:git` or `:path` options. This will likely
18
- change in the future.
16
+ Since Bundler 1.2, the `bundle package` command can also package `:git` and
17
+ `:path` dependencies besides .gem files. This needs to be explicitly enabled
18
+ via the `--all` option. Once used, the `--all` option will be remembered.
19
19
 
20
20
  ## REMOTE FETCHING
21
21
 
@@ -49,7 +49,6 @@ Each _gem_ `MAY` specify files that should be used when autorequiring via
49
49
  `Bundler.require`. You may pass an array with multiple files, or `false` to
50
50
  prevent any file from being autorequired.
51
51
 
52
- gem "sqlite3-ruby", :require => "sqlite3"
53
52
  gem "redis", :require => ["redis/connection/hiredis", "redis"]
54
53
  gem "webmock", :require => false
55
54
 
@@ -203,7 +202,7 @@ the `.gemspec`.
203
202
  | |-actionpack.gemspec [actionpack gem located here]
204
203
  |~activesupport
205
204
  | |-activesupport.gemspec [activesupport gem located here]
206
- ...
205
+ |...
207
206
 
208
207
  To install a gem located in a git repository, bundler changes to
209
208
  the directory containing the gemspec, runs `gem build name.gemspec`
@@ -211,6 +210,20 @@ and then installs the resulting gem. The `gem build` command,
211
210
  which comes standard with Rubygems, evaluates the `.gemspec` in
212
211
  the context of the directory in which it is located.
213
212
 
213
+ ### GITHUB (:github)
214
+
215
+ If the git repository you want to use is hosted on GitHub and is public, you can use the
216
+ :github shorthand to specify just the github username and repository name (without the
217
+ trailing ".git"), separated by a slash. If both the username and repository name are the
218
+ same, you can omit one.
219
+
220
+ gem "rails", :github => "rails/rails"
221
+ gem "rails", :github => "rails"
222
+
223
+ Are both equivalent to
224
+
225
+ gem "rails", :git => "git://github.com/rails/rails.git"
226
+
214
227
  ### PATH (:path)
215
228
 
216
229
  You can specify that a gem is located in a particular location
@@ -239,7 +252,7 @@ applied to a group of gems by using block form.
239
252
 
240
253
  platforms :ruby do
241
254
  gem "ruby-debug"
242
- gem "sqlite3-ruby"
255
+ gem "sqlite3"
243
256
  end
244
257
 
245
258
  group :development do
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bundler::Dsl do
4
- describe '#_normalize_options' do
5
- before do
6
- @rubygems = mock("rubygems")
7
- Bundler::Source::Rubygems.stub(:new){ @rubygems }
8
- end
4
+ before do
5
+ @rubygems = mock("rubygems")
6
+ Bundler::Source::Rubygems.stub(:new){ @rubygems }
7
+ end
9
8
 
9
+ describe '#_normalize_options' do
10
10
  it "should convert :github to :git" do
11
11
  subject.gem("sparks", :github => "indirect/sparks")
12
12
  github_uri = "git://github.com/indirect/sparks.git"
@@ -20,32 +20,29 @@ describe Bundler::Dsl do
20
20
  end
21
21
  end
22
22
 
23
+ describe '#method_missing' do
24
+ it 'should raise an error for unknown DSL methods' do
25
+ Bundler.should_receive(:read_file).with("Gemfile").and_return("unknown")
26
+ error_msg = "Undefined local variable or method `unknown'" \
27
+ " for Gemfile\\s+from Gemfile:1"
28
+ lambda{ subject.eval_gemfile("Gemfile") }.
29
+ should raise_error(Bundler::GemfileError, Regexp.new(error_msg))
30
+ end
31
+ end
32
+
33
+ describe "#eval_gemfile" do
34
+ it "handles syntax errors with a useful message" do
35
+ Bundler.should_receive(:read_file).with("Gemfile").and_return("}")
36
+ lambda{ subject.eval_gemfile("Gemfile") }.
37
+ should raise_error(Bundler::GemfileError, /Gemfile syntax error/)
38
+ end
39
+ end
40
+
23
41
  describe "syntax errors" do
24
42
  it "should raise a Bundler::GemfileError" do
25
43
  gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
26
44
  lambda { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
27
45
  should raise_error(Bundler::GemfileError)
28
46
  end
29
-
30
- it "should special case the ruby directive" do
31
- gemfile <<-G
32
- ruby "1.9.3"
33
- G
34
- lambda { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
35
- should_not raise_error(Bundler::GemfileError)
36
- end
37
-
38
- it "should special case the ruby directive and throws a warning" do
39
- install_gemfile <<-G
40
- source "file://#{gem_repo1}"
41
-
42
- ruby "1.9.3"
43
-
44
- gem "foo"
45
- G
46
-
47
- out.should include("Ignoring `ruby` directive")
48
- bundled_app("Gemfile.lock").should exist
49
- end
50
47
  end
51
48
  end
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require 'rake'
2
3
  require 'bundler/gem_helper'
3
4
 
4
5
  describe "Bundler::GemHelper tasks" do
@@ -61,6 +62,36 @@ describe "Bundler::GemHelper tasks" do
61
62
  Bundler.ui.should be_a(Bundler::UI::Shell)
62
63
  end
63
64
 
65
+ describe 'install_tasks' do
66
+ before(:each) do
67
+ @saved, Rake.application = Rake.application, Rake::Application.new
68
+ end
69
+
70
+ after(:each) do
71
+ Rake.application = @saved
72
+ end
73
+
74
+ it "defines Rake tasks" do
75
+ names = %w[build install release]
76
+
77
+ names.each { |name|
78
+ proc { Rake.application[name] }.should raise_error(/Don't know how to build task/)
79
+ }
80
+
81
+ @helper.install
82
+
83
+ names.each { |name|
84
+ proc { Rake.application[name] }.should_not raise_error
85
+ Rake.application[name].should be_instance_of Rake::Task
86
+ }
87
+ end
88
+
89
+ it "provides a way to access the gemspec object" do
90
+ @helper.install
91
+ Bundler::GemHelper.gemspec.name.should == 'test'
92
+ end
93
+ end
94
+
64
95
  describe 'build' do
65
96
  it "builds" do
66
97
  mock_build_message
@@ -123,7 +123,7 @@ describe "bundle cache" do
123
123
  it "re-caches during install" do
124
124
  cached_gem("rack-1.0.0").rmtree
125
125
  bundle :install
126
- out.should include("Updating .gem files in vendor/cache")
126
+ out.should include("Updating files in vendor/cache")
127
127
  cached_gem("rack-1.0.0").should exist
128
128
  end
129
129
 
@@ -215,6 +215,15 @@ describe "bundle cache" do
215
215
  out.should_not =~ /removing/i
216
216
  end
217
217
 
218
+ it "does not warn about all if it doesn't have any git/path dependency" do
219
+ install_gemfile <<-G
220
+ source "file://#{gem_repo1}"
221
+ gem "rack"
222
+ G
223
+ bundle "cache"
224
+ out.should_not =~ /\-\-all/
225
+ end
226
+
218
227
  it "should install gems with the name bundler in them (that aren't bundler)" do
219
228
  build_gem "foo-bundler", "1.0",
220
229
  :path => bundled_app('vendor/cache')
@@ -1,5 +1,6 @@
1
1
  require "spec_helper"
2
- describe "bundle cache with git" do
2
+
3
+ describe "git base name" do
3
4
  it "base_name should strip private repo uris" do
4
5
  source = Bundler::Source::Git.new("uri" => "git@github.com:bundler.git")
5
6
  source.send(:base_name).should == "bundler"
@@ -9,4 +10,115 @@ describe "bundle cache with git" do
9
10
  source = Bundler::Source::Git.new("uri" => "//MachineName/ShareFolder")
10
11
  source.send(:base_name).should == "ShareFolder"
11
12
  end
12
- end
13
+ end
14
+
15
+ %w(cache package).each do |cmd|
16
+ describe "bundle #{cmd} with git" do
17
+ it "copies repository to vendor cache and uses it" do
18
+ git = build_git "foo"
19
+ ref = git.ref_for("master", 11)
20
+
21
+ install_gemfile <<-G
22
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
23
+ G
24
+
25
+ bundle "#{cmd} --all"
26
+ bundled_app("vendor/cache/foo-1.0-#{ref}").should exist
27
+ bundled_app("vendor/cache/foo-1.0-#{ref}/.git").should_not exist
28
+
29
+ FileUtils.rm_rf lib_path("foo-1.0")
30
+ should_be_installed "foo 1.0"
31
+ end
32
+
33
+ it "runs twice without exploding" do
34
+ build_git "foo"
35
+
36
+ install_gemfile <<-G
37
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
38
+ G
39
+
40
+ bundle "#{cmd} --all"
41
+ bundle "#{cmd} --all"
42
+
43
+ err.should == ""
44
+ FileUtils.rm_rf lib_path("foo-1.0")
45
+ should_be_installed "foo 1.0"
46
+ end
47
+
48
+ it "tracks updates" do
49
+ git = build_git "foo"
50
+ old_ref = git.ref_for("master", 11)
51
+
52
+ install_gemfile <<-G
53
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
54
+ G
55
+
56
+ bundle "#{cmd} --all"
57
+
58
+ update_git "foo" do |s|
59
+ s.write "lib/foo.rb", "puts :CACHE"
60
+ end
61
+
62
+ ref = git.ref_for("master", 11)
63
+ ref.should_not == old_ref
64
+
65
+ bundle "update"
66
+ bundle "#{cmd} --all"
67
+
68
+ bundled_app("vendor/cache/foo-1.0-#{ref}").should exist
69
+
70
+ FileUtils.rm_rf lib_path("foo-1.0")
71
+ run "require 'foo'"
72
+ out.should == "CACHE"
73
+ end
74
+
75
+ it "uses the local repository to generate the cache" do
76
+ git = build_git "foo"
77
+ ref = git.ref_for("master", 11)
78
+
79
+ gemfile <<-G
80
+ gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
81
+ G
82
+
83
+ bundle %|config local.foo #{lib_path('foo-1.0')}|
84
+ bundle "install"
85
+ bundle "#{cmd} --all"
86
+
87
+ bundled_app("vendor/cache/foo-invalid-#{ref}").should exist
88
+
89
+ # Updating the local still uses the local.
90
+ update_git "foo" do |s|
91
+ s.write "lib/foo.rb", "puts :LOCAL"
92
+ end
93
+
94
+ run "require 'foo'"
95
+ out.should == "LOCAL"
96
+ end
97
+
98
+ it "copies repository to vendor cache, including submodules" do
99
+ build_git "submodule", "1.0"
100
+
101
+ git = build_git "has_submodule", "1.0" do |s|
102
+ s.add_dependency "submodule"
103
+ end
104
+
105
+ Dir.chdir(lib_path('has_submodule-1.0')) do
106
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
107
+ `git commit -m "submodulator"`
108
+ end
109
+
110
+ install_gemfile <<-G
111
+ git "#{lib_path('has_submodule-1.0')}", :submodules => true do
112
+ gem "has_submodule"
113
+ end
114
+ G
115
+
116
+ ref = git.ref_for("master", 11)
117
+ bundle "#{cmd} --all"
118
+
119
+ bundled_app("vendor/cache/has_submodule-1.0-#{ref}").should exist
120
+ bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0").should exist
121
+ should_be_installed "has_submodule 1.0"
122
+ end
123
+ end
124
+ end
@@ -1,27 +1,103 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "bundle cache" do
4
- describe "with path sources" do
5
- it "is silent when the path is within the bundle" do
3
+ %w(cache package).each do |cmd|
4
+ describe "bundle #{cmd} with path" do
5
+ it "is no-op when the path is within the bundle" do
6
6
  build_lib "foo", :path => bundled_app("lib/foo")
7
7
 
8
8
  install_gemfile <<-G
9
9
  gem "foo", :path => '#{bundled_app("lib/foo")}'
10
10
  G
11
11
 
12
- bundle "cache"
13
- out.should == "Updating .gem files in vendor/cache"
12
+ bundle "#{cmd} --all"
13
+ bundled_app("vendor/cache/foo-1.0").should_not exist
14
+ should_be_installed "foo 1.0"
14
15
  end
15
16
 
16
- it "warns when the path is outside of the bundle" do
17
+ it "copies when the path is outside the bundle " do
17
18
  build_lib "foo"
18
19
 
19
20
  install_gemfile <<-G
20
21
  gem "foo", :path => '#{lib_path("foo-1.0")}'
21
22
  G
22
23
 
23
- bundle "cache"
24
- out.should include("foo at `#{lib_path("foo-1.0")}` will not be cached")
24
+ bundle "#{cmd} --all"
25
+ bundled_app("vendor/cache/foo-1.0").should exist
26
+
27
+ FileUtils.rm_rf lib_path("foo-1.0")
28
+ should_be_installed "foo 1.0"
29
+ end
30
+
31
+ it "updates the path on each cache" do
32
+ build_lib "foo"
33
+
34
+ install_gemfile <<-G
35
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
36
+ G
37
+
38
+ bundle "#{cmd} --all"
39
+
40
+ build_lib "foo" do |s|
41
+ s.write "lib/foo.rb", "puts :CACHE"
42
+ end
43
+
44
+ bundle "#{cmd} --all"
45
+
46
+ bundled_app("vendor/cache/foo-1.0").should exist
47
+ FileUtils.rm_rf lib_path("foo-1.0")
48
+
49
+ run "require 'foo'"
50
+ out.should == "CACHE"
51
+ end
52
+
53
+ it "raises a warning without --all" do
54
+ build_lib "foo"
55
+
56
+ install_gemfile <<-G
57
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
58
+ G
59
+
60
+ bundle cmd
61
+ out.should =~ /please pass the \-\-all flag/
62
+ bundled_app("vendor/cache/foo-1.0").should_not exist
63
+ end
64
+
65
+ it "stores the given flag" do
66
+ build_lib "foo"
67
+
68
+ install_gemfile <<-G
69
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
70
+ G
71
+
72
+ bundle "#{cmd} --all"
73
+ build_lib "bar"
74
+
75
+ install_gemfile <<-G
76
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
77
+ gem "bar", :path => '#{lib_path("bar-1.0")}'
78
+ G
79
+
80
+ bundle cmd
81
+ bundled_app("vendor/cache/bar-1.0").should exist
82
+ end
83
+
84
+ it "can rewind chosen configuration" do
85
+ build_lib "foo"
86
+
87
+ install_gemfile <<-G
88
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
89
+ G
90
+
91
+ bundle "#{cmd} --all"
92
+ build_lib "baz"
93
+
94
+ gemfile <<-G
95
+ gem "foo", :path => '#{lib_path("foo-1.0")}'
96
+ gem "baz", :path => '#{lib_path("baz-1.0")}'
97
+ G
98
+
99
+ bundle "#{cmd} --no-all"
100
+ bundled_app("vendor/cache/baz-1.0").should_not exist
25
101
  end
26
102
  end
27
- end
103
+ end