bundler 2.1.0.pre.2 → 2.1.0.pre.3

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/lib/bundler.rb +87 -24
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli.rb +55 -25
  6. data/lib/bundler/cli/add.rb +1 -0
  7. data/lib/bundler/cli/{package.rb → cache.rb} +2 -2
  8. data/lib/bundler/cli/exec.rb +0 -7
  9. data/lib/bundler/dsl.rb +1 -1
  10. data/lib/bundler/friendly_errors.rb +1 -1
  11. data/lib/bundler/gem_helper.rb +0 -2
  12. data/lib/bundler/gem_helpers.rb +1 -1
  13. data/lib/bundler/inline.rb +7 -3
  14. data/lib/bundler/lockfile_parser.rb +1 -0
  15. data/lib/bundler/rubygems_ext.rb +1 -1
  16. data/lib/bundler/rubygems_integration.rb +0 -1
  17. data/lib/bundler/setup.rb +2 -9
  18. data/lib/bundler/shared_helpers.rb +12 -25
  19. data/lib/bundler/source/git.rb +1 -1
  20. data/lib/bundler/source/git/git_proxy.rb +1 -1
  21. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +132 -109
  22. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +1 -1
  23. data/lib/bundler/vendor/thor/lib/thor.rb +5 -2
  24. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -0
  25. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +6 -16
  26. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  27. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +18 -7
  28. data/lib/bundler/vendor/thor/lib/thor/base.rb +10 -8
  29. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  30. data/lib/bundler/vendor/thor/lib/thor/error.rb +14 -18
  31. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  32. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  33. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  34. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +1 -1
  35. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +8 -6
  36. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -3
  37. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  38. data/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -0
  39. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  40. data/lib/bundler/version.rb +1 -1
  41. data/man/bundle-add.1 +1 -1
  42. data/man/bundle-add.1.txt +1 -1
  43. data/man/bundle-binstubs.1 +1 -1
  44. data/man/bundle-binstubs.1.txt +1 -1
  45. data/man/bundle-cache.1 +55 -0
  46. data/man/bundle-cache.1.txt +78 -0
  47. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  48. data/man/bundle-check.1 +1 -1
  49. data/man/bundle-check.1.txt +1 -1
  50. data/man/bundle-clean.1 +1 -1
  51. data/man/bundle-clean.1.txt +1 -1
  52. data/man/bundle-config.1 +1 -1
  53. data/man/bundle-config.1.txt +1 -1
  54. data/man/bundle-doctor.1 +1 -1
  55. data/man/bundle-doctor.1.txt +1 -1
  56. data/man/bundle-exec.1 +1 -1
  57. data/man/bundle-exec.1.txt +1 -1
  58. data/man/bundle-gem.1 +1 -1
  59. data/man/bundle-gem.1.txt +1 -1
  60. data/man/bundle-info.1 +1 -1
  61. data/man/bundle-info.1.txt +1 -1
  62. data/man/bundle-init.1 +1 -1
  63. data/man/bundle-init.1.txt +1 -1
  64. data/man/bundle-inject.1 +1 -1
  65. data/man/bundle-inject.1.txt +1 -1
  66. data/man/bundle-install.1 +1 -1
  67. data/man/bundle-install.1.txt +1 -1
  68. data/man/bundle-list.1 +1 -1
  69. data/man/bundle-list.1.txt +1 -1
  70. data/man/bundle-lock.1 +1 -1
  71. data/man/bundle-lock.1.txt +1 -1
  72. data/man/bundle-open.1 +1 -1
  73. data/man/bundle-open.1.txt +1 -1
  74. data/man/bundle-outdated.1 +1 -1
  75. data/man/bundle-outdated.1.txt +1 -1
  76. data/man/bundle-platform.1 +1 -1
  77. data/man/bundle-platform.1.txt +1 -1
  78. data/man/bundle-pristine.1 +1 -1
  79. data/man/bundle-pristine.1.txt +1 -1
  80. data/man/bundle-remove.1 +1 -1
  81. data/man/bundle-remove.1.txt +1 -1
  82. data/man/bundle-show.1 +1 -1
  83. data/man/bundle-show.1.txt +1 -1
  84. data/man/bundle-update.1 +1 -1
  85. data/man/bundle-update.1.txt +1 -1
  86. data/man/bundle-viz.1 +1 -1
  87. data/man/bundle-viz.1.txt +1 -1
  88. data/man/bundle.1 +1 -1
  89. data/man/bundle.1.txt +1 -1
  90. data/man/gemfile.5 +1 -1
  91. data/man/gemfile.5.txt +1 -1
  92. data/man/index.txt +1 -1
  93. metadata +6 -7
  94. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  95. data/man/bundle-package.1 +0 -55
  96. data/man/bundle-package.1.txt +0 -79
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bundler::FileUtils
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -175,7 +175,7 @@ class Bundler::Thor
175
175
  handle_no_command_error(meth) unless command
