Skip to content

Commit

Permalink
Update vendored thor to 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Nov 14, 2024
1 parent 3762f93 commit 5cd1951
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 46 deletions.
11 changes: 11 additions & 0 deletions lib/bundler/vendor/thor/lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,17 @@ def disable_required_check?(command) #:nodoc:
command && disable_required_check.include?(command.name.to_sym)
end

# Checks if a specified command exists.
#
# ==== Parameters
# command_name<String>:: The name of the command to check for existence.
#
# ==== Returns
# Boolean:: +true+ if the command exists, +false+ otherwise.
def command_exists?(command_name) #:nodoc:
commands.keys.include?(normalize_command_name(command_name))
end

protected

# Returns this class exclusive options array set.
Expand Down
8 changes: 3 additions & 5 deletions lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Actions
# destination<String>:: the relative path to the destination root.
# config<Hash>:: give :verbose => false to not log the status, and
# :mode => :preserve, to preserve the file mode from the source.

#
# ==== Examples
#
Expand Down Expand Up @@ -275,9 +274,8 @@ def gsub_file(path, flag, *args, &block)
end
end

# Uncomment all lines matching a given regex. It will leave the space
# which existed before the comment hash in tact but will remove any spacing
# between the comment hash and the beginning of the line.
# Uncomment all lines matching a given regex. Preserves indentation before
# the comment hash and removes the hash and any immediate following space.
#
# ==== Parameters
# path<String>:: path of the file to be changed
Expand All @@ -291,7 +289,7 @@ def gsub_file(path, flag, *args, &block)
def uncomment_lines(path, flag, *args)
flag = flag.respond_to?(:source) ? flag.source : flag

gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args)
gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args)
end

# Comment all lines matching a given regex. It will leave the space
Expand Down
11 changes: 11 additions & 0 deletions lib/bundler/vendor/thor/lib/thor/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ def handle_argument_error(command, error, _args, arity) #:nodoc:
raise error, msg
end

# Checks if a specified command exists.
#
# ==== Parameters
# command_name<String>:: The name of the command to check for existence.
#
# ==== Returns
# Boolean:: +true+ if the command exists, +false+ otherwise.
def command_exists?(command_name) #:nodoc:
commands.keys.include?(command_name)
end

protected

# The method responsible for dispatching given the args.
Expand Down
5 changes: 1 addition & 4 deletions lib/bundler/vendor/thor/lib/thor/parser/argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def initialize(name, options = {})

def print_default
if @type == :array and @default.is_a?(Array)
@default.map { |x|
p = x.gsub('"','\\"')
"\"#{p}\""
}.join(" ")
@default.map(&:dump).join(" ")
else
@default
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/vendor/thor/lib/thor/parser/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def usage(padding = 0)

sample = "[#{sample}]".dup unless required?

if boolean?
sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.match(/\Ano[\-_]/)
if boolean? && name != "force" && !name.match(/\A(no|skip)[\-_]/)
sample << ", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]"
end

aliases_for_usage.ljust(padding) + sample
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/vendor/thor/lib/thor/parser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def parsing_options?
@parsing_options
end

# Parse boolean values which can be given as --foo=true, --foo or --no-foo.
# Parse boolean values which can be given as --foo=true or --foo for true values, or
# --foo=false, --no-foo or --skip-foo for false values.
#
def parse_boolean(switch)
if current_is_value?
Expand Down
18 changes: 9 additions & 9 deletions lib/bundler/vendor/thor/lib/thor/shell/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def indent(count = 1)
# Readline.
#
# ==== Example
# ask("What is your name?")
# ask("What is your name?")
#
# ask("What is the planet furthest from the sun?", :default => "Pluto")
# ask("What is the planet furthest from the sun?", :default => "Neptune")
#
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
#
# ask("What is your password?", :echo => false)
# ask("What is your password?", :echo => false)
#
# ask("Where should the file be saved?", :path => true)
# ask("Where should the file be saved?", :path => true)
#
def ask(statement, *args)
options = args.last.is_a?(Hash) ? args.pop : {}
Expand All @@ -93,7 +93,7 @@ def ask(statement, *args)
# are passed straight to puts (behavior got from Highline).
#
# ==== Example
# say("I know you knew that.")
# say("I know you knew that.")
#
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
return if quiet?
Expand All @@ -110,7 +110,7 @@ def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)
# are passed straight to puts (behavior got from Highline).
#
# ==== Example
# say_error("error: something went wrong")
# say_error("error: something went wrong")
#
def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
return if quiet?
Expand Down Expand Up @@ -143,14 +143,14 @@ def say_status(status, message, log_status = true)
stdout.flush
end

# Make a question the to user and returns true if the user replies "y" or
# Asks the user a question and returns true if the user replies "y" or
# "yes".
#
def yes?(statement, color = nil)
!!(ask(statement, color, add_to_history: false) =~ is?(:yes))
end

# Make a question the to user and returns true if the user replies "n" or
# Asks the user a question and returns true if the user replies "n" or
# "no".
#
def no?(statement, color = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/shell/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def set_color(string, *colors)
# Ask something to the user and receives a response.
#
# ==== Example
# ask("What is your name?")
# ask("What is your name?")
#
# TODO: Implement #ask for Bundler::Thor::Shell::HTML
def ask(statement, color = nil)
Expand Down
26 changes: 5 additions & 21 deletions lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,17 @@ def print_border_separator

def truncate(string)
return string unless @truncate
as_unicode do
chars = string.chars.to_a
if chars.length <= @truncate
chars.join
else
chars[0, @truncate - 3 - @indent].join + "..."
end
chars = string.chars.to_a
if chars.length <= @truncate
chars.join
else
chars[0, @truncate - 3 - @indent].join + "..."
end
end

def indentation
" " * @indent
end

if "".respond_to?(:encode)
def as_unicode
yield
end
else
def as_unicode
old = $KCODE # rubocop:disable Style/GlobalVars
$KCODE = "U" # rubocop:disable Style/GlobalVars
yield
ensure
$KCODE = old # rubocop:disable Style/GlobalVars
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def find_class_and_command_by_namespace(namespace, fallback = true)
*pieces, command = namespace.split(":")
namespace = pieces.join(":")
namespace = "default" if namespace.empty?
klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.commands.keys.include?(command) }
klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.command_exists?(command) }
end
unless klass # look for a Bundler::Thor::Group with the right name
klass = Bundler::Thor::Util.find_by_namespace(namespace)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/thor/lib/thor/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Bundler::Thor
VERSION = "1.3.0"
VERSION = "1.3.2"
end
2 changes: 1 addition & 1 deletion tool/bundler/vendor_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
gem "resolv", "0.5.0"
gem "securerandom", "0.3.2"
gem "timeout", "0.4.2"
gem "thor", "1.3.0"
gem "thor", "1.3.2"
gem "tsort", "0.2.0"
gem "uri", "1.0.1"

0 comments on commit 5cd1951

Please sign in to comment.