bundler 2.0.0.pre.3 → 2.1.0.pre.1

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 (217) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +721 -572
  3. data/LICENSE.md +18 -19
  4. data/README.md +9 -8
  5. data/bundler.gemspec +8 -25
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +121 -68
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +133 -125
  11. data/lib/bundler/cli/add.rb +27 -16
  12. data/lib/bundler/cli/common.rb +11 -12
  13. data/lib/bundler/cli/config.rb +161 -86
  14. data/lib/bundler/cli/console.rb +2 -2
  15. data/lib/bundler/cli/doctor.rb +4 -4
  16. data/lib/bundler/cli/exec.rb +4 -9
  17. data/lib/bundler/cli/gem.rb +5 -5
  18. data/lib/bundler/cli/info.rb +17 -5
  19. data/lib/bundler/cli/init.rb +1 -1
  20. data/lib/bundler/cli/install.rb +12 -11
  21. data/lib/bundler/cli/issue.rb +3 -3
  22. data/lib/bundler/cli/open.rb +10 -6
  23. data/lib/bundler/cli/outdated.rb +85 -81
  24. data/lib/bundler/cli/package.rb +8 -9
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +32 -12
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +8 -7
  32. data/lib/bundler/definition.rb +36 -27
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +2 -2
  35. data/lib/bundler/dsl.rb +18 -42
  36. data/lib/bundler/env.rb +8 -13
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +1 -13
  39. data/lib/bundler/fetcher.rb +14 -11
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +4 -1
  43. data/lib/bundler/fetcher/index.rb +4 -2
  44. data/lib/bundler/friendly_errors.rb +4 -5
  45. data/lib/bundler/gem_helper.rb +39 -24
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +10 -8
  51. data/lib/bundler/inline.rb +19 -18
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -8
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -2
  57. data/lib/bundler/lockfile_parser.rb +13 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/plugin.rb +42 -29
  60. data/lib/bundler/plugin/api.rb +1 -1
  61. data/lib/bundler/plugin/api/source.rb +2 -2
  62. data/lib/bundler/plugin/index.rb +14 -3
  63. data/lib/bundler/plugin/installer.rb +28 -15
  64. data/lib/bundler/psyched_yaml.rb +1 -1
  65. data/lib/bundler/resolver.rb +72 -24
  66. data/lib/bundler/resolver/spec_group.rb +2 -2
  67. data/lib/bundler/retry.rb +2 -2
  68. data/lib/bundler/ruby_version.rb +4 -19
  69. data/lib/bundler/rubygems_ext.rb +10 -66
  70. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  71. data/lib/bundler/rubygems_integration.rb +144 -395
  72. data/lib/bundler/runtime.rb +2 -9
  73. data/lib/bundler/settings.rb +15 -48
  74. data/lib/bundler/setup.rb +6 -5
  75. data/lib/bundler/shared_helpers.rb +58 -71
  76. data/lib/bundler/similarity_detector.rb +2 -2
  77. data/lib/bundler/source.rb +5 -5
  78. data/lib/bundler/source/git.rb +19 -12
  79. data/lib/bundler/source/git/git_proxy.rb +35 -39
  80. data/lib/bundler/source/metadata.rb +7 -2
  81. data/lib/bundler/source/path.rb +13 -8
  82. data/lib/bundler/source/rubygems.rb +11 -5
  83. data/lib/bundler/source/rubygems/remote.rb +1 -2
  84. data/lib/bundler/source_list.rb +9 -12
  85. data/lib/bundler/spec_set.rb +1 -6
  86. data/lib/bundler/stub_specification.rb +18 -30
  87. data/lib/bundler/templates/Executable.bundler +23 -14
  88. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  89. data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
  90. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  91. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -27
  92. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
  93. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  94. data/lib/bundler/ui.rb +3 -3
  95. data/lib/bundler/ui/rg_proxy.rb +1 -1
  96. data/lib/bundler/ui/shell.rb +4 -8
  97. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  98. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  99. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  101. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +151 -48
  102. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
  103. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  104. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  105. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  116. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +248 -279
  117. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  120. data/lib/bundler/vendor/thor/lib/thor.rb +1 -1
  121. data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -11
  122. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  123. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  124. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +11 -2
  126. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -1
  127. data/lib/bundler/vendor/thor/lib/thor/base.rb +16 -17
  128. data/lib/bundler/vendor/thor/lib/thor/error.rb +82 -0
  129. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  130. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  131. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  132. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +7 -2
  133. data/lib/bundler/vendor/thor/lib/thor/runner.rb +6 -6
  134. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  135. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +52 -7
  136. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  137. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  138. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  139. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  140. data/lib/bundler/vendored_fileutils.rb +1 -6
  141. data/lib/bundler/vendored_molinillo.rb +1 -1
  142. data/lib/bundler/vendored_persistent.rb +7 -5
  143. data/lib/bundler/vendored_thor.rb +2 -2
  144. data/lib/bundler/version.rb +1 -20
  145. data/lib/bundler/version_ranges.rb +51 -5
  146. data/lib/bundler/vlad.rb +3 -3
  147. data/lib/bundler/worker.rb +1 -3
  148. data/lib/bundler/yaml_serializer.rb +2 -3
  149. data/man/bundle-add.1 +10 -2
  150. data/man/bundle-add.1.txt +11 -5
  151. data/man/bundle-add.ronn +7 -1
  152. data/man/bundle-binstubs.1 +2 -2
  153. data/man/bundle-binstubs.1.txt +2 -2
  154. data/man/bundle-binstubs.ronn +1 -1
  155. data/man/bundle-check.1 +1 -1
  156. data/man/bundle-check.1.txt +6 -6
  157. data/man/bundle-clean.1 +1 -1
  158. data/man/bundle-clean.1.txt +1 -1
  159. data/man/bundle-config.1 +36 -36
  160. data/man/bundle-config.1.txt +66 -67
  161. data/man/bundle-config.ronn +42 -40
  162. data/man/bundle-doctor.1 +1 -1
  163. data/man/bundle-doctor.1.txt +1 -1
  164. data/man/bundle-exec.1 +1 -1
  165. data/man/bundle-exec.1.txt +1 -1
  166. data/man/bundle-gem.1 +1 -1
  167. data/man/bundle-gem.1.txt +3 -3
  168. data/man/bundle-info.1 +1 -1
  169. data/man/bundle-info.1.txt +1 -1
  170. data/man/bundle-init.1 +2 -2
  171. data/man/bundle-init.1.txt +2 -2
  172. data/man/bundle-init.ronn +1 -1
  173. data/man/bundle-inject.1 +1 -1
  174. data/man/bundle-inject.1.txt +1 -1
  175. data/man/bundle-install.1 +8 -5
  176. data/man/bundle-install.1.txt +56 -51
  177. data/man/bundle-install.ronn +9 -4
  178. data/man/bundle-list.1 +1 -1
  179. data/man/bundle-list.1.txt +1 -1
  180. data/man/bundle-lock.1 +1 -1
  181. data/man/bundle-lock.1.txt +16 -16
  182. data/man/bundle-open.1 +1 -1
  183. data/man/bundle-open.1.txt +1 -1
  184. data/man/bundle-outdated.1 +1 -1
  185. data/man/bundle-outdated.1.txt +1 -1
  186. data/man/bundle-package.1 +1 -1
  187. data/man/bundle-package.1.txt +1 -1
  188. data/man/bundle-platform.1 +1 -1
  189. data/man/bundle-platform.1.txt +1 -1
  190. data/man/bundle-pristine.1 +1 -1
  191. data/man/bundle-pristine.1.txt +1 -1
  192. data/man/bundle-remove.1 +1 -1
  193. data/man/bundle-remove.1.txt +1 -1
  194. data/man/bundle-show.1 +1 -1
  195. data/man/bundle-show.1.txt +1 -1
  196. data/man/bundle-update.1 +4 -4
  197. data/man/bundle-update.1.txt +64 -65
  198. data/man/bundle-update.ronn +3 -3
  199. data/man/bundle-viz.1 +1 -1
  200. data/man/bundle-viz.1.txt +1 -1
  201. data/man/bundle.1 +3 -3
  202. data/man/bundle.1.txt +8 -8
  203. data/man/bundle.ronn +2 -2
  204. data/man/gemfile.5 +13 -16
  205. data/man/gemfile.5.ronn +10 -14
  206. data/man/gemfile.5.txt +104 -108
  207. metadata +16 -102
  208. data/exe/bundle_ruby +0 -60
  209. data/lib/bundler/cli/cache.rb +0 -36
  210. data/lib/bundler/compatibility_guard.rb +0 -14
  211. data/lib/bundler/ssl_certs/.document +0 -1
  212. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  213. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  214. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  215. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  216. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  217. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
