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
@@ -0,0 +1,33 @@
1
+ module Bundler
2
+ class CLI::Inject
3
+ attr_reader :options, :name, :version, :gems
4
+ def initialize(options, name, version, gems)
5
+ @options = options
6
+ @name = name
7
+ @version = version
8
+ @gems = gems
9
+ end
10
+
11
+ def run
12
+ # The required arguments allow Thor to give useful feedback when the arguments
13
+ # are incorrect. This adds those first two arguments onto the list as a whole.
14
+ gems.unshift(version).unshift(name)
15
+
16
+ # Build an array of Dependency objects out of the arguments
17
+ deps = []
18
+ gems.each_slice(2) do |gem_name, gem_version|
19
+ deps << Bundler::Dependency.new(gem_name, gem_version)
20
+ end
21
+
22
+ added = Injector.inject(deps)
23
+
24
+ if added.any?
25
+ Bundler.ui.confirm "Added to Gemfile:"
26
+ Bundler.ui.confirm added.map{ |g| " #{g}" }.join("\n")
27
+ else
28
+ Bundler.ui.confirm "All injected gems were already present in the Gemfile"
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,123 @@
1
+ module Bundler
2
+ class CLI::Install
3
+ attr_reader :options
4
+ def initialize(options)
5
+ @options = options.dup
6
+ end
7
+
8
+ def run
9
+ if options[:without]
10
+ options[:without] = options[:without].map{|g| g.tr(' ', ':') }
11
+ end
12
+
13
+ ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
14
+
15
+ # Just disable color in deployment mode
16
+ Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
17
+
18
+ if (options[:path] || options[:deployment]) && options[:system]
19
+ Bundler.ui.error "You have specified both a path to install your gems to, \n" \
20
+ "as well as --system. Please choose."
21
+ exit 1
22
+ end
23
+
24
+ if (options["trust-policy"])
25
+ unless (Bundler.rubygems.security_policies.keys.include?(options["trust-policy"]))
26
+ Bundler.ui.error "Rubygems doesn't know about trust policy '#{options["trust-policy"]}'. " \
27
+ "The known policies are: #{Bundler.rubygems.security_policies.keys.join(', ')}."
28
+ exit 1
29
+ end
30
+ Bundler.settings["trust-policy"] = options["trust-policy"]
31
+ else
32
+ Bundler.settings["trust-policy"] = nil if Bundler.settings["trust-policy"]
33
+ end
34
+
35
+ if options[:deployment] || options[:frozen]
36
+ unless Bundler.default_lockfile.exist?
37
+ flag = options[:deployment] ? '--deployment' : '--frozen'
38
+ raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " \
39
+ "sure you have checked your Gemfile.lock into version control " \
40
+ "before deploying."
41
+ end
42
+
43
+ if Bundler.root.join("vendor/cache").exist?
44
+ options[:local] = true
45
+ end
46
+
47
+ Bundler.settings[:frozen] = '1'
48
+ end
49
+
50
+ # When install is called with --no-deployment, disable deployment mode
51
+ if options[:deployment] == false
52
+ Bundler.settings.delete(:frozen)
53
+ options[:system] = true
54
+ end
55
+
56
+ Bundler.settings[:path] = nil if options[:system]
57
+ Bundler.settings[:path] = "vendor/bundle" if options[:deployment]
58
+ Bundler.settings[:path] = options["path"] if options["path"]
59
+ Bundler.settings[:path] ||= "bundle" if options["standalone"]
60
+ Bundler.settings[:bin] = options["binstubs"] if options["binstubs"]
61
+ Bundler.settings[:bin] = nil if options["binstubs"] && options["binstubs"].empty?
62
+ Bundler.settings[:shebang] = options["shebang"] if options["shebang"]
63
+ Bundler.settings[:jobs] = options["jobs"] if options["jobs"]
64
+ Bundler.settings[:no_prune] = true if options["no-prune"]
65
+ Bundler.settings[:clean] = options["clean"] if options["clean"]
66
+ Bundler.settings.without = options[:without]
67
+ Bundler.ui.level = "warn" if options[:quiet]
68
+ Bundler::Fetcher.disable_endpoint = options["full-index"]
69
+ Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil
70
+
71
+ # rubygems plugins sometimes hook into the gem install process
72
+ Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
73
+
74
+ definition = Bundler.definition
75
+ definition.validate_ruby!
76
+ Installer.install(Bundler.root, definition, options)
77
+ Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
78
+
79
+ if Bundler.settings[:path]
80
+ absolute_path = File.expand_path(Bundler.settings[:path])
81
+ relative_path = absolute_path.sub(File.expand_path('.'), '.')
82
+ Bundler.ui.confirm "Your bundle is complete!"
83
+ without_groups_messages
84
+ Bundler.ui.confirm "It was installed into #{relative_path}"
85
+ else
86
+ Bundler.ui.confirm "Your bundle is complete!"
87
+ without_groups_messages
88
+ Bundler.ui.confirm "Use `bundle show [gemname]` to see where a bundled gem is installed."
89
+ end
90
+ Installer.post_install_messages.to_a.each do |name, msg|
91
+ Bundler.ui.confirm "Post-install message from #{name}:"
92
+ Bundler.ui.info msg
93
+ end
94
+
95
+ if Bundler.settings[:clean] && Bundler.settings[:path]
96
+ require "bundler/cli/clean"
97
+ Bundler::CLI::Clean.new(options).run
98
+ end
99
+ rescue GemNotFound, VersionConflict => e
100
+ if options[:local] && Bundler.app_cache.exist?
101
+ Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
102
+ end
103
+
104
+ if Bundler.definition.rubygems_remotes.empty?
105
+ Bundler.ui.warn <<-WARN, :wrap => true
106
+ Your Gemfile has no gem server sources. If you need gems that are \
107
+ not already on your machine, add a line like this to your Gemfile:
108
+ source 'https://rubygems.org'
109
+ WARN
110
+ end
111
+ raise e
112
+ end
113
+
114
+ private
115
+
116
+ def without_groups_messages
117
+ if Bundler.settings.without.any?
118
+ require "bundler/cli/common"
119
+ Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,25 @@
1
+ require 'bundler/cli/common'
2
+
3
+ module Bundler
4
+ class CLI::Open
5
+ attr_reader :options, :name
6
+ def initialize(options, name)
7
+ @options = options
8
+ @name = name
9
+ end
10
+
11
+ def run
12
+ editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
13
+ return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor
14
+ spec = Bundler::CLI::Common.select_spec(name, :regex_match)
15
+ return unless spec
16
+ full_gem_path = spec.full_gem_path
17
+ Dir.chdir(full_gem_path) do
18
+ command = "#{editor} #{full_gem_path}"
19
+ success = system(command)
20
+ Bundler.ui.info "Could not run '#{command}'" unless success
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,80 @@
1
+ require 'bundler/cli/common'
2
+
3
+ module Bundler
4
+ class CLI::Outdated
5
+ attr_reader :options, :gems
6
+ def initialize(options, gems)
7
+ @options = options
8
+ @gems = gems
9
+ end
10
+
11
+ def run
12
+ sources = Array(options[:source])
13
+
14
+ gems.each do |gem_name|
15
+ Bundler::CLI::Common.select_spec(gem_name)
16
+ end
17
+
18
+ Bundler.definition.validate_ruby!
19
+ current_specs = Bundler.ui.silence { Bundler.load.specs }
20
+ current_dependencies = {}
21
+ Bundler.ui.silence { Bundler.load.dependencies.each { |dep| current_dependencies[dep.name] = dep } }
22
+
23
+ if gems.empty? && sources.empty?
24
+ # We're doing a full update
25
+ definition = Bundler.definition(true)
26
+ else
27
+ definition = Bundler.definition(:gems => gems, :sources => sources)
28
+ end
29
+ options["local"] ? definition.resolve_with_cache! : definition.resolve_remotely!
30
+
31
+ Bundler.ui.info ""
32
+
33
+ out_count = 0
34
+ # Loop through the current specs
35
+ gemfile_specs, dependency_specs = current_specs.partition { |spec| current_dependencies.has_key? spec.name }
36
+ [gemfile_specs.sort_by(&:name), dependency_specs.sort_by(&:name)].flatten.each do |current_spec|
37
+ next if !gems.empty? && !gems.include?(current_spec.name)
38
+
39
+ dependency = current_dependencies[current_spec.name]
40
+
41
+ if options["strict"]
42
+ active_spec = definition.specs.detect { |spec| spec.name == current_spec.name }
43
+ else
44
+ active_spec = definition.index[current_spec.name].sort_by { |b| b.version }
45
+ if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1
46
+ active_spec = active_spec.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? }
47
+ end
48
+ active_spec = active_spec.last
49
+ end
50
+ next if active_spec.nil?
51
+
52
+ gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
53
+ git_outdated = current_spec.git_version != active_spec.git_version
54
+ if gem_outdated || git_outdated
55
+ if out_count == 0
56
+ if options["pre"]
57
+ Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):"
58
+ else
59
+ Bundler.ui.info "Outdated gems included in the bundle:"
60
+ end
61
+ end
62
+
63
+ spec_version = "#{active_spec.version}#{active_spec.git_version}"
64
+ current_version = "#{current_spec.version}#{current_spec.git_version}"
65
+ dependency_version = %|Gemfile specifies "#{dependency.requirement}"| if dependency && dependency.specific?
66
+ Bundler.ui.info " * #{active_spec.name} (#{spec_version} > #{current_version}) #{dependency_version}".rstrip
67
+ out_count += 1
68
+ end
69
+ Bundler.ui.debug "from #{active_spec.loaded_from}"
70
+ end
71
+
72
+ if out_count.zero?
73
+ Bundler.ui.info "Your bundle is up to date!\n"
74
+ else
75
+ exit 1
76
+ end
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,36 @@
1
+ module Bundler
2
+ class CLI::Package
3
+ attr_reader :options
4
+
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def run
10
+ Bundler.ui.level = "warn" if options[:quiet]
11
+ Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
12
+ setup_cache_all
13
+ install
14
+ # TODO: move cache contents here now that all bundles are locked
15
+ custom_path = Pathname.new(options[:path]) if options[:path]
16
+ Bundler.load.cache(custom_path)
17
+ end
18
+
19
+ private
20
+
21
+ def install
22
+ require 'bundler/cli/install'
23
+ Bundler::CLI::Install.new(options.dup).run
24
+ end
25
+
26
+ def setup_cache_all
27
+ Bundler.settings[:cache_all] = options[:all] if options.key?("all")
28
+
29
+ if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all]
30
+ Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
31
+ "to package them as well, please pass the --all flag. This will be the default " \
32
+ "on Bundler 2.0."
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,43 @@
1
+ module Bundler
2
+ class CLI::Platform
3
+ attr_reader :options
4
+ def initialize(options)
5
+ @options = options
6
+ end
7
+
8
+ def run
9
+ platforms, ruby_version = Bundler.ui.silence do
10
+ [ Bundler.definition.platforms.map {|p| "* #{p}" },
11
+ Bundler.definition.ruby_version ]
12
+ end
13
+ output = []
14
+
15
+ if options[:ruby]
16
+ if ruby_version
17
+ output << ruby_version
18
+ else
19
+ output << "No ruby version specified"
20
+ end
21
+ else
22
+ output << "Your platform is: #{RUBY_PLATFORM}"
23
+ output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
24
+
25
+ if ruby_version
26
+ output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
27
+
28
+ begin
29
+ Bundler.definition.validate_ruby!
30
+ output << "Your current platform satisfies the Ruby version requirement."
31
+ rescue RubyVersionMismatch => e
32
+ output << e.message
33
+ end
34
+ else
35
+ output << "Your Gemfile does not specify a Ruby version requirement."
36
+ end
37
+ end
38
+
39
+ Bundler.ui.info output.join("\n\n")
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+ require 'bundler/cli/common'
2
+
3
+ module Bundler
4
+ class CLI::Show
5
+ attr_reader :options, :gem_name
6
+ def initialize(options, gem_name)
7
+ @options = options
8
+ @gem_name = gem_name
9
+ end
10
+
11
+ def run
12
+ Bundler.ui.silence do
13
+ Bundler.definition.validate_ruby!
14
+ Bundler.load.lock
15
+ end
16
+
17
+ if gem_name
18
+ if gem_name == "bundler"
19
+ path = File.expand_path("../../../..", __FILE__)
20
+ else
21
+ spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
22
+ return unless spec
23
+ path = spec.full_gem_path
24
+ if !File.directory?(path)
25
+ Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:"
26
+ end
27
+ end
28
+ return Bundler.ui.info(path)
29
+ end
30
+
31
+ if options[:paths]
32
+ Bundler.load.specs.sort_by { |s| s.name }.map do |s|
33
+ Bundler.ui.info s.full_gem_path
34
+ end
35
+ else
36
+ Bundler.ui.info "Gems included by the bundle:"
37
+ Bundler.load.specs.sort_by { |s| s.name }.each do |s|
38
+ Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,73 @@
1
+ module Bundler
2
+ class CLI::Update
3
+ attr_reader :options, :gems
4
+ def initialize(options, gems)
5
+ @options = options
6
+ @gems = gems
7
+ end
8
+
9
+ def run
10
+
11
+ sources = Array(options[:source])
12
+ groups = Array(options[:group]).map(&:to_sym)
13
+ Bundler.ui.level = "warn" if options[:quiet]
14
+
15
+ if gems.empty? && sources.empty? && groups.empty?
16
+ # We're doing a full update
17
+ Bundler.definition(true)
18
+ else
19
+ unless Bundler.default_lockfile.exist?
20
+ raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
21
+ "Run `bundle install` to update and install the bundled gems."
22
+ end
23
+ # cycle through the requested gems, just to make sure they exist
24
+ names = Bundler.locked_gems.specs.map{ |s| s.name }
25
+ gems.each do |g|
26
+ next if names.include?(g)
27
+ require "bundler/cli/common"
28
+ raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(g, names)
29
+ end
30
+
31
+ if groups.any?
32
+ specs = Bundler.definition.specs_for groups
33
+ sources.concat(specs.map(&:name))
34
+ end
35
+
36
+ Bundler.definition(:gems => gems, :sources => sources)
37
+ end
38
+
39
+ Bundler::Fetcher.disable_endpoint = options["full-index"]
40
+
41
+ opts = options.dup
42
+ opts["update"] = true
43
+ opts["local"] = options[:local]
44
+
45
+ Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"]
46
+
47
+ # rubygems plugins sometimes hook into the gem install process
48
+ Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
49
+
50
+ Bundler.definition.validate_ruby!
51
+ Installer.install Bundler.root, Bundler.definition, opts
52
+ Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
53
+
54
+ if Bundler.settings[:clean] && Bundler.settings[:path]
55
+ require "bundler/cli/clean"
56
+ Bundler::CLI::Clean.new(options).run
57
+ end
58
+
59
+ Bundler.ui.confirm "Your bundle is updated!"
60
+ without_groups_messages
61
+ end
62
+
63
+ private
64
+
65
+ def without_groups_messages
66
+ if Bundler.settings.without.any?
67
+ require "bundler/cli/common"
68
+ Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
69
+ end
70
+ end
71
+
72
+ end
73
+ end