[rubygems/rubygems] Bump up thor-1.2.2
https://github.com/rubygems/rubygems/commit/d9a003b4e7
This commit is contained in:
parent
30326844c7
commit
5f411b9b3e
2
lib/bundler/vendor/thor/lib/thor.rb
vendored
2
lib/bundler/vendor/thor/lib/thor.rb
vendored
@ -356,7 +356,7 @@ class Bundler::Thor
|
||||
end
|
||||
|
||||
# The method responsible for dispatching given the args.
|
||||
def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
|
||||
def dispatch(meth, given_args, given_opts, config) #:nodoc:
|
||||
meth ||= retrieve_command_name(given_args)
|
||||
command = all_commands[normalize_command_name(meth)]
|
||||
|
||||
|
7
lib/bundler/vendor/thor/lib/thor/actions.rb
vendored
7
lib/bundler/vendor/thor/lib/thor/actions.rb
vendored
@ -175,7 +175,7 @@ class Bundler::Thor
|
||||
shell.padding += 1 if verbose
|
||||
@destination_stack.push File.expand_path(dir, destination_root)
|
||||
|
||||
# If the directory doesnt exist and we're not pretending
|
||||
# If the directory doesn't exist and we're not pretending
|
||||
if !File.exist?(destination_root) && !pretend
|
||||
require "fileutils"
|
||||
FileUtils.mkdir_p(destination_root)
|
||||
@ -223,9 +223,10 @@ class Bundler::Thor
|
||||
|
||||
contents = if is_uri
|
||||
require "open-uri"
|
||||
URI.open(path, "Accept" => "application/x-thor-template", &:read)
|
||||
# for ruby 2.1-2.4
|
||||
URI.send(:open, path, "Accept" => "application/x-thor-template", &:read)
|
||||
else
|
||||
open(path, &:read)
|
||||
File.open(path, &:read)
|
||||
end
|
||||
|
||||
instance_eval(contents, path)
|
||||
|
@ -60,7 +60,7 @@ class Bundler::Thor
|
||||
invoke_with_conflict_check do
|
||||
require "fileutils"
|
||||
FileUtils.mkdir_p(File.dirname(destination))
|
||||
File.open(destination, "wb") { |f| f.write render }
|
||||
File.open(destination, "wb", config[:perm]) { |f| f.write render }
|
||||
end
|
||||
given_destination
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ class Bundler::Thor
|
||||
URI.send(:open, source) { |input| input.binmode.read }
|
||||
else
|
||||
source = File.expand_path(find_in_source_paths(source.to_s))
|
||||
open(source) { |input| input.binmode.read }
|
||||
File.open(source) { |input| input.binmode.read }
|
||||
end
|
||||
|
||||
destination ||= if block_given?
|
||||
@ -252,7 +252,7 @@ class Bundler::Thor
|
||||
# flag<Regexp|String>:: the regexp or string to be replaced
|
||||
# replacement<String>:: the replacement, can be also given as a block
|
||||
# config<Hash>:: give :verbose => false to not log the status, and
|
||||
# :force => true, to force the replacement regardles of runner behavior.
|
||||
# :force => true, to force the replacement regardless of runner behavior.
|
||||
#
|
||||
# ==== Example
|
||||
#
|
||||
|
@ -21,7 +21,7 @@ class Bundler::Thor
|
||||
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
|
||||
# end
|
||||
#
|
||||
WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
|
||||
WARNINGS = { unchanged_no_flag: 'File unchanged! Either the supplied flag value not found or the content has already been inserted!' }
|
||||
|
||||
def insert_into_file(destination, *args, &block)
|
||||
data = block_given? ? block : args.shift
|
||||
|
9
lib/bundler/vendor/thor/lib/thor/base.rb
vendored
9
lib/bundler/vendor/thor/lib/thor/base.rb
vendored
@ -506,7 +506,7 @@ class Bundler::Thor
|
||||
#
|
||||
def public_command(*names)
|
||||
names.each do |name|
|
||||
class_eval "def #{name}(*); super end"
|
||||
class_eval "def #{name}(*); super end", __FILE__, __LINE__
|
||||
end
|
||||
end
|
||||
alias_method :public_task, :public_command
|
||||
@ -558,8 +558,7 @@ class Bundler::Thor
|
||||
return if options.empty?
|
||||
|
||||
list = []
|
||||
padding = options.map { |o| o.aliases.size }.max.to_i * 4
|
||||
|
||||
padding = options.map { |o| o.aliases_for_usage.size }.max.to_i
|
||||
options.each do |option|
|
||||
next if option.hide
|
||||
item = [option.usage(padding)]
|
||||
@ -610,7 +609,7 @@ class Bundler::Thor
|
||||
def find_and_refresh_command(name) #:nodoc:
|
||||
if commands[name.to_s]
|
||||
commands[name.to_s]
|
||||
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
|
||||
elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
|
||||
commands[name.to_s] = command.clone
|
||||
else
|
||||
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
|
||||
@ -618,7 +617,7 @@ class Bundler::Thor
|
||||
end
|
||||
alias_method :find_and_refresh_task, :find_and_refresh_command
|
||||
|
||||
# Everytime someone inherits from a Bundler::Thor class, register the klass
|
||||
# Every time someone inherits from a Bundler::Thor class, register the klass
|
||||
# and file into baseclass.
|
||||
def inherited(klass)
|
||||
super(klass)
|
||||
|
22
lib/bundler/vendor/thor/lib/thor/error.rb
vendored
22
lib/bundler/vendor/thor/lib/thor/error.rb
vendored
@ -11,7 +11,15 @@ class Bundler::Thor
|
||||
end
|
||||
end
|
||||
|
||||
DidYouMean::Correctable
|
||||
Module.new do
|
||||
def to_s
|
||||
super + DidYouMean.formatter.message_for(corrections)
|
||||
end
|
||||
|
||||
def corrections
|
||||
@corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
|
||||
@ -100,16 +108,4 @@ class Bundler::Thor
|
||||
|
||||
class MalformattedArgumentError < InvocationError
|
||||
end
|
||||
|
||||
if Correctable
|
||||
if DidYouMean.respond_to?(:correct_error)
|
||||
DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
|
||||
DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
|
||||
else
|
||||
DidYouMean::SPELL_CHECKERS.merge!(
|
||||
'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
|
||||
'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
2
lib/bundler/vendor/thor/lib/thor/group.rb
vendored
2
lib/bundler/vendor/thor/lib/thor/group.rb
vendored
@ -169,7 +169,7 @@ class Bundler::Thor::Group
|
||||
# options are added to group_options hash. Options that already exists
|
||||
# in base_options are not added twice.
|
||||
#
|
||||
def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
|
||||
def get_options_from_invocations(group_options, base_options) #:nodoc:
|
||||
invocations.each do |name, from_option|
|
||||
value = if from_option
|
||||
option = class_options[name]
|
||||
|
@ -1,5 +1,5 @@
|
||||
class Bundler::Thor
|
||||
class Arguments #:nodoc: # rubocop:disable ClassLength
|
||||
class Arguments #:nodoc:
|
||||
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
|
||||
|
||||
# Receives an array of args and returns two arrays, one with arguments
|
||||
|
@ -58,7 +58,7 @@ class Bundler::Thor
|
||||
default = nil
|
||||
if VALID_TYPES.include?(value)
|
||||
value
|
||||
elsif required = (value == :required) # rubocop:disable AssignmentInCondition
|
||||
elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
|
||||
:string
|
||||
end
|
||||
when TrueClass, FalseClass
|
||||
@ -93,10 +93,14 @@ class Bundler::Thor
|
||||
sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
|
||||
end
|
||||
|
||||
aliases_for_usage.ljust(padding) + sample
|
||||
end
|
||||
|
||||
def aliases_for_usage
|
||||
if aliases.empty?
|
||||
(" " * padding) << sample
|
||||
""
|
||||
else
|
||||
"#{aliases.join(', ')}, #{sample}"
|
||||
"#{aliases.join(', ')}, "
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
class Bundler::Thor
|
||||
class Options < Arguments #:nodoc: # rubocop:disable ClassLength
|
||||
class Options < Arguments #:nodoc:
|
||||
LONG_RE = /^(--\w+(?:-\w+)*)$/
|
||||
SHORT_RE = /^(-[a-z])$/i
|
||||
EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
|
||||
@ -85,7 +85,7 @@ class Bundler::Thor
|
||||
super(arg)
|
||||
end
|
||||
|
||||
def parse(args) # rubocop:disable MethodLength
|
||||
def parse(args) # rubocop:disable Metrics/MethodLength
|
||||
@pile = args.dup
|
||||
@is_treated_as_value = false
|
||||
@parsing_options = true
|
||||
@ -101,7 +101,7 @@ class Bundler::Thor
|
||||
unshift($1.split("").map { |f| "-#{f}" })
|
||||
next
|
||||
when EQ_RE
|
||||
unshift($2, is_value: true)
|
||||
unshift($2, :is_value => true)
|
||||
switch = $1
|
||||
when SHORT_NUM
|
||||
unshift($2)
|
||||
@ -194,7 +194,7 @@ class Bundler::Thor
|
||||
end
|
||||
|
||||
def switch_option(arg)
|
||||
if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition
|
||||
if match = no_or_skip?(arg) # rubocop:disable Lint/AssignmentInCondition
|
||||
@switches[arg] || @switches["--#{match}"]
|
||||
else
|
||||
@switches[arg]
|
||||
|
@ -41,7 +41,7 @@ instance_eval do
|
||||
def task(*)
|
||||
task = super
|
||||
|
||||
if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
|
||||
if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
|
||||
non_namespaced_name = task.name.split(":").last
|
||||
|
||||
description = non_namespaced_name
|
||||
@ -59,7 +59,7 @@ instance_eval do
|
||||
end
|
||||
|
||||
def namespace(name)
|
||||
if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
|
||||
if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
|
||||
const_name = Bundler::Thor::Util.camel_case(name.to_s).to_sym
|
||||
klass.const_set(const_name, Class.new(Bundler::Thor))
|
||||
new_klass = klass.const_get(const_name)
|
||||
|
54
lib/bundler/vendor/thor/lib/thor/runner.rb
vendored
54
lib/bundler/vendor/thor/lib/thor/runner.rb
vendored
@ -2,12 +2,10 @@ require_relative "../thor"
|
||||
require_relative "group"
|
||||
|
||||
require "yaml"
|
||||
require "digest/md5"
|
||||
require "digest/sha2"
|
||||
require "pathname"
|
||||
|
||||
class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
|
||||
autoload :OpenURI, "open-uri"
|
||||
|
||||
class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
|
||||
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
||||
|
||||
def self.banner(command, all = false, subcommand = false)
|
||||
@ -45,25 +43,37 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
||||
|
||||
desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
|
||||
method_options :as => :string, :relative => :boolean, :force => :boolean
|
||||
def install(name) # rubocop:disable MethodLength
|
||||
def install(name) # rubocop:disable Metrics/MethodLength
|
||||
initialize_thorfiles
|
||||
|
||||
# If a directory name is provided as the argument, look for a 'main.thor'
|
||||
# command in said directory.
|
||||
begin
|
||||
if File.directory?(File.expand_path(name))
|
||||
base = File.join(name, "main.thor")
|
||||
package = :directory
|
||||
contents = open(base, &:read)
|
||||
else
|
||||
base = name
|
||||
package = :file
|
||||
contents = open(name, &:read)
|
||||
is_uri = name =~ %r{^https?\://}
|
||||
|
||||
if is_uri
|
||||
base = name
|
||||
package = :file
|
||||
require "open-uri"
|
||||
begin
|
||||
contents = URI.send(:open, name, &:read) # Using `send` for Ruby 2.4- support
|
||||
rescue OpenURI::HTTPError
|
||||
raise Error, "Error opening URI '#{name}'"
|
||||
end
|
||||
else
|
||||
# If a directory name is provided as the argument, look for a 'main.thor'
|
||||
# command in said directory.
|
||||
begin
|
||||
if File.directory?(File.expand_path(name))
|
||||
base = File.join(name, "main.thor")
|
||||
package = :directory
|
||||
contents = File.open(base, &:read)
|
||||
else
|
||||
base = name
|
||||
package = :file
|
||||
require "open-uri"
|
||||
contents = URI.send(:open, name, &:read) # for ruby 2.1-2.4
|
||||
end
|
||||
rescue Errno::ENOENT
|
||||
raise Error, "Error opening file '#{name}'"
|
||||
end
|
||||
rescue OpenURI::HTTPError
|
||||
raise Error, "Error opening URI '#{name}'"
|
||||
rescue Errno::ENOENT
|
||||
raise Error, "Error opening file '#{name}'"
|
||||
end
|
||||
|
||||
say "Your Thorfile contains:"
|
||||
@ -84,14 +94,14 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
||||
as = basename if as.empty?
|
||||
end
|
||||
|
||||
location = if options[:relative] || name =~ %r{^https?://}
|
||||
location = if options[:relative] || is_uri
|
||||
name
|
||||
else
|
||||
File.expand_path(name)
|
||||
end
|
||||
|
||||
thor_yaml[as] = {
|
||||
:filename => Digest::MD5.hexdigest(name + as),
|
||||
:filename => Digest::SHA256.hexdigest(name + as),
|
||||
:location => location,
|
||||
:namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class Bundler::Thor
|
||||
# indent<Integer>:: Indent the first column by indent value.
|
||||
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
||||
#
|
||||
def print_table(array, options = {}) # rubocop:disable MethodLength
|
||||
def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
|
||||
return if array.empty?
|
||||
|
||||
formats = []
|
||||
|
@ -105,7 +105,7 @@ class Bundler::Thor
|
||||
end
|
||||
|
||||
def are_colors_disabled?
|
||||
!ENV['NO_COLOR'].nil?
|
||||
!ENV['NO_COLOR'].nil? && !ENV['NO_COLOR'].empty?
|
||||
end
|
||||
|
||||
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
||||
|
8
lib/bundler/vendor/thor/lib/thor/util.rb
vendored
8
lib/bundler/vendor/thor/lib/thor/util.rb
vendored
@ -90,7 +90,7 @@ class Bundler::Thor
|
||||
def snake_case(str)
|
||||
return str.downcase if str =~ /^[A-Z_]+$/
|
||||
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
|
||||
$+.downcase
|
||||
Regexp.last_match(-1).downcase
|
||||
end
|
||||
|
||||
# Receives a string and convert it to camel case. camel_case returns CamelCase.
|
||||
@ -150,7 +150,7 @@ class Bundler::Thor
|
||||
# inside the sandbox to avoid namespacing conflicts.
|
||||
#
|
||||
def load_thorfile(path, content = nil, debug = false)
|
||||
content ||= File.binread(path)
|
||||
content ||= File.read(path)
|
||||
|
||||
begin
|
||||
Bundler::Thor::Sandbox.class_eval(content, path)
|
||||
@ -189,7 +189,7 @@ class Bundler::Thor
|
||||
# Returns the root where thor files are located, depending on the OS.
|
||||
#
|
||||
def thor_root
|
||||
File.join(user_home, ".thor").tr('\\', "/")
|
||||
File.join(user_home, ".thor").tr("\\", "/")
|
||||
end
|
||||
|
||||
# Returns the files in the thor root. On Windows thor_root will be something
|
||||
@ -236,7 +236,7 @@ class Bundler::Thor
|
||||
# symlink points to 'ruby_install_name'
|
||||
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
||||
end
|
||||
rescue NotImplementedError # rubocop:disable HandleExceptions
|
||||
rescue NotImplementedError # rubocop:disable Lint/HandleExceptions
|
||||
# just ignore on windows
|
||||
end
|
||||
end
|
||||
|
2
lib/bundler/vendor/thor/lib/thor/version.rb
vendored
2
lib/bundler/vendor/thor/lib/thor/version.rb
vendored
@ -1,3 +1,3 @@
|
||||
class Bundler::Thor
|
||||
VERSION = "1.2.1"
|
||||
VERSION = "1.2.2"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user