@@ -2,34 +2,45 @@
2
2
 
3
3
  module Bundler
4
4
  class CLI::Add
5
+ attr_reader :gems, :options, :version
6
+
5
7
  def initialize(options, gems)
6
8
  @gems = gems
7
9
  @options = options
8
- @options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
10
+ @options[:group] = options[:group].split(",").map(&:strip) unless options[:group].nil?
11
+ @version = options[:version].split(",").map(&:strip) unless options[:version].nil?
9
12
  end
10
13
 
11
14
  def run
12
- raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if @options[:strict] && @options[:optimistic]
13
-
14
- # raise error when no gems are specified
15
- raise InvalidOption, "Please specify gems to add." if @gems.empty?
15
+ validate_options!
16
+ inject_dependencies
17
+ perform_bundle_install unless options["skip-install"]
18
+ end
16
19
 
17
- version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)
20
+ private
18
21
 
19
- unless version.nil?
20
- version.each do |v|
21
- raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
22
- end
23
- end
22
+ def perform_bundle_install
23
+ Installer.install(Bundler.root, Bundler.definition)
24
+ end
24
25
 
25
- dependencies = @gems.map {|g| Bundler::Dependency.new(g, version, @options) }
26
+ def inject_dependencies
27
+ dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
26
28
 
