bundler 1.6.0.pre.1 → 1.6.0.pre.2

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -3
  3. data/Rakefile +12 -7
  4. data/lib/bundler.rb +3 -3
  5. data/lib/bundler/cli.rb +36 -619
  6. data/lib/bundler/cli/binstubs.rb +36 -0
  7. data/lib/bundler/cli/cache.rb +34 -0
  8. data/lib/bundler/cli/check.rb +35 -0
  9. data/lib/bundler/cli/clean.rb +19 -0
  10. data/lib/bundler/cli/common.rb +54 -0
  11. data/lib/bundler/cli/config.rb +84 -0
  12. data/lib/bundler/cli/console.rb +42 -0
  13. data/lib/bundler/cli/exec.rb +37 -0
  14. data/lib/bundler/cli/gem.rb +61 -0
  15. data/lib/bundler/cli/init.rb +33 -0
  16. data/lib/bundler/cli/inject.rb +33 -0
  17. data/lib/bundler/cli/install.rb +123 -0
  18. data/lib/bundler/cli/open.rb +25 -0
  19. data/lib/bundler/cli/outdated.rb +80 -0
  20. data/lib/bundler/cli/package.rb +36 -0
  21. data/lib/bundler/cli/platform.rb +43 -0
  22. data/lib/bundler/cli/show.rb +44 -0
  23. data/lib/bundler/cli/update.rb +73 -0
  24. data/lib/bundler/cli/viz.rb +27 -0
  25. data/lib/bundler/dsl.rb +46 -26
  26. data/lib/bundler/fetcher.rb +50 -4
  27. data/lib/bundler/installer.rb +1 -1
  28. data/lib/bundler/parallel_workers/worker.rb +1 -1
  29. data/lib/bundler/remote_specification.rb +1 -1
  30. data/lib/bundler/resolver.rb +30 -18
  31. data/lib/bundler/source/git.rb +0 -4
  32. data/lib/bundler/source/git/git_proxy.rb +2 -2
  33. data/lib/bundler/source/rubygems.rb +1 -14
  34. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -1
  35. data/lib/bundler/vendor/thor/base.rb +1 -1
  36. data/lib/bundler/version.rb +1 -1
  37. data/spec/bundler/bundler_spec.rb +46 -47
  38. data/spec/bundler/{cli_rspec.rb → cli_spec.rb} +0 -1
  39. data/spec/bundler/definition_spec.rb +3 -7
  40. data/spec/bundler/dsl_spec.rb +43 -21
  41. data/spec/bundler/gem_helper_spec.rb +152 -123
  42. data/spec/bundler/retry_spec.rb +6 -7
  43. data/spec/bundler/settings_spec.rb +0 -2
  44. data/spec/bundler/source_spec.rb +4 -4
  45. data/spec/commands/newgem_spec.rb +7 -7
  46. data/spec/commands/outdated_spec.rb +11 -0
  47. data/spec/install/gems/dependency_api_spec.rb +41 -0
  48. data/spec/install/gems/simple_case_spec.rb +1 -17
  49. data/spec/other/ext_spec.rb +1 -1
  50. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +18 -0
  51. data/spec/support/builders.rb +43 -42
  52. data/spec/support/permissions.rb +0 -1
  53. data/spec/update/gems_spec.rb +11 -0
  54. metadata +51 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba02e8bf782c12afb3abc0227c0589c4008d7a50
4
- data.tar.gz: d24a21a4d7ee5c5b8a170e7268cfd87927a8a2c1
3
+ metadata.gz: 82bb96245aad548e3f54e66a218d8e3067896263
4
+ data.tar.gz: b2db8a96173217dbe55870f6cfb5010d20c3dfb9
5
5
  SHA512:
6
- metadata.gz: d4edc092f83b06ea5d803ff0c7f732339e01f37f34fb8675a263f228e2f1ffffc8c032af1f628aa8939db4acf0715baf41bf3d232375b2126646c0c0ef46d657
7
- data.tar.gz: 8b5bd0fa37c93c3aef9bb1fb5b7d43e28f3e550e21917eadd498f5d766a582d69f11e68f3007a21425863e30c6d58179cab716df25b488a6d265ed434b10d833
6
+ metadata.gz: 8ecbe4d05b632741d905d9ed74d5041e4e4c22215e30557db72d982e5c0414caf5e6ae8c297d79ede129b6ef1370d35dae597b3b7ffa09d38106f7ad0fcd20ef
7
+ data.tar.gz: cde92cfd5835369cc85496e4dbd42a6d63b8bd5091cb416031b161f0f9738ff9e3409cdbf598d4ad5283b402864a9325e83c61913d4fed07f6adbd8a22507f6c
@@ -2,15 +2,29 @@
2
2
 
3
3
  Bugfixes:
4
4
 