176
176
 
177
177
  shell.say "Usage:"
178
- shell.say " #{banner(command)}"
178
+ shell.say " #{banner(command).split("\n").join("\n ")}"
179
179
  shell.say
180
180
  class_options_help(shell, nil => command.options.values)
181
181
  if command.long_description
@@ -398,7 +398,10 @@ class Bundler::Thor
398
398
  # the namespace should be displayed as arguments.
399
399
  #
400
400
  def banner(command, namespace = nil, subcommand = false)
401
- "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
401
+ $thor_runner ||= false
402
+ command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
403
+ "#{basename} #{formatted_usage}"
404
+ end.join("\n")
402
405
  end
403
406
 
404
407
  def baseclass #:nodoc:
@@ -12,6 +12,7 @@ class Bundler::Thor
12
12
  attr_accessor :behavior
13
13
 
14
14
  def self.included(base) #:nodoc:
15
+ super(base)
15
16
  base.extend ClassMethods
16
17
  end
17
18
 
@@ -56,7 +56,7 @@ class Bundler::Thor
56
56
  attr_reader :source
57
57
 
58
58
  def initialize(base, source, destination = nil, config = {}, &block)
59
- @source = File.expand_path(base.find_in_source_paths(source.to_s))
59
+ @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
60
60
  @block = block
61
61
  super(base, destination, {:recursive => true}.merge(config))
62
62
  end
@@ -96,22 +96,12 @@ class Bundler::Thor
96
96
  end
97
97
  end
98
98
 
99
- if RUBY_VERSION < "2.0"
100
- def file_level_lookup(previous_lookup)
101
- File.join(previous_lookup, "{*,.[a-z]*}")
102
- end
103
-
104
- def files(lookup)
105
- Dir[lookup]
106
- end
107
- else
108
- def file_level_lookup(previous_lookup)
109
- File.join(previous_lookup, "*")
110
- end
99
+ def file_level_lookup(previous_lookup)
100
+ File.join(previous_lookup, "*")
101
+ end
111
102
 
112
- def files(lookup)
113
- Dir.glob(lookup, File::FNM_DOTMATCH)
114
- end
103
+ def files(lookup)
104
+ Dir.glob(lookup, File::FNM_DOTMATCH)
115
105
  end
116
106
  end
117
107
  end
@@ -23,14 +23,14 @@ class Bundler::Thor
23
23
  destination = args.first || source
24
24
  source = File.expand_path(find_in_source_paths(source.to_s))
25
25
 
26
- create_file destination, nil, config do
26
+ resulting_destination = create_file destination, nil, config do
27
27
  content = File.binread(source)
28
28
  content = yield(content) if block
29
29
  content
30
30
  end
31
31
  if config[:mode] == :preserve
32
32
  mode = File.stat(source).mode
33
- chmod(destination, mode, config)
33
+ chmod(resulting_destination, mode, config)
34
34
  end
35
35
  end
36
36
 
@@ -80,14 +80,14 @@ class Bundler::Thor
80
80
  config = args.last.is_a?(Hash) ? args.pop : {}
81
81
  destination = args.first
82
82
 