27
29
  Injector.inject(dependencies,
28
- :conservative_versioning => @options[:version].nil?, # Perform conservative versioning only when version is not specified
29
- :optimistic => @options[:optimistic],
30
- :strict => @options[:strict])
30
+ :conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
31
+ :optimistic => options[:optimistic],
32
+ :strict => options[:strict])
33
+ end
34
+
35
+ def validate_options!
36
+ raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
31
37
 
32
- Installer.install(Bundler.root, Bundler.definition) unless @options["skip-install"]
38
+ # raise error when no gems are specified
39
+ raise InvalidOption, "Please specify gems to add." if gems.empty?
40
+
41
+ version.to_a.each do |v|
42
+ raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
43
+ end
33
44
  end
34
45
  end
35
46
  end
@@ -14,17 +14,18 @@ module Bundler
14
14
  Bundler.ui.info msg
15
15
  end
16
16
 
17
- def self.output_without_groups_message
17
+ def self.output_without_groups_message(command)
18
18
  return if Bundler.settings[:without].empty?
19
- Bundler.ui.confirm without_groups_message
19
+ Bundler.ui.confirm without_groups_message(command)
20
20
  end
21
21
 
22
- def self.without_groups_message
22
+ def self.without_groups_message(command)
23
+ command_in_past_tense = command == :install ? "installed" : "updated"
23
24
  groups = Bundler.settings[:without]
24
25
  group_list = [groups[0...-1].join(", "), groups[-1..-1]].
25
26
  reject {|s| s.to_s.empty? }.join(" and ")
26
- group_str = (groups.size == 1) ? "group" : "groups"
27
- "Gems in the #{group_str} #{group_list} were not installed."
27
+ group_str = groups.size == 1 ? "group" : "groups"
28
+ "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
28
29
  end
29
30
 
30
31
  def self.select_spec(name, regex_match = nil)
@@ -49,10 +50,6 @@ module Bundler
49
50
  end
50
51
 
51
52
  def self.ask_for_spec_from(specs)
52
- if !$stdout.tty? && ENV["BUNDLE_SPEC_RUN"].nil?
53
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
54
- end
55
-
56
53
  specs.each_with_index do |spec, index|
57
54
  Bundler.ui.info "#{index.succ} : #{spec.name}", true
58
55
  end
@@ -63,7 +60,7 @@ module Bundler
63
60
  end
64
61
 
65
62
  def self.gem_not_found_message(missing_gem_name, alternatives)
