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
@@ -2,13 +2,6 @@ before_script:
2
2
  - sudo apt-get install groff -y
3
3
  - rake spec:deps
4
4
 
5
- script: rake spec:travis
6
-
7
- rvm:
8
- - 1.8.7
9
- - 1.9.2
10
- - 1.9.3
11
-
12
5
  env:
13
6
  - RGV=v1.3.6
14
7
  - RGV=v1.3.7
@@ -18,6 +11,8 @@ env:
18
11
  - RGV=v1.7.2
19
12
  - RGV=v1.8.10
20
13
 
14
+ language: ruby
15
+
21
16
  matrix:
22
17
  exclude:
23
18
  - rvm: 1.9.2
@@ -37,3 +32,11 @@ notifications:
37
32
  email:
38
33
  - travis-ci@andrearko.com
39
34
  - hone02@gmail.com
35
+ - sferik@gmail.com
36
+
37
+ rvm:
38
+ - 1.8.7
39
+ - 1.9.2
40
+ - 1.9.3
41
+
42
+ script: rake spec:travis
@@ -1,18 +1,37 @@
1
- ## 1.1.5 (Jul 17, 2012)
1
+ ## 1.2.0.pre
2
2
 
3
3
  Features:
4
4
 
5
- - Special case `ruby` directive from 1.2.0, so you can install Gemfiles that use it
5
+ - bundle package now accepts --all to package git and path dependencies
6
+ - bundle config now accepts --local, --global and --delete options
7
+ - It is possible to override a git repository via configuration.
8
+ For instance, if you have a git dependency on rack, you can force
9
+ it to use a local repo with `bundle config local.rack ~/path/to/rack`
10
+ - Cache gemspec loads for performance (@dekellum, #1635)
11
+ - add --full-index flag to `bundle update` (@fluxx, #1829)
12
+ - add --quiet flag to `bundle update` (@nashby, #1654)
13
+ - Add Bundler::GemHelper.gemspec (@knu, #1637)
14
+ - Graceful handling of Gemfile syntax errors (@koraktor, #1661)
15
+ - `bundle platform` command
16
+ - add ruby to DSL, to specify version of ruby
17
+ - error out if the ruby version doesn't match
6
18
 
7
- ## 1.1.4 (May 27, 2012)
19
+ Performance:
20
+
21
+ - bundle exec shouldn't run Bundler.setup just setting the right rubyopts options is enough (@spastorino, #1598)
8
22
 
9
23
  Bugfixes:
10
24
 
11
- - Use `latest_release` in Capistrano and Vlad integration (#1264)
12
- - Unknown exceptions now link to ISSUES for help instead of a new ticket
13
- - When OpenSSL is missing, provide instructions for fixing (#1776 etc.)
14
- - Correct inline help for `clean --force` (@dougbarth, #1911)
15
- - Work around a Ruby 1.9.3p194 bug in Psych when config files are empty
25
+ - Avoid passing RUBYOPT changes in with_clean_env block (@eric1234, #1604)
26
+ - Use the same ruby to run subprocesses as is running rake (@brixen)
27
+
28
+ Documentation:
29
+
30
+ - Add :github documentation in DSL (@zofrex, #1848, #1851, #1852)
31
+ - Add docs for the --no-cache option (@fluxx, #1796)
32
+ - Add basic documentation for bin_path and bundle_path (@radar)
33
+ - Add documentation for the run method in Bundler::Installer
34
+
16
35
 
17
36
  ## 1.1.3 (March 23, 2012)
18
37
 
data/ISSUES.md CHANGED
@@ -1,20 +1,10 @@
1
1
  # Bundler Issues
2
2
 
3
- So! You're having problems with Bundler. This file is here to help. If you're running into an error, try reading the rest of this file for help. If you can't figure out how to solve your problem, there are also instructions on how to report a bug.
4
-
5
- ## Documentation
6
-
7
- Instructions for common Bundler uses can be found on the [Bundler documentation site](http://gembundler.com/v1.0/).
8
-
9
- Detailed information about each Bundler command, including help with common problems, can be found in the [Bundler man pages](http://gembundler.com/man/bundle.1.html).
10
-
11
3
  ## Troubleshooting
12
4
 
13
- ### Heroku errors
14
-
15
- Please open a ticket with Heroku if you're having trouble deploying. They have a professional support team who can help you resolve Heroku issues far better than the Bundler team can. If the problem that you are having turns out to be a bug in Bundler itself, Heroku support can get the exact details to us.
5
+ Instructions for common Bundler use-cases can be found on the [Bundler documentation site](http://gembundler.com/v1.0/).
16
6
 
17
- ### Something else
7
+ Detailed information about each Bundler command, including help with common problems, can be found in the [Bundler man pages](http://gembundler.com/man/bundle.1.html).
18
8
 
19
9
  After reading the documentation, try these troubleshooting steps:
20
10
 
@@ -36,9 +26,24 @@ After reading the documentation, try these troubleshooting steps:
36
26
  # try to install one more time
37
27
  bundle install
38
28
 
29
+ ## Frequently encountered issues
30
+
31
+ ### Heroku errors
32
+
33
+ Open a ticket with Heroku. If the issue somehow turns out to be with Bundler itself, the Heroku support team will forward the details of your issue to us.
34
+
35
+ ### REE and Zlib::GzipFile::Error
36
+
37
+ Ruby Enterprise Edition users may see a `Zlib::GzipFile::Error` while installing gems. It is due to [a bug in REE](http://code.google.com/p/rubyenterpriseedition/issues/detail?id=45). You may be able to resolve the issue by upgrading REE, or changing to a different interpreter.
38
+
39
+ ### Rake activation error
40
+
41
+ Anyone who has installed the Spork gem may see activation errors while running `rake` directly. This is because old versions of Spork would [install the newest rake using a mkmf file](https://github.com/timcharper/spork/issues/119). To resolve the issue, update the Spork version requirement in your Gemfile to at least `"~>0.8.5"` or `"~>0.9.0.rc8"`.
42
+
43
+
39
44
  ## Reporting unresolved problems
40
45
 
41
- The Bundler team needs to know some things in order to diagnose and hopefully fix the bug you've found. When you report a bug, please include the following information:
46
+ Instructions that allow the Bundler team to reproduce your issue are vitally important. When you report a bug, please include the following information:
42
47
 
43
48
  - The command you ran
44
49
  - Exception backtrace(s), if any
@@ -52,12 +57,11 @@ The Bundler team needs to know some things in order to diagnose and hopefully fi
52
57
  - Whether you have the `rubygems-bundler` gem, which can break gem binares
53
58
  - Whether you have the `open_gem` gem, which can cause rake activation conflicts
54
59
 
60
+
55
61
  If you are using Rails 2.3, please also include:
56
62
 
57
63
  - Your boot.rb file
58
64
  - Your preinitializer.rb file
59
65
  - Your environment.rb file
60
66
 
61
- [Create a gist](https://gist.github.com) containing all of that information, then visit the [Bundler issue tracker](https://github.com/carlhuda/bundler/issues) and [create a new ticket](https://github.com/carlhuda/bundler/issues/new) describing your problem and linking to your gist.
62
-
63
- Thanks for reporting issues and making Bundler better!
67
+ [Create a gist](https://gist.github.com) containing all of that information, then visit the [Bundler issue tracker](https://github.com/carlhuda/bundler) and create a new ticket describing your problem and linking to your gist.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://secure.travis-ci.org/carlhuda/bundler.png?branch=master)](http://travis-ci.org/carlhuda/bundler)
2
+
1
3
  # Bundler: a gem to bundle gems
2
4
 
3
5
  Bundler is a tool that manages gem dependencies for your ruby application. It
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.unshift File.expand_path("../lib", __FILE__)
3
+ require 'rubygems'
3
4
  require 'bundler/gem_tasks'
4
5
 
5
6
  task :release => ["man:clean", "man:build"]
@@ -18,8 +19,8 @@ end
18
19
  namespace :spec do
19
20
  desc "Ensure spec dependencies are installed"
20
21
  task :deps do
21
- sh "gem list ronn | (grep 'ronn' 1> /dev/null) || gem install ronn --no-ri --no-rdoc"
22
- sh "gem list rspec | (grep 'rspec (2.' 1> /dev/null) || gem install rspec --no-ri --no-rdoc"
22
+ sh "#{Gem.ruby} -S gem list ronn | (grep 'ronn' 1> /dev/null) || #{Gem.ruby} -S gem install ronn --no-ri --no-rdoc"
23
+ sh "#{Gem.ruby} -S gem list rspec | (grep 'rspec (2.' 1> /dev/null) || #{Gem.ruby} -S gem install rspec --no-ri --no-rdoc"
23
24
  end
24
25
  end
25
26
 
@@ -40,7 +41,7 @@ begin
40
41
  rm_rf 'tmp'
41
42
  end
42
43
 
43
- desc "Run the real-world spec suite (reequires internet)"
44
+ desc "Run the real-world spec suite (requires internet)"
44
45
  task :realworld => ["set_realworld", "spec"]
45
46
 
46
47
  task :set_realworld do
@@ -142,7 +143,7 @@ begin
142
143
  roff = "lib/bundler/man/#{basename}"
143
144
 
144
145
  file roff => ["lib/bundler/man", ronn] do
145
- sh "ronn --roff --pipe #{ronn} > #{roff}"
146
+ sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
146
147
  end
147
148
 
148
149
  file "#{roff}.txt" => roff do
@@ -178,7 +179,7 @@ begin
178
179
 
179
180
  desc "Install CI dependencies"
180
181
  task :deps do
181
- sh "gem list ci_reporter | (grep 'ci_reporter' 1> /dev/null) || gem install ci_reporter --no-ri --no-rdoc"
182
+ sh "#{Gem.ruby} -S gem list ci_reporter | (grep 'ci_reporter' 1> /dev/null) || #{Gem.ruby} -S gem install ci_reporter --no-ri --no-rdoc"
182
183
  end
183
184
  task :deps => "spec:deps"
184
185
  end
data/bin/bundle CHANGED
@@ -22,8 +22,10 @@ rescue Interrupt => e
22
22
  rescue SystemExit => e
23
23
  exit e.status
24
24
  rescue Exception => e
25
- Bundler.ui.error(
26
- "Unfortunately, a fatal error has occurred. Please see the Bundler \n" \
27
- "troubleshooting documentation at http://bit.ly/bundler-issues. Thanks! \n")
25
+ Bundler.ui.error "Unfortunately, a fatal error has occurred. " +
26
+ "Please report this error to the Bundler issue tracker at " +
27
+ "https://github.com/carlhuda/bundler/issues so that we can fix it. " +
28
+ "Please include the full output of the command, your Gemfile and Gemfile.lock. " +
29
+ "Thanks!"
28
30
  raise e
29
31
  end
@@ -27,12 +27,14 @@ module Bundler
27
27
  autoload :MatchPlatform, 'bundler/match_platform'
28
28
  autoload :RemoteSpecification, 'bundler/remote_specification'
29
29
  autoload :Resolver, 'bundler/resolver'
30
+ autoload :RubyVersion, 'bundler/ruby_version'
30
31
  autoload :Runtime, 'bundler/runtime'
31
32
  autoload :Settings, 'bundler/settings'
32
33
  autoload :SharedHelpers, 'bundler/shared_helpers'
33
34
  autoload :SpecSet, 'bundler/spec_set'
34
35
  autoload :Source, 'bundler/source'
35
36
  autoload :Specification, 'bundler/shared_helpers'
37
+ autoload :SystemRubyVersion, 'bundler/ruby_version'
36
38
  autoload :UI, 'bundler/ui'
37
39
 
38
40
  class BundlerError < StandardError
@@ -41,19 +43,20 @@ module Bundler
41
43
  end
42
44
  end
43
45
 
44
- class GemfileNotFound < BundlerError; status_code(10) ; end
45
- class GemNotFound < BundlerError; status_code(7) ; end
46
- class GemfileError < BundlerError; status_code(4) ; end
47
- class InstallError < BundlerError; status_code(5) ; end
48
- class InstallHookError < BundlerError; status_code(6) ; end
49
- class PathError < BundlerError; status_code(13) ; end
50
- class GitError < BundlerError; status_code(11) ; end
51
- class DeprecatedError < BundlerError; status_code(12) ; end
52
- class GemspecError < BundlerError; status_code(14) ; end
53
- class DslError < BundlerError; status_code(15) ; end
54
- class ProductionError < BundlerError; status_code(16) ; end
55
- class InvalidOption < DslError ; end
56
- class HTTPError < BundlerError; status_code(17) ; end
46
+ class GemfileNotFound < BundlerError; status_code(10) ; end
47
+ class GemNotFound < BundlerError; status_code(7) ; end
48
+ class GemfileError < BundlerError; status_code(4) ; end
49
+ class InstallError < BundlerError; status_code(5) ; end
50
+ class InstallHookError < BundlerError; status_code(6) ; end
51
+ class PathError < BundlerError; status_code(13) ; end
52
+ class GitError < BundlerError; status_code(11) ; end
53
+ class DeprecatedError < BundlerError; status_code(12) ; end
54
+ class GemspecError < BundlerError; status_code(14) ; end
55
+ class DslError < BundlerError; status_code(15) ; end
56
+ class ProductionError < BundlerError; status_code(16) ; end
57
+ class InvalidOption < DslError ; end
58
+ class HTTPError < BundlerError; status_code(17) ; end
59
+ class RubyVersionMismatch < BundlerError; status_code(18) ; end
57
60
 
58
61
 
59
62
  WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
@@ -85,10 +88,12 @@ module Bundler
85
88
  @ui ||= UI.new
86
89
  end
87
90
 
91
+ # Returns absolute path of where gems are installed on the filesystem.
88
92
  def bundle_path
89
93
  @bundle_path ||= Pathname.new(settings.path).expand_path(root)
90
94
  end
91
95
 
96
+ # Returns absolute location of where binstubs are installed to.
92
97
  def bin_path
93
98
  @bin_path ||= begin
94
99
  path = settings[:bin] || "bin"
@@ -102,6 +107,8 @@ module Bundler
102
107
  # Just return if all groups are already loaded
103
108
  return @setup if defined?(@setup)
104
109
 
110
+ definition.validate_ruby!
111
+
105
112
  if groups.empty?
106
113
  # Load all groups, but only once
107
114
  @setup = load.setup
@@ -268,6 +275,15 @@ module Bundler
268
275
  end
269
276
 
270
277
  def load_gemspec(file)
278
+ @gemspec_cache ||= {}
279
+ key = File.expand_path(file)
280
+ spec = ( @gemspec_cache[key] ||= load_gemspec_uncached(file) )
281
+ # Protect against caching side-effected gemspecs by returning a
282
+ # new instance each time.
283
+ spec.dup if spec
284
+ end
285
+
286
+ def load_gemspec_uncached(file)
271
287
  path = Pathname.new(file)
272
288
  # Eval the gemspec from its parent directory
273
289
  Dir.chdir(path.dirname.to_s) do
@@ -294,6 +310,10 @@ module Bundler
294
310
  end
295
311
  end
296
312
 
313
+ def clear_gemspec_cache
314
+ @gemspec_cache = {}
315
+ end
316
+
297
317
  private
298
318
 
299
319
  def configure_gem_home_and_path
@@ -5,7 +5,7 @@
5
5
  require 'bundler/deployment'
6
6
 
7
7
  Capistrano::Configuration.instance(:must_exist).load do
8
- before "deploy:finalize_update", "bundle:install"
8
+ after "deploy:finalize_update", "bundle:install"
9
9
  Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
10
10
  set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
11
11
  end
@@ -99,7 +99,9 @@ module Bundler
99
99
 
100
100
  Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
101
101
  begin
102
- not_installed = Bundler.definition.missing_specs
102
+ definition = Bundler.definition
103
+ definition.validate_ruby!
104
+ not_installed = definition.missing_specs
103
105
  rescue GemNotFound, VersionConflict
104
106
  Bundler.ui.error "Your Gemfile's dependencies could not be satisfied"
105
107
  Bundler.ui.warn "Install missing gems with `bundle install`"
@@ -217,7 +219,9 @@ module Bundler
217
219
  # rubygems plugins sometimes hook into the gem install process
218
220
  Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
219
221
 
220
- Installer.install(Bundler.root, Bundler.definition, opts)
222
+ definition = Bundler.definition
223
+ definition.validate_ruby!
224
+ Installer.install(Bundler.root, definition, opts)
221
225
  Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
222
226
 
223
227
  if Bundler.settings[:path]
@@ -256,8 +260,13 @@ module Bundler
256
260
  method_option "source", :type => :array, :banner => "Update a specific source (and all gems associated with it)"
257
261
  method_option "local", :type => :boolean, :banner =>
258
262
  "Do not attempt to fetch gems remotely and use the gem cache instead"
263
+ method_option "quiet", :type => :boolean, :banner =>
264
+ "Only output warnings and errors."
265
+ method_option "full-index", :type => :boolean, :banner =>
266
+ "Use the rubygems modern index instead of the API endpoint"
259
267
  def update(*gems)
260
268
  sources = Array(options[:source])
269
+ Bundler.ui.be_quiet! if options[:quiet]
261
270
 
262
271
  if gems.empty? && sources.empty?
263
272
  # We're doing a full update
@@ -266,10 +275,13 @@ module Bundler
266
275
  Bundler.definition(:gems => gems, :sources => sources)
267
276
  end
268
277
 
278
+ Bundler::Fetcher.disable_endpoint = options["full-index"]
279
+
269
280
  opts = {"update" => true, "local" => options[:local]}
270
281
  # rubygems plugins sometimes hook into the gem install process
271
282
  Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
272
283
 
284
+ Bundler.definition.validate_ruby!
273
285
  Installer.install Bundler.root, Bundler.definition, opts
274
286
  Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
275
287
  clean if Bundler.settings[:clean] && Bundler.settings[:path]
@@ -285,6 +297,7 @@ module Bundler
285
297
  method_option "paths", :type => :boolean,
286
298
  :banner => "List the paths of all gems that are required by your Gemfile."
287
299
  def show(gem_name = nil)
300
+ Bundler.definition.validate_ruby!
288
301
  Bundler.load.lock
289
302
 
290
303
  if gem_name
@@ -314,6 +327,7 @@ module Bundler
314
327
  "Do not attempt to fetch gems remotely and use the gem cache instead"
315
328
  def outdated(*gems)
316
329
  sources = Array(options[:source])
330
+ Bundler.definition.validate_ruby!
317
331
  current_specs = Bundler.load.specs
318
332
 
319
333
  if gems.empty? && sources.empty?
@@ -362,8 +376,11 @@ module Bundler
362
376
 
363
377
  desc "cache", "Cache all the gems to vendor/cache", :hide => true
364
378
  method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
379
+ method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
365
380
  def cache
381
+ Bundler.definition.validate_ruby!
366
382
  Bundler.definition.resolve_with_cache!
383
+ setup_cache_all
367
384
  Bundler.load.cache
368
385
  Bundler.settings[:no_prune] = true if options["no-prune"]
369
386
  Bundler.load.lock
@@ -375,6 +392,7 @@ module Bundler
375
392
 
376
393
  desc "package", "Locks and then caches all of the gems into vendor/cache"
377
394
  method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
395
+ method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
378
396
  long_desc <<-D
379
397
  The package command will copy the .gem files for every gem in the bundle into the
380
398
  directory ./vendor/cache. If you then check that directory into your source
@@ -382,6 +400,7 @@ module Bundler
382
400
  bundle without having to download any additional gems.
383
401
  D
384
402
  def package
403
+ setup_cache_all
385
404
  install
386
405
  # TODO: move cache contents here now that all bundles are locked
387
406
  Bundler.load.cache
@@ -397,6 +416,7 @@ module Bundler
397
416
  def exec(*)
398
417
  ARGV.shift # remove "exec"
399
418
 
419
+ Bundler.definition.validate_ruby!
400
420
  Bundler.load.setup_environment
401
421
 
402
422
  begin
@@ -427,10 +447,17 @@ module Bundler
427
447
  will show the current value, as well as any superceded values and
428
448
  where they were specified.
429
449
  D
430
- def config(name = nil, *args)
450
+ def config(*)
431
451
  values = ARGV.dup
432
452
  values.shift # remove config
433
- values.shift # remove the name
453
+
454
+ peek = values.shift
455
+
456
+ if peek && peek =~ /^\-\-/
457
+ name, scope = values.shift, $'
458
+ else
459
+ name, scope = peek, "global"
460
+ end
434
461
 
435
462
  unless name
436
463
  Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
@@ -447,29 +474,45 @@ module Bundler
447
474
  return
448
475
  end
449
476
 
450
- if values.empty?
451
- Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
452
- with_padding do
453
- Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line }
477
+ case scope
478
+ when "delete"
479
+ Bundler.settings.set_local(name, nil)
480
+ Bundler.settings.set_global(name, nil)
481
+ when "local", "global"
482
+ if values.empty?
483
+ Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
484
+ with_padding do
485
+ Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line }
486
+ end
487
+ return
454
488
  end
455
- else
489
+
456
490
  locations = Bundler.settings.locations(name)
457
491
 
458
- if local = locations[:local]
459
- Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " \
460
- "system value you are currently setting"
461
- end
492
+ if scope == "global"
493
+ if local = locations[:local]
494
+ Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " \
495
+ "global value you are currently setting"
496
+ end
497
+
498
+ if env = locations[:env]
499
+ Bundler.ui.info "You have a bundler environment variable for #{name} set to #{env.inspect}. " \
500
+ "This will take precedence over the global value you are setting"
501
+ end
462
502
 
463
- if global = locations[:global]
464
- Bundler.ui.info "You are replacing the current system value of #{name}, which is currently #{global}"
503
+ if global = locations[:global]
504
+ Bundler.ui.info "You are replacing the current global value of #{name}, which is currently #{global.inspect}"
505
+ end
465
506
  end
466
507
 
467
- if env = locations[:env]
468
- Bundler.ui.info "You have set a bundler environment variable for #{env}. This will take precedence " \
469
- "over the system value you are setting"
508
+ if scope == "local" && local = locations[:local]
509
+ Bundler.ui.info "You are replacing the current local value of #{name}, which is currently #{local.inspect}"
470
510
  end
471
511
 
472
- Bundler.settings.set_global(name, values.join(" "))
512
+ Bundler.settings.send("set_#{scope}", name, values.join(" "))
513
+ else
514
+ Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
515
+ exit 1
473
516
  end
474
517
  end
475
518
 
@@ -573,7 +616,7 @@ module Bundler
573
616
 
574
617
  desc "clean", "Cleans up unused gems in your bundler directory"
575
618
  method_option "force", :type => :boolean, :default => false, :banner =>
576
- "forces clean even if --path is not set"
619
+ "forces clean even if --path is set"
577
620
  def clean
578
621
  if Bundler.settings[:path] || options[:force]
579
622
  Bundler.load.clean
@@ -583,8 +626,53 @@ module Bundler
583
626
  end
584
627
  end
585
628
 
629
+ desc "platform", "Displays platform compatibility information"
630
+ method_option "ruby", :type => :boolean, :default => false, :banner =>
631
+ "only display ruby related platform information"
632
+ def platform
633
+ platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
634
+ ruby_version = Bundler.definition.ruby_version
635
+ output = []
636
+
637
+ if options[:ruby]
638
+ if ruby_version
639
+ output << ruby_version
640
+ else
641
+ output << "No ruby version specified"
642
+ end
643
+ else
644
+ output << "Your platform is: #{RUBY_PLATFORM}"
645
+ output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
646
+
647
+ if ruby_version
648
+ output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
649
+
650
+ begin
651
+ Bundler.definition.validate_ruby!
652
+ output << "Your current platform satisfies the Ruby version requirement."
653
+ rescue RubyVersionMismatch => e
654
+ output << e.message
655
+ end
656
+ else
657
+ output << "Your Gemfile does not specify a Ruby version requirement."
658
+ end
659
+ end
660
+
661
+ Bundler.ui.info output.join("\n\n")
662
+ end
663
+
586
664
  private
587
665
 
666
+ def setup_cache_all
667
+ if options.key?("all")
668
+ Bundler.settings[:cache_all] = options[:all] || nil
669
+ elsif Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) }
670
+ Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
671
+ "to package them as well, please pass the --all flag. This will be the default " \
672
+ "on Bundler 2.0."
673
+ end
674
+ end
675
+
588
676
  def have_groff?
589
677
  !(`which groff` rescue '').empty?
590
678
  end