5
- - many Gemfiles that had incorrect errors now resolve correctly (@Who828)
5
+ - many Gemfiles that caused incorrect errors now resolve correctly (@Who828)
6
+ - redirects across hosts now work on rubies without OpenSSL (#2686, @grddev)
7
+ - gemspecs now handle filenames with newlines (#2634, @jasonmp85)
8
+ - support escaped characters in usernames and passwords (@punkie)
9
+ - no more exception on `update GEM` without lock file (@simi)
6
10
 
7
11
  Features:
8
12
 
9
13
  - resolver rewritten to avoid recursion (@Who828)
14
+ - add `git_source` for custom options like :github and :gist (@strzalek)
15
+ - HTTP auth may now be stored in `bundle config` (@smashwilson)
10
16
  - some complex Gemfiles are resolved up to 10x faster (@Who828)
11
17
  - add support for IRB alternatives such as Pry and Ripl (@joallard, @postmodern)
12
18
  - highlight installed or updated gems (#2722, #2741, @yaotti, @simi)
13
- - display post_install_message's for gems installed via :git (@phallstrom)
19
+ - display the `post_install_message` for gems installed via :git (@phallstrom)
20
+ - `bundle outdated --strict` now only reports allowed updates (@davidblondeau)
21
+
22
+ ## 1.5.3 (2014-02-06)
23
+
24
+ Bugfixes:
25
+
26
+ - find "missing" gems that are actually present (#2780, #2818, #2854)
27
+ - pse n-1 cores when given n jobs for parallel install (@jdickey)
14
28
 
15
29
  ## 1.5.2 (2014-01-10)
16
30
 
@@ -56,7 +70,7 @@ Features:
56
70
 
57
71
  - bundle update also accepts --jobs (#2692, @mrkn)
58
72
  - add fork URL to README for new `bundle gem` (#2665, @zzak)
59
- - add `bundle outdated --strict` (#2685, @rhysd)
73
+ - add `bundle outdated --strict` (#2685, @davidblondeau)
60
74
  - warn if same gem/version is added twice (#2679, @jendiamond)
61
75
  - don't redownload installed specs for `bundle install` (#2680, @cainlevy)
62
76
  - override gem sources with mirrors (#2650, @danielsdeleo, @mkristian)
data/Rakefile CHANGED
@@ -30,8 +30,8 @@ end
30
30
  namespace :spec do
31
31
  desc "Ensure spec dependencies are installed"
32
32
  task :deps do
33
- {"rdiscount" => "~> 1.6", "ronn" => "~> 0.7.3", "rspec" => "~> 2.99.0.beta1"}.each do |name, version|
34
- sh "#{Gem.ruby} -S gem list -i #{name} -v '#{version}' || " \
33
+ {"rdiscount" => "~> 1.6", "ronn" => "~> 0.7.3", "rspec" => "~> 3.0.beta"}.each do |name, version|
34
+ sh "#{Gem.ruby} -S gem list -i '^#{name}$' -v '#{version}' || " \
35
35
  "#{Gem.ruby} -S gem install #{name} -v '#{version}' --no-ri --no-rdoc"
36
36
  end
37
37
  end
@@ -39,14 +39,19 @@ namespace :spec do
39
39
  namespace :travis do
40
40
  task :deps do
41
41
  # Give the travis user a name so that git won't fatally error
42
- system("sudo sed -i 's/1000::/1000:Travis:/g' /etc/passwd")
42
+ system "sudo sed -i 's/1000::/1000:Travis:/g' /etc/passwd"
43
43
  # Strip secure_path so that RVM paths transmit through sudo -E
44
- system("sudo sed -i '/secure_path/d' /etc/sudoers")
44
+ system "sudo sed -i '/secure_path/d' /etc/sudoers"
45
45
  # Install groff for the ronn gem
46
- system("sudo apt-get install groff -y")
47
- # Downgrade Rubygems on 1.8 to avoid https://github.com/rubygems/rubygems/issues/784
46
+ sh "sudo apt-get install groff -y"
48
47
  if RUBY_VERSION < '1.9'
49
- system("gem update --system 2.1.11")
48
+ # Downgrade Rubygems on 1.8 so Ronn can be required
49
+ # https://github.com/rubygems/rubygems/issues/784
50
+ sh "gem update --system 2.1.11"
51
+ else
52
+ # Downgrade Rubygems so RSpec 3 can be instaled
53
+ # https://github.com/rubygems/rubygems/issues/813
54
+ sh "gem update --system 2.2.0"
50
55
  end
51
56
  # Install the other gem deps, etc.
52
57
  Rake::Task["spec:deps"].invoke
@@ -55,7 +55,7 @@ module Bundler
55
55
  class GemNotFound < BundlerError; status_code(7) ; end
56
56
  class GemfileError < BundlerError; status_code(4) ; end
57
57
  class InstallError < BundlerError; status_code(5) ; end
58
- class InstallHookError < BundlerError; status_code(6) ; end
58
+ class InstallHookError < BundlerError; status_code(8) ; end
59
59
  class PathError < BundlerError; status_code(13) ; end
60
60
  class GitError < BundlerError; status_code(11) ; end
61
61
  class DeprecatedError < BundlerError; status_code(12) ; end
@@ -67,6 +67,7 @@ module Bundler
67
67
  class SecurityError < BundlerError; status_code(19) ; end
68
68
  class LockfileError < BundlerError; status_code(20) ; end
69
69
  class CyclicDependencyError < BundlerError; status_code(21) ; end
70
+ class GemfileLockNotFound < BundlerError; status_code(22) ; end
70
71
 
71
72
  # Internal errors, should be rescued
72
73
  class VersionConflict < BundlerError
@@ -395,14 +396,13 @@ module Bundler
395
396
  blank_home = ENV['GEM_HOME'].nil? || ENV['GEM_HOME'].empty?
396
397
  if settings[:disable_shared_gems]
397
398
  ENV['GEM_PATH'] = ''
398
- configure_gem_home
399
399
  elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s
400
400
  possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
401
401
  paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
402
402
  ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
403
- configure_gem_home
404
403
  end
405
404
 
405
+ configure_gem_home
406
406
  bundle_path
407
407
  end
408
408
 
@@ -72,28 +72,8 @@ module Bundler
72
72
  D
73
73
  method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
74
74
  def init
75
- opts = options.dup
76
- if File.exist?("Gemfile")
77
- Bundler.ui.error "Gemfile already exists at #{Dir.pwd}/Gemfile"
78
- exit 1
79
- end
80
-
81
- if opts[:gemspec]
82
- gemspec = File.expand_path(opts[:gemspec])
83
- unless File.exist?(gemspec)
84
- Bundler.ui.error "Gem specification #{gemspec} doesn't exist"
85
- exit 1
86
- end
87
- spec = Gem::Specification.load(gemspec)
88
- puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
89
- File.open('Gemfile', 'wb') do |file|
90
- file << "# Generated from #{gemspec}\n"
91
- file << spec.to_gemfile
92
- end
93
- else
94
- puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
95
- FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
96
- end
75
+ require 'bundler/cli/init'
76
+ Init.new(options.dup).run
97
77
  end
98
78
 
99
79
  desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
@@ -109,29 +89,8 @@ module Bundler
109
89
  method_option "dry-run", :type => :boolean, :default => false, :banner =>
110
90
  "Lock the Gemfile"
111
91
  def check
112
- Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
113
- begin
114
- definition = Bundler.definition
115
- definition.validate_ruby!
116
- not_installed = definition.missing_specs
117
- rescue GemNotFound, VersionConflict
118
- Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
119
- Bundler.ui.warn "Install missing gems with `bundle install`."
120
- exit 1
121
- end
122
-
123
- if not_installed.any?
124
- Bundler.ui.error "The following gems are missing"
125
- not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" }
126
- Bundler.ui.warn "Install missing gems with `bundle install`"
127
- exit 1
128
- elsif !Bundler.default_lockfile.exist? && Bundler.settings[:frozen]
129
- Bundler.ui.error "This bundle has been frozen, but there is no Gemfile.lock present"
130
- exit 1
131
- else
132
- Bundler.load.lock unless options[:"dry-run"]
133
- Bundler.ui.info "The Gemfile's dependencies are satisfied"
134
- end
92
+ require 'bundler/cli/check'
93
+ Check.new(options).run
135
94
  end
136
95
 
137
96
  desc "install", "Install the current environment to the system"
@@ -183,107 +142,8 @@ module Bundler
183
142
  "Specify the number of jobs to run in parallel"
184
143
 
185
144
  def install
186
- opts = options.dup
187
- if opts[:without]
188
- opts[:without] = opts[:without].map{|g| g.tr(' ', ':') }
189
- end
190
-
191
- ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
192
-
193
- # Just disable color in deployment mode
194
- Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment]
195
-
196
- if (opts[:path] || opts[:deployment]) && opts[:system]
197
- Bundler.ui.error "You have specified both a path to install your gems to, \n" \
198
- "as well as --system. Please choose."
199
- exit 1
200
- end
201
-
202
- if (opts["trust-policy"])
203
- unless (Bundler.rubygems.security_policies.keys.include?(opts["trust-policy"]))
204
- Bundler.ui.error "Rubygems doesn't know about trust policy '#{opts["trust-policy"]}'. " \
205
- "The known policies are: #{Bundler.rubygems.security_policies.keys.join(', ')}."
206
- exit 1
207
- end
208
- Bundler.settings["trust-policy"] = opts["trust-policy"]
209
- else
210
- Bundler.settings["trust-policy"] = nil if Bundler.settings["trust-policy"]
211
- end
212
-
213
- if opts[:deployment] || opts[:frozen]
214
- unless Bundler.default_lockfile.exist?
215
- flag = opts[:deployment] ? '--deployment' : '--frozen'
216
- raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " \
217
- "sure you have checked your Gemfile.lock into version control " \
218
- "before deploying."
219
- end
220
-
221
- if Bundler.root.join("vendor/cache").exist?
222
- opts[:local] = true
223
- end
224
-
225
- Bundler.settings[:frozen] = '1'
226
- end
227
-
228
- # When install is called with --no-deployment, disable deployment mode
229
- if opts[:deployment] == false
230
- Bundler.settings.delete(:frozen)
231
- opts[:system] = true
232
- end
233
-
234
- Bundler.settings[:path] = nil if opts[:system]
235
- Bundler.settings[:path] = "vendor/bundle" if opts[:deployment]
236
- Bundler.settings[:path] = opts["path"] if opts["path"]
237
- Bundler.settings[:path] ||= "bundle" if opts["standalone"]
238
- Bundler.settings[:bin] = opts["binstubs"] if opts["binstubs"]
239
- Bundler.settings[:bin] = nil if opts["binstubs"] && opts["binstubs"].empty?
240
- Bundler.settings[:shebang] = opts["shebang"] if opts["shebang"]
241
- Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"]
242
- Bundler.settings[:no_prune] = true if opts["no-prune"]
243
- Bundler.settings[:clean] = opts["clean"] if opts["clean"]
244
- Bundler.settings.without = opts[:without]
245
- Bundler.ui.level = "warn" if opts[:quiet]
246
- Bundler::Fetcher.disable_endpoint = opts["full-index"]
247
- Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil
248
-
249
- # rubygems plugins sometimes hook into the gem install process
250
- Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
251
-
252
- definition = Bundler.definition
253
- definition.validate_ruby!
254
- Installer.install(Bundler.root, definition, opts)
255
- Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
256
-
257
- if Bundler.settings[:path]
258
- absolute_path = File.expand_path(Bundler.settings[:path])
259
- relative_path = absolute_path.sub(File.expand_path('.'), '.')
260
- Bundler.ui.confirm "Your bundle is complete!"
261
- Bundler.ui.confirm without_groups_message if Bundler.settings.without.any?
262
- Bundler.ui.confirm "It was installed into #{relative_path}"
263
- else
264
- Bundler.ui.confirm "Your bundle is complete!"
265
- Bundler.ui.confirm without_groups_message if Bundler.settings.without.any?
266
- Bundler.ui.confirm "Use `bundle show [gemname]` to see where a bundled gem is installed."
267
- end
268
- Installer.post_install_messages.to_a.each do |name, msg|
269
- Bundler.ui.confirm "Post-install message from #{name}:"
270
- Bundler.ui.info msg
271
- end
272
-
273
- clean if Bundler.settings[:clean] && Bundler.settings[:path]
274
- rescue GemNotFound, VersionConflict => e
275
- if opts[:local] && Bundler.app_cache.exist?
276
- Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
277
- end
278
-
279
- if Bundler.definition.rubygems_remotes.empty?
280
- Bundler.ui.warn <<-WARN, :wrap => true
281
- Your Gemfile has no gem server sources. If you need gems that are \
282
- not already on your machine, add a line like this to your Gemfile:
283
- source 'https://rubygems.org'
284
- WARN
285
- end
286
- raise e
145
+ require 'bundler/cli/install'
146
+ Install.new(options.dup).run
287
147
  end
288
148
 
289
149
  desc "update", "update the current environment"
@@ -304,46 +164,8 @@ module Bundler
304
164
  method_option "group", :aliases => "-g", :type => :array, :banner =>
305
165
  "Update a specific group"
306
166
  def update(*gems)
307
- sources = Array(options[:source])
308
- groups = Array(options[:group]).map(&:to_sym)
309
- Bundler.ui.level = "warn" if options[:quiet]
310
-
311
- if gems.empty? && sources.empty? && groups.empty?
312
- # We're doing a full update
313
- Bundler.definition(true)
314
- else
315
- # cycle through the requested gems, just to make sure they exist
316
- names = Bundler.locked_gems.specs.map{ |s| s.name }
317
- gems.each do |g|
318
- next if names.include?(g)
319
- raise GemNotFound, not_found_message(g, names)
320
- end
321
-
322
- if groups.any?
323
- specs = Bundler.definition.specs_for groups
324
- sources.concat(specs.map(&:name))
325
- end
326
-
327
- Bundler.definition(:gems => gems, :sources => sources)
328
- end
329
-
330
- Bundler::Fetcher.disable_endpoint = options["full-index"]
331
-
332
- opts = options.dup
333
- opts["update"] = true
334
- opts["local"] = options[:local]
335
-
336
- Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"]
337
-
338
- # rubygems plugins sometimes hook into the gem install process
339
- Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
340
-
341
- Bundler.definition.validate_ruby!
342
- Installer.install Bundler.root, Bundler.definition, opts
343
- Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
344
- clean if Bundler.settings[:clean] && Bundler.settings[:path]
345
- Bundler.ui.confirm "Your bundle is updated!"
346
- Bundler.ui.confirm without_groups_message if Bundler.settings.without.any?
167
+ require 'bundler/cli/update'
168
+ Update.new(options, gems).run
347
169
  end
348
170
 
349
171
  desc "show [GEM]", "Shows all gems that are part of the bundle, or the path to a given gem"
@@ -354,35 +176,8 @@ module Bundler
354
176
  method_option "paths", :type => :boolean,
355
177
  :banner => "List the paths of all gems that are required by your Gemfile."
356
178
  def show(gem_name = nil)
357
- Bundler.ui.silence do
358
- Bundler.definition.validate_ruby!
359
- Bundler.load.lock
360
- end
361
-
362
- if gem_name
363
- if gem_name == "bundler"
364
- path = File.expand_path("../../..", __FILE__)
365
- else
366
- spec = select_spec(gem_name, :regex_match)
367
- return unless spec
368
- path = spec.full_gem_path
369
- if !File.directory?(path)
370
- Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:"
371
- end
372
- end
373
- return Bundler.ui.info(path)
374
- end
375
-
376
- if options[:paths]
377
- Bundler.load.specs.sort_by { |s| s.name }.map do |s|
378
- Bundler.ui.info s.full_gem_path
379
- end
380
- else
381
- Bundler.ui.info "Gems included by the bundle:"
382
- Bundler.load.specs.sort_by { |s| s.name }.each do |s|
383
- Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
384
- end
385
- end
179
+ require 'bundler/cli/show'
180
+ Show.new(options, gem_name).run
386
181
  end
387
182
  map %w(list) => "show"
388
183
 
@@ -396,26 +191,8 @@ module Bundler
396
191
  method_option "force", :type => :boolean, :default => false, :banner =>
397
192
  "overwrite existing binstubs if they exist"
398
193
  def binstubs(*gems)
399
- Bundler.definition.validate_ruby!
400
- Bundler.settings[:bin] = options["path"] if options["path"]
401
- Bundler.settings[:bin] = nil if options["path"] && options["path"].empty?
402
- installer = Installer.new(Bundler.root, Bundler.definition)
403
-
404
- if gems.empty?
405
- Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
406
- exit 1
407
- end
408
-
409
- gems.each do |gem_name|
410
- spec = installer.specs.find{|s| s.name == gem_name }
411
- raise GemNotFound, not_found_message(gem_name, Bundler.definition.specs) unless spec
412
-
413
- if spec.name == "bundler"
414
- Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems."
415
- else
416
- installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
417
- end
418
- end
194
+ require 'bundler/cli/binstubs'
195
+ Binstubs.new(options, gems).run
419
196
  end
420
197
 
421
198
  desc "outdated [GEM]", "list installed gems with newer versions available"
@@ -432,89 +209,16 @@ module Bundler
432
209
  method_option "strict", :type => :boolean, :banner =>
433
210
  "Only list newer versions allowed by your Gemfile requirements"
434
211
  def outdated(*gems)
435
- sources = Array(options[:source])
436
-
437
- gems.each do |gem_name|
438
- select_spec(gem_name)
439
- end
440
-
441
- Bundler.definition.validate_ruby!
442
- current_specs = Bundler.ui.silence { Bundler.load.specs }
443
- current_dependencies = {}
444
- Bundler.ui.silence { Bundler.load.dependencies.each { |dep| current_dependencies[dep.name] = dep } }
445
-
446
- if gems.empty? && sources.empty?
447
- # We're doing a full update
448
- definition = Bundler.definition(true)
449
- else
450
- definition = Bundler.definition(:gems => gems, :sources => sources)
451
- end
452
- options["local"] ? definition.resolve_with_cache! : definition.resolve_remotely!
453
-
454
- Bundler.ui.info ""
455
-
456
- out_count = 0
457
- # Loop through the current specs
458
- gemfile_specs, dependency_specs = current_specs.partition { |spec| current_dependencies.has_key? spec.name }
459
- [gemfile_specs.sort_by(&:name), dependency_specs.sort_by(&:name)].flatten.each do |current_spec|
460
- next if !gems.empty? && !gems.include?(current_spec.name)
461
-
462
- dependency = current_dependencies[current_spec.name]
463
-
464
- active_spec = definition.index[current_spec.name].sort_by { |b| b.version }
465
- if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1
466
- active_spec = active_spec.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? }
467
- end
468
- if options["strict"]
469
- active_spec = active_spec.reverse.detect do |b|
470
- dependency && b.respond_to?(:version) && dependency.requirement.satisfied_by?(b.version)
471
- end || active_spec.last
472
- else
473
- active_spec = active_spec.last
474
- end
475
- next if active_spec.nil?
476
-
477
- gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
478
- git_outdated = current_spec.git_version != active_spec.git_version
479
- if gem_outdated || git_outdated
480
- if out_count == 0
481
- if options["pre"]
482
- Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):"
483
- else
484
- Bundler.ui.info "Outdated gems included in the bundle:"
485
- end
486
- end
487
-
488
- spec_version = "#{active_spec.version}#{active_spec.git_version}"
489
- current_version = "#{current_spec.version}#{current_spec.git_version}"
490
- dependency_version = %|Gemfile specifies "#{dependency.requirement}"| if dependency && dependency.specific?
491
- Bundler.ui.info " * #{active_spec.name} (#{spec_version} > #{current_version}) #{dependency_version}".rstrip
492
- out_count += 1
493
- end
494
- Bundler.ui.debug "from #{active_spec.loaded_from}"
495
- end
496
-
497
- if out_count.zero?
498
- Bundler.ui.info "Your bundle is up to date!\n"
499
- else
500
- exit 1
501
- end
212
+ require 'bundler/cli/outdated'
213
+ Outdated.new(options, gems).run
502
214
  end
503
215
 
504
216
  desc "cache", "Cache all the gems to vendor/cache", :hide => true
505
217
  method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
506
218
  method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
507
219
  def cache
508
- Bundler.definition.validate_ruby!
509
- Bundler.definition.resolve_with_cache!
510
- setup_cache_all
511
- Bundler.load.cache
512
- Bundler.settings[:no_prune] = true if options["no-prune"]
513
- Bundler.load.lock
514
- rescue GemNotFound => e
515
- Bundler.ui.error(e.message)
516
- Bundler.ui.warn "Run `bundle install` to install missing gems."
517
- exit 1
220
+ require 'bundler/cli/cache'
221
+ Cache.new(options).run
518
222
  end
519
223
 
520
224
  desc "package", "Locks and then caches all of the gems into vendor/cache"
@@ -531,13 +235,8 @@ module Bundler
531
235
  bundle without having to download any additional gems.
532
236
  D
533
237
  def package
534
- Bundler.ui.level = "warn" if options[:quiet]
535
- Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
536
- setup_cache_all
537
- install
538
- # TODO: move cache contents here now that all bundles are locked
539
- custom_path = Pathname.new(options[:path]) if options[:path]
540
- Bundler.load.cache(custom_path)
238
+ require 'bundler/cli/package'
239
+ Package.new(options).run
541
240
  end
542
241
  map %w(pack) => :package
543
242
 
@@ -549,29 +248,8 @@ module Bundler
549
248
  into the system wide Rubygems repository.
550
249
  D
551
250
  def exec(*args)
552
- Bundler.definition.validate_ruby!
553
- Bundler.load.setup_environment
554
-
555
- begin
556
- if RUBY_VERSION >= "2.0"
557
- args << { :close_others => !options.keep_file_descriptors? }
558
- elsif options.keep_file_descriptors?
559
- Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
560
- end
561
-
562
- # Run
563
- Kernel.exec(*args)
564
- rescue Errno::EACCES
565
- Bundler.ui.error "bundler: not executable: #{args.first}"
566
- exit 126
567
- rescue Errno::ENOENT
568
- Bundler.ui.error "bundler: command not found: #{args.first}"
569
- Bundler.ui.warn "Install missing gem executables with `bundle install`"
570
- exit 127
571
- rescue ArgumentError
572
- Bundler.ui.error "bundler: exec needs a command to run"
573
- exit 128
574
- end
251
+ require 'bundler/cli/exec'
252
+ Exec.new(options, args).run
575
253
  end
576
254
 
577
255
  desc "config NAME [VALUE]", "retrieve or set a configuration value"
@@ -587,88 +265,14 @@ module Bundler
587
265
  where they were specified.
588
266
  D
589
267
  def config(*args)
590
- peek = args.shift
591
-
592
- if peek && peek =~ /^\-\-/
593
- name, scope = args.shift, $'
594
- else
595
- name, scope = peek, "global"
596
- end
597
-
598
- unless name
599
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
600
-
601
- Bundler.settings.all.each do |setting|
602
- Bundler.ui.confirm "#{setting}"
603
- with_padding do
604
- Bundler.settings.pretty_values_for(setting).each do |line|
605
- Bundler.ui.info line
606
- end
607
- end
608
- Bundler.ui.confirm ""
609
- end
610
- return
611
- end
612
-
613
- case scope
614
- when "delete"
615
- Bundler.settings.set_local(name, nil)
616
- Bundler.settings.set_global(name, nil)
617
- when "local", "global"
618
- if args.empty?
619
- Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
620
- with_padding do
621
- Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line }
622
- end
623
- return
624
- end
625
-
626
- locations = Bundler.settings.locations(name)
627
-
628
- if scope == "global"
629
- if local = locations[:local]
630
- Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " \
631
- "global value you are currently setting"
632
- end
633
-
634
- if env = locations[:env]
635
- Bundler.ui.info "You have a bundler environment variable for #{name} set to #{env.inspect}. " \
636
- "This will take precedence over the global value you are setting"
637
- end
638
-
639
- if global = locations[:global]
640
- Bundler.ui.info "You are replacing the current global value of #{name}, which is currently #{global.inspect}"
641
- end
642
- end
643
-
644
- if scope == "local" && local = locations[:local]
645
- Bundler.ui.info "You are replacing the current local value of #{name}, which is currently #{local.inspect}"
646
- end
647
-
648
- if name.match(/\Alocal\./)
649
- pathname = Pathname.new(args.join(" "))
650
- args = [pathname.expand_path.to_s] if pathname.directory?
651
- end
652
-
653
- Bundler.settings.send("set_#{scope}", name, args.join(" "))
654
- else
655
- Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
656
- exit 1
657
- end
268
+ require 'bundler/cli/config'
269
+ Config.new(options, args, self).run
658
270
  end
659
271
 
660
272
  desc "open GEM", "Opens the source directory of the given bundled gem"
661
273
  def open(name)
662
- editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
663
- return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor
664
- spec = select_spec(name, :regex_match)
665
- return unless spec
666
- full_gem_path = spec.full_gem_path
667
- Dir.chdir(full_gem_path) do
668
- command = "#{editor} #{full_gem_path}"
669
- success = system(command)
670
- Bundler.ui.info "Could not run '#{command}'" unless success
671
- end
274
+ require 'bundler/cli/open'
275
+ Open.new(options, name).run
672
276
  end
673
277
 
674
278
  CONSOLES = {
@@ -679,34 +283,8 @@ module Bundler
679
283
 
680
284
  desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
681
285
  def console(group = nil)
682
- group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
683
- ARGV.clear
684
-
685
- preferred = Bundler.settings[:console] || 'irb'
686
-
687
- # See if console is available
688
- begin
689
- require preferred || true
690
- rescue LoadError
691
- # Is it in Gemfile?
692
- Bundler.ui.error "Could not load the #{preferred} console"
693
- Bundler.ui.info "Falling back on IRB..."
694
-
695
- require 'irb'
696
- preferred = 'irb'
697
- end
698
-
699
- constant = CONSOLES[preferred]
700
-
701
- console = begin
702
- Object.const_get(constant)
703
- rescue NameError => e
704
- Bundler.ui.error e.inspect
705
- Bundler.ui.error "Could not load the #{constant} console"
706
- return
707
- end
708
-
709
- console.start
286
+ require 'bundler/cli/console'
287
+ Console.new(options, group, CONSOLES).run
710
288
  end
711
289
 
712
290
  desc "version", "Prints the bundler's version information"
@@ -740,21 +318,8 @@ module Bundler
740
318
  method_option :requirements, :type => :boolean, :default => false, :aliases => '-r', :banner => "Set to show the version of each required dependency."
741
319
  method_option :format, :type => :string, :default => "png", :aliases => '-F', :banner => "This is output format option. Supported format is png, jpg, svg, dot ..."
742
320
  def viz
743
- require 'graphviz'
744
- output_file = File.expand_path(options[:file])
745
- graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format])
746
- graph.viz
747
- rescue LoadError => e
748
- Bundler.ui.error e.inspect
749
- Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
750
- Bundler.ui.warn "`gem install ruby-graphviz`"
751
- rescue StandardError => e
752
- if e.message =~ /GraphViz not installed or dot not in PATH/
753
- Bundler.ui.error e.message
754
- Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`."
755
- else
756
- raise
757
- end
321
+ require 'bundler/cli/viz'
322
+ Viz.new(options).run
758
323
  end
759
324
 
760
325
  desc "gem GEM", "Creates a skeleton for creating a rubygem"
@@ -766,53 +331,8 @@ module Bundler
766
331
  :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
767
332
 
768
333
  def gem(name)
769
- name = name.chomp("/") # remove trailing slash if present
770
- namespaced_path = name.tr('-', '/')
771
- target = File.join(Dir.pwd, name)
772
- constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
773
- constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
774
- constant_array = constant_name.split('::')
775
- git_user_name = `git config user.name`.chomp
776
- git_user_email = `git config user.email`.chomp
777
- opts = {
778
- :name => name,
779
- :namespaced_path => namespaced_path,
780
- :constant_name => constant_name,
781
- :constant_array => constant_array,
782
- :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
783
- :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
784
- :test => options[:test]
785
- }
786
- gemspec_dest = File.join(target, "#{name}.gemspec")
787
- template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
788
- template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
789
- template(File.join("newgem/LICENSE.txt.tt"), File.join(target, "LICENSE.txt"), opts)
790
- template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), opts)
791
- template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts)
792
- template(File.join("newgem/newgem.gemspec.tt"), gemspec_dest, opts)
793
- template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{namespaced_path}.rb"), opts)
794
- template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{namespaced_path}/version.rb"), opts)
795
- if options[:bin]
796
- template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts)
797
- end
798
- case options[:test]
799
- when 'rspec'
800
- template(File.join("newgem/rspec.tt"), File.join(target, ".rspec"), opts)
801
- template(File.join("newgem/spec/spec_helper.rb.tt"), File.join(target, "spec/spec_helper.rb"), opts)
802
- template(File.join("newgem/spec/newgem_spec.rb.tt"), File.join(target, "spec/#{namespaced_path}_spec.rb"), opts)
803
- when 'minitest'
804
- template(File.join("newgem/test/minitest_helper.rb.tt"), File.join(target, "test/minitest_helper.rb"), opts)
805
- template(File.join("newgem/test/test_newgem.rb.tt"), File.join(target, "test/test_#{namespaced_path}.rb"), opts)
806
- end
807
- if options[:test]
808
- template(File.join("newgem/.travis.yml.tt"), File.join(target, ".travis.yml"), opts)
809
- end
810
- Bundler.ui.info "Initializing git repo in #{target}"
811
- Dir.chdir(target) { `git init`; `git add .` }
812
-
813
- if options[:edit]
814
- run("#{options["edit"]} \"#{gemspec_dest}\"") # Open gemspec in editor
815
- end
334
+ require 'bundler/cli/gem'
335
+ Gem.new(options, name, self).run
816
336
  end
817
337
 
818
338
  def self.source_root
@@ -825,71 +345,22 @@ module Bundler
825
345
  method_option "force", :type => :boolean, :default => false, :banner =>
826
346
  "forces clean even if --path is not set"
827
347
  def clean
828
- if Bundler.settings[:path] || options[:force]
829
- Bundler.load.clean(options[:"dry-run"])
830
- else
831
- Bundler.ui.error "Can only use bundle clean when --path is set or --force is set"
832
- exit 1
833
- end
348
+ require 'bundler/cli/clean'
349
+ Clean.new(options.dup).run
834
350
  end
835
351
 
836
352
  desc "platform", "Displays platform compatibility information"
837
353
  method_option "ruby", :type => :boolean, :default => false, :banner =>
838
354
  "only display ruby related platform information"
839
355
  def platform
840
- platforms, ruby_version = Bundler.ui.silence do
841
- [ Bundler.definition.platforms.map {|p| "* #{p}" },
842
- Bundler.definition.ruby_version ]
843
- end
844
- output = []
845
-
846
- if options[:ruby]
847
- if ruby_version
848
- output << ruby_version
849
- else
850
- output << "No ruby version specified"
851
- end
852
- else
853
- output << "Your platform is: #{RUBY_PLATFORM}"
854
- output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
855
-
856
- if ruby_version
857
- output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
858
-
859
- begin
860
- Bundler.definition.validate_ruby!
861
- output << "Your current platform satisfies the Ruby version requirement."
862
- rescue RubyVersionMismatch => e
863
- output << e.message
864
- end
865
- else
866
- output << "Your Gemfile does not specify a Ruby version requirement."
867
- end
868
- end
869
-
870
- Bundler.ui.info output.join("\n\n")
356
+ require 'bundler/cli/platform'
357
+ Platform.new(options).run
871
358
  end
872
359
 
873
360
  desc "inject GEM VERSION ...", "Add the named gem(s), with version requirements, to the resolved Gemfile"
874
361
  def inject(name, version, *gems)
875
- # The required arguments allow Thor to give useful feedback when the arguments
876
- # are incorrect. This adds those first two arguments onto the list as a whole.
877
- gems.unshift(version).unshift(name)
878
-
879
- # Build an array of Dependency objects out of the arguments
880
- deps = []
881
- gems.each_slice(2) do |gem_name, gem_version|
882
- deps << Bundler::Dependency.new(gem_name, gem_version)
883
- end
884
-
885
- added = Injector.inject(deps)
886
-
887
- if added.any?
888
- Bundler.ui.confirm "Added to Gemfile:"
889
- Bundler.ui.confirm added.map{ |g| " #{g}" }.join("\n")
890
- else
891
- Bundler.ui.confirm "All injected gems were already present in the Gemfile"
892
- end
362
+ require 'bundler/cli/inject'
363
+ Inject.new(options, name, version, gems).run
893
364
  end
894
365
 
895
366
  desc "env", "Print information about the environment Bundler is running under"
@@ -897,59 +368,5 @@ module Bundler
897
368
  Env.new.write($stdout)
898
369
  end
899
370
 
900
- private
901
-
902
- def setup_cache_all
903
- Bundler.settings[:cache_all] = options[:all] if options.key?("all")
904
-
905
- if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all]
906
- Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
907
- "to package them as well, please pass the --all flag. This will be the default " \
908
- "on Bundler 2.0."
909
- end
910
- end
911
-
912
- def select_spec(name, regex_match = nil)
913
- specs = []
914
- regexp = Regexp.new(name) if regex_match
915
-
916
- Bundler.definition.specs.each do |spec|
917
- return spec if spec.name == name
918
- specs << spec if regexp && spec.name =~ regexp
919
- end
920
-
921
- case specs.count
922
- when 0
923
- raise GemNotFound, not_found_message(name, Bundler.definition.dependencies)
924
- when 1
925
- specs.first
926
- else
927
- specs.each_with_index do |spec, index|
928
- Bundler.ui.info "#{index.succ} : #{spec.name}", true
929
- end
930
- Bundler.ui.info '0 : - exit -', true
931
-
932
- input = Bundler.ui.ask('> ')
933
- (num = input.to_i) > 0 ? specs[num - 1] : nil
934
- end
935
- end
936
-
937
- def not_found_message(missing_gem_name, alternatives)
938
- require 'bundler/similarity_detector'
939
- message = "Could not find gem '#{missing_gem_name}'."
940
- alternate_names = alternatives.map { |a| a.respond_to?(:name) ? a.name : a }
941
- suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
942
- message += "\nDid you mean #{suggestions}?" if suggestions
943
- message
944
- end
945
-
946
- def without_groups_message
947
- groups = Bundler.settings.without
948
- group_list = [groups[0...-1].join(", "), groups[-1..-1]].
949
- reject{|s| s.to_s.empty? }.join(" and ")
950
- group_str = (groups.size == 1) ? "group" : "groups"
951
- "Gems in the #{group_str} #{group_list} were not installed."
952
- end
953
-
954
371
  end
955
372
  end