66
- require "bundler/similarity_detector"
63
+ require_relative "../similarity_detector"
67
64
  message = "Could not find gem '#{missing_gem_name}'."
68
65
  alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
69
66
  suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
@@ -72,7 +69,7 @@ module Bundler
72
69
  end
73
70
 
74
71
  def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
75
- locked_names = locked_gems.specs.map(&:name)
72
+ locked_names = locked_gems.specs.map(&:name).uniq
76
73
  names.-(locked_names).each do |g|
77
74
  raise GemNotFound, gem_not_found_message(g, locked_names)
78
75
  end
@@ -80,10 +77,12 @@ module Bundler
80
77
 
81
78
  def self.configure_gem_version_promoter(definition, options)
82
79
  patch_level = patch_level_options(options)
80
+ patch_level << :patch if patch_level.empty? && Bundler.settings[:prefer_patch]
83
81
  raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1
82
+
84
83
  definition.gem_version_promoter.tap do |gvp|
85
84
  gvp.level = patch_level.first || :major
86
- gvp.strict = options[:strict] || options["update-strict"]
85
+ gvp.strict = options[:strict] || options["update-strict"] || options["filter-strict"]
87
86
  end
88
87
  end
89
88
 
@@ -1,119 +1,194 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bundler
4
- class CLI::Config
5
- attr_reader :name, :options, :scope, :thor
6
- attr_accessor :args
7
-
8
- def initialize(options, args, thor)
9
- @options = options
10
- @args = args
11
- @thor = thor
12
- @name = peek = args.shift
13
- @scope = "global"
14
- return unless peek && peek.start_with?("--")
15
- @name = args.shift
16
- @scope = peek[2..-1]
4
+ class CLI::Config < Thor
5
+ class_option :parseable, :type => :boolean, :banner => "Use minimal formatting for more parseable output"
6
+
7
+ def self.scope_options
8
+ method_option :global, :type => :boolean, :banner => "Only change the global config"
9
+ method_option :local, :type => :boolean, :banner => "Only change the local config"
17
10
  end
11
+ private_class_method :scope_options
18
12
 
19
- def run
20
- unless name
21
- confirm_all
22
- return
23
- end
13
+ desc "base NAME [VALUE]", "The Bundler 1 config interface", :hide => true
14
+ scope_options
15
+ method_option :delete, :type => :boolean, :banner => "delete"
16
+ def base(name = nil, *value)
17
+ new_args =
18
+ if ARGV.size == 1
19
+ ["config", "list"]
20
+ elsif ARGV.include?("--delete")
21
+ ARGV.map {|arg| arg == "--delete" ? "unset" : arg }
22
+ elsif ARGV.include?("--global") || ARGV.include?("--local") || ARGV.size == 3
23
+ ["config", "set", *ARGV[1..-1]]
24
+ else
25
+ ["config", "get", ARGV[1]]
26
+ end
24
27
 
25
- unless valid_scope?(scope)
26
- Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
27
- exit 1
28
- end
28
+ SharedHelpers.major_deprecation 2,
29
+ "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
30
+
31
+ Base.new(options, name, value, self).run
32
+ end
33
+
34
+ desc "list", "List out all configured settings"
35
+ def list
36
+ Base.new(options, nil, nil, self).run
37
+ end
38
+
39
+ desc "get NAME", "Returns the value for the given key"
40
+ def get(name)
41
+ Base.new(options, name, nil, self).run
42
+ end
43
+
44
+ desc "set NAME VALUE", "Sets the given value for the given key"
45
+ scope_options
46
+ def set(name, value, *value_)
47
+ Base.new(options, name, value_.unshift(value), self).run
48
+ end
29
49
 
30
- if scope == "delete"
31
- Bundler.settings.set_local(name, nil)
32
- Bundler.settings.set_global(name, nil)
33
- return
50
+ desc "unset NAME", "Unsets the value for the given key"
51
+ scope_options
52
+ def unset(name)
53
+ options[:delete] = true
54
+ Base.new(options, name, nil, self).run
55
+ end
56
+
57
+ default_task :base
58
+
59
+ class Base
60
+ attr_reader :name, :value, :options, :scope, :thor
61
+
62
+ def initialize(options, name, value, thor)
63
+ @options = options
64
+ @name = name
65
+ value = Array(value)
66
+ @value = value.empty? ? nil : value.join(" ")
67
+ @thor = thor
68
+ validate_scope!
34
69
  end