83
- if source =~ %r{^https?\://}
83
+ render = if source =~ %r{^https?\://}
84
84
  require "open-uri"
85
+ URI.send(:open, source) { |input| input.binmode.read }
85
86
  else
86
87
  source = File.expand_path(find_in_source_paths(source.to_s))
88
+ open(source) { |input| input.binmode.read }
87
89
  end
88
90
 
89
- render = open(source) { |input| input.binmode.read }
90
-
91
91
  destination ||= if block_given?
92
92
  block.arity == 1 ? yield(render) : yield
93
93
  else
@@ -21,9 +21,14 @@ class Bundler::Thor
21
21
  # gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
22
22
  # end
23
23
  #
24
+ WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
25
+
24
26
  def insert_into_file(destination, *args, &block)
25
27
  data = block_given? ? block : args.shift
26
- config = args.shift
28
+
29
+ config = args.shift || {}
30
+ config[:after] = /\z/ unless config.key?(:before) || config.key?(:after)
31
+
27
32
  action InjectIntoFile.new(self, destination, data, config)
28
33
  end
29
34
  alias_method :inject_into_file, :insert_into_file
@@ -45,8 +50,6 @@ class Bundler::Thor
45
50
  end
46
51
 
47
52
  def invoke!
48
- say_status :invoke
49
-
50
53
  content = if @behavior == :after
51
54
  '\0' + replacement
52
55
  else
@@ -54,7 +57,11 @@ class Bundler::Thor
54
57
  end
55
58
 
56
59
  if exists?
57
- replace!(/#{flag}/, content, config[:force])
60
+ if replace!(/#{flag}/, content, config[:force])
61
+ say_status(:invoke)
62
+ else
63
+ say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
64
+ end
58
65
  else
59
66
  unless pretend?
60
67
  raise Bundler::Thor::Error, "The file #{ destination } does not appear to exist"
@@ -78,7 +85,7 @@ class Bundler::Thor
78
85
 
79
86
  protected
80
87
 
81
- def say_status(behavior)
88
+ def say_status(behavior, warning: nil, color: nil)
82
89
  status = if behavior == :invoke
83
90
  if flag == /\A/
84
91
  :prepend
@@ -87,11 +94,13 @@ class Bundler::Thor
87
94
  else
88
95
  :insert
89
96
  end
97
+ elsif warning
98
+ warning
90
99
  else
91
100
  :subtract
92
101
  end
93
102
 
94
- super(status, config[:verbose])
103
+ super(status, (color || config[:verbose]))
95
104
  end
96
105
 
97
106
  # Adds the content to the file.
@@ -100,8 +109,10 @@ class Bundler::Thor
100
109
  return if pretend?
101
110
  content = File.read(destination)
102
111
  if force || !content.include?(replacement)
103
- content.gsub!(regexp, string)
112
+ success = content.gsub!(regexp, string)
113
+
104
114
  File.open(destination, "wb") { |file| file.write(content) }
115
+ success
105
116
  end
106
117
  end
107
118
  end
@@ -1,6 +1,5 @@
1
1
  require_relative "command"
2
2
  require_relative "core_ext/hash_with_indifferent_access"
3
- require_relative "core_ext/ordered_hash"
4
3
  require_relative "error"
5
4
  require_relative "invocation"
6
5
  require_relative "parser"
@@ -89,6 +88,7 @@ class Bundler::Thor
89
88
 
90
89
  class << self
91
90
  def included(base) #:nodoc:
91
+ super(base)
92
92
  base.extend ClassMethods
93
93
  base.send :include, Invocation
94
94
  base.send :include, Shell
@@ -353,22 +353,22 @@ class Bundler::Thor
353
353
  # Returns the commands for this Bundler::Thor class.
354
354
  #
355
355
  # ==== Returns
356
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
357
- # objects as values.
356
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
357
+ # objects as values.
358
358
  #
359
359
  def commands
360
- @commands ||= Bundler::Thor::CoreExt::OrderedHash.new
360
+ @commands ||= Hash.new
361
361
  end
362
362
  alias_method :tasks, :commands
363
363
 
364
364
  # Returns the commands for this Bundler::Thor class and all subclasses.
365
365
  #
366
366
  # ==== Returns
367
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
368
- # objects as values.
367
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
368
+ # objects as values.
369
369
  #
370
370
  def all_commands
371
- @all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new)
371
+ @all_commands ||= from_superclass(:all_commands, Hash.new)
372
372
  @all_commands.merge!(commands)
373
373
  end
374
374
  alias_method :all_tasks, :all_commands
@@ -502,7 +502,7 @@ class Bundler::Thor
502
502
  msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
503
503
  msg << "no arguments" if args.empty?
504
504
  msg << "arguments " << args.inspect unless args.empty?
505
- msg << "\nUsage: #{banner(command).inspect}"
505
+ msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
506
506
  raise InvocationError, msg
507
507
  end
508
508
 
@@ -596,6 +596,7 @@ class Bundler::Thor
596
596
  # Everytime someone inherits from a Bundler::Thor class, register the klass
597
597
  # and file into baseclass.
598
598
  def inherited(klass)
599
+ super(klass)
599
600
  Bundler::Thor::Base.register_klass_file(klass)
600
601
  klass.instance_variable_set(:@no_commands, false)
601
602
  end
@@ -603,6 +604,7 @@ class Bundler::Thor
603
604
  # Fire this callback whenever a method is added. Added methods are
604
605
  # tracked as commands by invoking the create_command method.
605
606
  def method_added(meth)
607
+ super(meth)
606
608
  meth = meth.to_s
607
609
 
608
610
  if meth == "initialize"
@@ -49,24 +49,32 @@ class Bundler::Thor
49
49
 
50
50
  formatted ||= "".dup
51
51
 
52
- # Add usage with required arguments
53
- formatted << if klass && !klass.arguments.empty?
54
- usage.to_s.gsub(/^#{name}/) do |match|
55
- match << " " << klass.arguments.map(&:usage).compact.join(" ")
56
- end
57
- else
58
- usage.to_s
59
- end
52
+ Array(usage).map do |specific_usage|
53
+ formatted_specific_usage = formatted
60
54
 
61
- # Add required options
62
- formatted << " #{required_options}"
55
+ formatted_specific_usage += required_arguments_for(klass, specific_usage)
63
56
 
64
- # Strip and go!
65
- formatted.strip
57
+ # Add required options
58
+ formatted_specific_usage += " #{required_options}"
59
+
60
+ # Strip and go!
61
+ formatted_specific_usage.strip
62
+ end.join("\n")
66
63
  end
67
64
 
68
65
  protected
69
66
 
67
+ # Add usage with required arguments
68
+ def required_arguments_for(klass, usage)
69
+ if klass && !klass.arguments.empty?
70
+ usage.to_s.gsub(/^#{name}/) do |match|
71
+ match << " " << klass.arguments.map(&:usage).compact.join(" ")
72
+ end
73
+ else
74
+ usage.to_s
75
+ end
76
+ end
77
+
70
78
  def not_debugging?(instance)
71
79
  !(instance.class.respond_to?(:debugging) && instance.class.debugging)
72
80
  end
@@ -97,8 +105,7 @@ class Bundler::Thor
97
105
  def handle_argument_error?(instance, error, caller)
98
106
  not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
99
107
  saned = sans_backtrace(error.backtrace, caller)
100
- # Ruby 1.9 always include the called method in the backtrace
101
- saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
108
+ saned.empty? || saned.size == 1
102
109
  end
103
110
  end
104
111
 
@@ -1,22 +1,18 @@
1
1
  class Bundler::Thor
2
- Correctable =
3
- begin
4
- require 'did_you_mean'
5
-
6
- # In order to support versions of Ruby that don't have keyword
7
- # arguments, we need our own spell checker class that doesn't take key
8
- # words. Even though this code wouldn't be hit because of the check
9
- # above, it's still necessary because the interpreter would otherwise be
10
- # unable to parse the file.
11
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
12
- def initialize(dictionary)
13
- @dictionary = dictionary
14
- end
15
- end
16
-
17
- DidYouMean::Correctable
18
- rescue LoadError, NameError
19
- end
2
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
3
+ # In order to support versions of Ruby that don't have keyword
4
+ # arguments, we need our own spell checker class that doesn't take key
5
+ # words. Even though this code wouldn't be hit because of the check
6
+ # above, it's still necessary because the interpreter would otherwise be
7
+ # unable to parse the file.
8
+ class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
9
+ def initialize(dictionary)
10
+ @dictionary = dictionary
11
+ end
12
+ end
13
+
14
+ DidYouMean::Correctable
15
+ end
20
16
 
21
17
  # Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
22
18
  # errors have their backtrace suppressed and are nicely shown to the user.
@@ -1,6 +1,7 @@
1
1
  class Bundler::Thor
2
2
  module Invocation
3
3
  def self.included(base) #:nodoc:
4
+ super(base)
4
5
  base.extend ClassMethods
5
6
  end
6
7
 
@@ -24,7 +24,7 @@ class Bundler::Thor
24
24
  $stdin.gets
25
25
  else
26
26
  # Lazy-load io/console since it is gem-ified as of 2.3
27
- require "io/console" if RUBY_VERSION > "1.9.2"
27
+ require "io/console"
28
28
  $stdin.noecho(&:gets)
29
29
  end
30
30
  end
@@ -1,19 +1,19 @@
1
- begin
2
- require "readline"
3
- rescue LoadError
4
- end
5
-
6
1
  class Bundler::Thor
7
2
  module LineEditor
8
3
  class Readline < Basic
9
4
  def self.available?
5
+ begin
6
+ require "readline"
7
+ rescue LoadError
8
+ end
9
+
10
10
  Object.const_defined?(:Readline)
11
11
  end
12
12
 
13
13
  def readline
14
14
  if echo?
15
15
  ::Readline.completion_append_character = nil
16
- # Ruby 1.8.7 does not allow Readline.completion_proc= to receive nil.
16
+ # rb-readline does not allow Readline.completion_proc= to receive nil.
17
17
  if complete = completion_proc
18
18
  ::Readline.completion_proc = complete
19
19
  end
@@ -9,7 +9,7 @@ class Bundler::Thor
9
9
  arguments = []
10
10
 
11
11
  args.each do |item|
12
- break if item =~ /^-/
12
+ break if item.is_a?(String) && item =~ /^-/
13
13
  arguments << item
14
14
  end
15
15
 
@@ -1,17 +1,18 @@
1
1
  class Bundler::Thor
2
2
  class Option < Argument #:nodoc:
3
- attr_reader :aliases, :group, :lazy_default, :hide
3
+ attr_reader :aliases, :group, :lazy_default, :hide, :repeatable
4
4
 
5
5
  VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
6
6
 
7
7
  def initialize(name, options = {})
8
8
  @check_default_type = options[:check_default_type]
9
9
  options[:required] = false unless options.key?(:required)
10
+ @repeatable = options.fetch(:repeatable, false)
10
11
  super
11
- @lazy_default = options[:lazy_default]
12
- @group = options[:group].to_s.capitalize if options[:group]
13
- @aliases = Array(options[:aliases])
14
- @hide = options[:hide]
12
+ @lazy_default = options[:lazy_default]
13
+ @group = options[:group].to_s.capitalize if options[:group]
14
+ @aliases = Array(options[:aliases])
15
+ @hide = options[:hide]
15
16
  end
16
17
 
17
18
  # This parse quick options given as method_options. It makes several
@@ -128,7 +129,8 @@ class Bundler::Thor
128
129
  @default.class.name.downcase.to_sym
129
130
  end
130
131
 
131
- raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type
132
+ expected_type = (@repeatable && @type != :hash) ? :array : @type
133
+ raise ArgumentError, "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == expected_type
132
134
  end
133
135
 
134
136
  def dasherized?
@@ -97,7 +97,8 @@ class Bundler::Thor
97
97
 
98
98
  switch = normalize_switch(switch)
99
99
  option = switch_option(switch)
100
- @assigns[option.human_name] = parse_peek(switch, option)
100
+ result = parse_peek(switch, option)
101
+ assign_result!(option, result)
101
102
  elsif @stop_on_unknown
102
103
  @parsing_options = false
103
104
  @extra << shifted
@@ -132,6 +133,15 @@ class Bundler::Thor
132
133
 
133
134
  protected
134
135
 
136
+ def assign_result!(option, result)
137
+ if option.repeatable && option.type == :hash
138
+ (@assigns[option.human_name] ||= {}).merge!(result)
139
+ elsif option.repeatable
140
+ (@assigns[option.human_name] ||= []) << result
141
+ else
142
+ @assigns[option.human_name] = result
143
+ end
144
+ end
135
145
  # Check if the current value in peek is a registered switch.
136
146
  #
137
147
  # Two booleans are returned. The first is true if the current value
@@ -161,7 +171,7 @@ class Bundler::Thor
161
171
  end
162
172
 
163
173
  def switch?(arg)
164
- switch_option(normalize_switch(arg))
174
+ !switch_option(normalize_switch(arg)).nil?
165
175
  end
166
176
 
167
177
  def switch_option(arg)
@@ -194,7 +204,7 @@ class Bundler::Thor
194
204
  shift
195
205
  false
196
206
  else
197
- !no_or_skip?(switch)
207
+ @switches.key?(switch) || !no_or_skip?(switch)
198
208
  end
199
209
  else
200
210
  @switches.key?(switch) || !no_or_skip?(switch)