Skip to content

Commit c6e399a

Browse files
authored
Merge pull request #6676 from rubygems/thor-1-2-2
Bump up thor-1.2.2
2 parents d481e3c + d9a003b commit c6e399a

File tree

17 files changed

+76
-66
lines changed

17 files changed

+76
-66
lines changed

bundler/lib/bundler/vendor/thor/lib/thor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def disable_required_check #:nodoc:
356356
end
357357

358358
# The method responsible for dispatching given the args.
359-
def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
359+
def dispatch(meth, given_args, given_opts, config) #:nodoc:
360360
meth ||= retrieve_command_name(given_args)
361361
command = all_commands[normalize_command_name(meth)]
362362

bundler/lib/bundler/vendor/thor/lib/thor/actions.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def inside(dir = "", config = {}, &block)
175175
shell.padding += 1 if verbose
176176
@destination_stack.push File.expand_path(dir, destination_root)
177177

178-
# If the directory doesnt exist and we're not pretending
178+
# If the directory doesn't exist and we're not pretending
179179
if !File.exist?(destination_root) && !pretend
180180
require "fileutils"
181181
FileUtils.mkdir_p(destination_root)
@@ -223,9 +223,10 @@ def apply(path, config = {})
223223

224224
contents = if is_uri
225225
require "open-uri"
226-
URI.open(path, "Accept" => "application/x-thor-template", &:read)
226+
# for ruby 2.1-2.4
227+
URI.send(:open, path, "Accept" => "application/x-thor-template", &:read)
227228
else
228-
open(path, &:read)
229+
File.open(path, &:read)
229230
end
230231

231232
instance_eval(contents, path)

bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def invoke!
6060
invoke_with_conflict_check do
6161
require "fileutils"
6262
FileUtils.mkdir_p(File.dirname(destination))
63-
File.open(destination, "wb") { |f| f.write render }
63+
File.open(destination, "wb", config[:perm]) { |f| f.write render }
6464
end
6565
given_destination
6666
end

bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get(source, *args, &block)
8585
URI.send(:open, source) { |input| input.binmode.read }
8686
else
8787
source = File.expand_path(find_in_source_paths(source.to_s))
88-
open(source) { |input| input.binmode.read }
88+
File.open(source) { |input| input.binmode.read }
8989
end
9090

9191
destination ||= if block_given?
@@ -252,7 +252,7 @@ def inject_into_module(path, module_name, *args, &block)
252252
# flag<Regexp|String>:: the regexp or string to be replaced
253253
# replacement<String>:: the replacement, can be also given as a block
254254
# config<Hash>:: give :verbose => false to not log the status, and
255-
# :force => true, to force the replacement regardles of runner behavior.
255+
# :force => true, to force the replacement regardless of runner behavior.
256256
#
257257
# ==== Example
258258
#

bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Actions
2121
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
2222
# end
2323
#
24-
WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
24+
WARNINGS = { unchanged_no_flag: 'File unchanged! Either the supplied flag value not found or the content has already been inserted!' }
2525

2626
def insert_into_file(destination, *args, &block)
2727
data = block_given? ? block : args.shift

bundler/lib/bundler/vendor/thor/lib/thor/base.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def start(given_args = ARGV, config = {})
506506
#
507507
def public_command(*names)
508508
names.each do |name|
509-
class_eval "def #{name}(*); super end"
509+
class_eval "def #{name}(*); super end", __FILE__, __LINE__
510510
end
511511
end
512512
alias_method :public_task, :public_command
@@ -558,8 +558,7 @@ def print_options(shell, options, group_name = nil)
558558
return if options.empty?
559559

560560
list = []
561-
padding = options.map { |o| o.aliases.size }.max.to_i * 4
562-
561+
padding = options.map { |o| o.aliases_for_usage.size }.max.to_i
563562
options.each do |option|
564563
next if option.hide
565564
item = [option.usage(padding)]
@@ -610,15 +609,15 @@ def build_options(options, scope) #:nodoc:
610609
def find_and_refresh_command(name) #:nodoc:
611610
if commands[name.to_s]
612611
commands[name.to_s]
613-
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
612+
elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
614613
commands[name.to_s] = command.clone
615614
else
616615
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
617616
end
618617
end
619618
alias_method :find_and_refresh_task, :find_and_refresh_command
620619

621-
# Everytime someone inherits from a Bundler::Thor class, register the klass
620+
# Every time someone inherits from a Bundler::Thor class, register the klass
622621
# and file into baseclass.
623622
def inherited(klass)
624623
super(klass)

bundler/lib/bundler/vendor/thor/lib/thor/error.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ def initialize(dictionary)
1111
end
1212
end
1313

14-
DidYouMean::Correctable
14+
Module.new do
15+
def to_s
16+
super + DidYouMean.formatter.message_for(corrections)
17+
end
18+
19+
def corrections
20+
@corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
21+
end
22+
end
1523
end
1624

1725
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
@@ -100,16 +108,4 @@ class RequiredArgumentMissingError < InvocationError
100108

101109
class MalformattedArgumentError < InvocationError
102110
end
103-
104-
if Correctable
105-
if DidYouMean.respond_to?(:correct_error)
106-
DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
107-
DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
108-
else
109-
DidYouMean::SPELL_CHECKERS.merge!(
110-
'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
111-
'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
112-
)
113-
end
114-
end
115111
end

bundler/lib/bundler/vendor/thor/lib/thor/group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def class_options_help(shell, groups = {}) #:nodoc:
169169
# options are added to group_options hash. Options that already exists
170170
# in base_options are not added twice.
171171
#
172-
def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
172+
def get_options_from_invocations(group_options, base_options) #:nodoc:
173173
invocations.each do |name, from_option|
174174
value = if from_option
175175
option = class_options[name]

bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Bundler::Thor
2-
class Arguments #:nodoc: # rubocop:disable ClassLength
2+
class Arguments #:nodoc:
33
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
44

55
# Receives an array of args and returns two arrays, one with arguments

bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.parse(key, value)
5858
default = nil
5959
if VALID_TYPES.include?(value)
6060
value
61-
elsif required = (value == :required) # rubocop:disable AssignmentInCondition
61+
elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
6262
:string
6363
end
6464
when TrueClass, FalseClass
@@ -93,10 +93,14 @@ def usage(padding = 0)
9393
sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
9494
end
9595

96+
aliases_for_usage.ljust(padding) + sample
97+
end
98+
99+
def aliases_for_usage
96100
if aliases.empty?
97-
(" " * padding) << sample
101+
""
98102
else
99-
"#{aliases.join(', ')}, #{sample}"
103+
"#{aliases.join(', ')}, "
100104
end
101105
end
102106

0 commit comments

Comments
 (0)