35
70
 
36
- if args.empty?
37
- if options[:parseable]
38
- if value = Bundler.settings[name]
39
- Bundler.ui.info("#{name}=#{value}")
71
+ def run
72
+ unless name
73
+ warn_unused_scope "Ignoring --#{scope}"
74
+ confirm_all
75
+ return
76
+ end
77
+
78
+ if options[:delete]
79
+ if !explicit_scope? || scope != "global"
80
+ Bundler.settings.set_local(name, nil)
81
+ end
82
+ if !explicit_scope? || scope != "local"
83
+ Bundler.settings.set_global(name, nil)
40
84
  end
41
85
  return
42
86
  end
43
87
 
44
- confirm(name)
45
- return
46
- end
88
+ if value.nil?
89
+ warn_unused_scope "Ignoring --#{scope} since no value to set was given"
47
90
 
48
- Bundler.ui.info(message) if message
49
- Bundler.settings.send("set_#{scope}", name, new_value)
50
- end
91
+ if options[:parseable]
92
+ if value = Bundler.settings[name]
93
+ Bundler.ui.info("#{name}=#{value}")
94
+ end
95
+ return
96
+ end
51
97
 
52
- private
98
+ confirm(name)
99
+ return
100
+ end
53
101
 
54
- def confirm_all
55
- if @options[:parseable]
56
- thor.with_padding do
102
+ Bundler.ui.info(message) if message
103
+ Bundler.settings.send("set_#{scope}", name, new_value)
104
+ end
105
+
106
+ def confirm_all
107
+ if @options[:parseable]
108
+ thor.with_padding do
109
+ Bundler.settings.all.each do |setting|
110
+ val = Bundler.settings[setting]
111
+ Bundler.ui.info "#{setting}=#{val}"
112
+ end
113
+ end
114
+ else
115
+ Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
57
116
  Bundler.settings.all.each do |setting|
58
- val = Bundler.settings[setting]
59
- Bundler.ui.info "#{setting}=#{val}"
117
+ Bundler.ui.confirm setting
118
+ show_pretty_values_for(setting)
119
+ Bundler.ui.confirm ""
60
120
  end
61
121
  end
62
- else
63
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
64
- Bundler.settings.all.each do |setting|
65
- Bundler.ui.confirm "#{setting}"
66
- show_pretty_values_for(setting)
67
- Bundler.ui.confirm ""
68
- end
69
122
  end
70
- end
71
123
 
72
- def confirm(name)
73
- Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
74
- show_pretty_values_for(name)
75
- end
124
+ def confirm(name)
125
+ Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
126
+ show_pretty_values_for(name)
127
+ end
76
128
 
77
- def new_value
78
- pathname = Pathname.new(args.join(" "))
79
- if name.start_with?("local.") && pathname.directory?
80
- pathname.expand_path.to_s
81
- else
82
- args.join(" ")
129
+ def new_value
130
+ pathname = Pathname.new(value)
131
+ if name.start_with?("local.") && pathname.directory?
132
+ pathname.expand_path.to_s
133
+ else
134
+ value
135
+ end
83
136
  end
84
- end
85
137
 
86
- def message
87
- locations = Bundler.settings.locations(name)
88
- if @options[:parseable]
89
- "#{name}=#{new_value}" if new_value
90
- elsif scope == "global"
91
- if locations[:local]
92
- "Your application has set #{name} to #{locations[:local].inspect}. " \
93
- "This will override the global value you are currently setting"
94
- elsif locations[:env]
95
- "You have a bundler environment variable for #{name} set to " \
96
- "#{locations[:env].inspect}. This will take precedence over the global value you are setting"
97
- elsif locations[:global] && locations[:global] != args.join(" ")
98
- "You are replacing the current global value of #{name}, which is currently " \
99
- "#{locations[:global].inspect}"
138
+ def message
139
+ locations = Bundler.settings.locations(name)
140
+ if @options[:parseable]
141
+ "#{name}=#{new_value}" if new_value
142
+ elsif scope == "global"
143
+ if !locations[:local].nil?
144
+ "Your application has set #{name} to #{locations[:local].inspect}. " \
145
+ "This will override the global value you are currently setting"
146
+ elsif locations[:env]
147
+ "You have a bundler environment variable for #{name} set to " \
148
+ "#{locations[:env].inspect}. This will take precedence over the global value you are setting"
149
+ elsif !locations[:global].nil? && locations[:global] != value
150
+ "You are replacing the current global value of #{name}, which is currently " \
151
+ "#{locations[:global].inspect}"
152
+ end
153
+ elsif scope == "local" && !locations[:local].nil? && locations[:local] != value
154
+ "You are replacing the current local value of #{name}, which is currently " \
155
+ "#{locations[:local].inspect}"
100
156
  end
101
- elsif scope == "local" && locations[:local] != args.join(" ")
102
- "You are replacing the current local value of #{name}, which is currently " \
103
- "#{locations[:local].inspect}"
104
157
  end
105
- end
106
158
 
107
- def show_pretty_values_for(setting)
108
- thor.with_padding do
109
- Bundler.settings.pretty_values_for(setting).each do |line|
110
- Bundler.ui.info line
159
+ def show_pretty_values_for(setting)
160
+ thor.with_padding do
161
+ Bundler.settings.pretty_values_for(setting).each do |line|
162
+ Bundler.ui.info line
163
+ end
111
164
  end
112
165
  end
113
- end
114
166
 
115
- def valid_scope?(scope)
116
- %w[delete local global].include?(scope)
167
+ def explicit_scope?
168
+ @explicit_scope
169
+ end
170
+
171
+ def warn_unused_scope(msg)
172
+ return unless explicit_scope?
173
+ return if options[:parseable]
174
+
175
+ Bundler.ui.warn(msg)
176
+ end
177
+
178
+ def validate_scope!
179
+ @explicit_scope = true
180
+ scopes = %w[global local].select {|s| options[s] }
181
+ case scopes.size
182
+ when 0
183
+ @scope = "global"
184
+ @explicit_scope = false
185
+ when 1
186
+ @scope = scopes.first
187
+ else
188
+ raise InvalidOption,
189
+ "The options #{scopes.join " and "} were specified. Please only use one of the switches at a time."
190
+ end
191
+ end
117
192
  end
118
193
  end
119
194
  end
@@ -9,10 +9,10 @@ module Bundler
9
9
  end
10
10
 
11
11
  def run
12
- Bundler::SharedHelpers.major_deprecation 3, "bundle console will be replaced " \
12
+ Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
13
13
  "by `bin/console` generated by `bundle gem <name>`"
14
14
 
15
- group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require
15
+ group ? Bundler.require(:default, *group.split.map!(&:to_sym)) : Bundler.require
16
16
  ARGV.clear
17
17
 
18
18
  console = get_console(Bundler.settings[:console] || "irb")
@@ -4,8 +4,8 @@ require "rbconfig"
4
4
 
5
5
  module Bundler
6
6
  class CLI::Doctor
7
- DARWIN_REGEX = /\s+(.+) \(compatibility /
8
- LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/
7
+ DARWIN_REGEX = /\s+(.+) \(compatibility /.freeze
8
+ LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/.freeze
9
9
 
10
10
  attr_reader :options
11
11
 
@@ -56,7 +56,7 @@ module Bundler
56
56
  end
57
57
 
58
58
  def check!
59
- require "bundler/cli/check"
59
+ require_relative "check"
60
60
  Bundler::CLI::Check.new({}).run
61
61
  end
62
62
 
@@ -100,7 +100,7 @@ module Bundler
100
100
  files_not_readable_or_writable = []
101
101
  files_not_rw_and_owned_by_different_user = []
102
102
  files_not_owned_by_current_user_but_still_rw = []
103
- Find.find(Bundler.home.to_s).each do |f|
103
+ Find.find(Bundler.bundle_path.to_s).each do |f|
104
104
  if !File.writable?(f) || !File.readable?(f)
105
105
  if File.stat(f).uid != Process.uid
106
106
  files_not_rw_and_owned_by_different_user << f