diff options
-rw-r--r-- | Rakefile | 23 | ||||
-rw-r--r-- | lib/bundler/vendor/.document | 0 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor.rb (renamed from lib/bundler/vendor/thor.rb) | 110 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb (renamed from lib/bundler/vendor/thor/actions.rb) | 68 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb (renamed from lib/bundler/vendor/thor/actions/create_file.rb) | 14 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb (renamed from lib/bundler/vendor/thor/actions/create_link.rb) | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb (renamed from lib/bundler/vendor/thor/actions/directory.rb) | 22 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb (renamed from lib/bundler/vendor/thor/actions/empty_directory.rb) | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb (renamed from lib/bundler/vendor/thor/actions/file_manipulation.rb) | 28 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb (renamed from lib/bundler/vendor/thor/actions/inject_into_file.rb) | 48 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb (renamed from lib/bundler/vendor/thor/base.rb) | 142 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb (renamed from lib/bundler/vendor/thor/command.rb) | 16 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb (renamed from lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb) | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb (renamed from lib/bundler/vendor/thor/core_ext/io_binary_read.rb) | 2 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb (renamed from lib/bundler/vendor/thor/core_ext/ordered_hash.rb) | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb (renamed from lib/bundler/vendor/thor/error.rb) | 6 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb (renamed from lib/bundler/vendor/thor/group.rb) | 54 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb (renamed from lib/bundler/vendor/thor/invocation.rb) | 27 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb | 17 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb (renamed from lib/bundler/vendor/thor/line_editor/basic.rb) | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb (renamed from lib/bundler/vendor/thor/line_editor/readline.rb) | 14 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb (renamed from lib/bundler/vendor/thor/parser/argument.rb) | 14 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb (renamed from lib/bundler/vendor/thor/parser/arguments.rb) | 20 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb (renamed from lib/bundler/vendor/thor/parser/option.rb) | 24 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb (renamed from lib/bundler/vendor/thor/parser/options.rb) | 24 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb (renamed from lib/bundler/vendor/thor/rake_compat.rb) | 28 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb (renamed from lib/bundler/vendor/thor/runner.rb) | 152 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb (renamed from lib/bundler/vendor/thor/shell.rb) | 36 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb (renamed from lib/bundler/vendor/thor/shell/basic.rb) | 61 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb (renamed from lib/bundler/vendor/thor/shell/color.rb) | 20 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb (renamed from lib/bundler/vendor/thor/shell/html.rb) | 56 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb (renamed from lib/bundler/vendor/thor/util.rb) | 122 | ||||
-rw-r--r-- | lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb | 3 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/line_editor.rb | 17 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/parser.rb | 4 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/version.rb | 3 | ||||
-rw-r--r-- | lib/bundler/vendored_thor.rb | 9 |
38 files changed, 621 insertions, 587 deletions
@@ -50,6 +50,29 @@ namespace :molinillo do end end +namespace :thor do + task :namespace do + files = Dir.glob('lib/bundler/vendor/thor*/**/*.rb') + sh "sed -i.bak 's/Thor/Bundler::Thor/g' #{files.join(' ')}" + sh "rm #{files.join('.bak ')}.bak" + end + + task :clean do + files = Dir.glob('lib/bundler/vendor/thor*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last } + puts files + sh "rm -r #{files.join(' ')}" + end + + task :update, [:tag] => [] do |t, args| + tag = args[:tag] + Dir.chdir 'lib/bundler/vendor' do + `curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz` + end + Rake::Task['thor:namespace'].invoke + Rake::Task['thor:clean'].invoke + end +end + namespace :spec do desc "Ensure spec dependencies are installed" task :deps do diff --git a/lib/bundler/vendor/.document b/lib/bundler/vendor/.document deleted file mode 100644 index e69de29bb2..0000000000 --- a/lib/bundler/vendor/.document +++ /dev/null diff --git a/lib/bundler/vendor/thor.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor.rb index e315a381e3..8775d6a3e0 100644 --- a/lib/bundler/vendor/thor.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor.rb @@ -1,7 +1,7 @@ -require 'set' -require 'thor/base' +require "set" +require "thor/base" -class Thor # rubocop:disable ClassLength +class Bundler::Thor # rubocop:disable ClassLength class << self # Allows for custom "Command" package naming. # @@ -10,7 +10,7 @@ class Thor # rubocop:disable ClassLength # options<Hash> # def package_name(name, options = {}) - @package_name = name.nil? || name == '' ? nil : name + @package_name = name.nil? || name == "" ? nil : name end # Sets the default command when thor is executed without an explicit command to be called. @@ -20,22 +20,22 @@ class Thor # rubocop:disable ClassLength # def default_command(meth = nil) if meth - @default_command = meth == :none ? 'help' : meth.to_s + @default_command = meth == :none ? "help" : meth.to_s else - @default_command ||= from_superclass(:default_command, 'help') + @default_command ||= from_superclass(:default_command, "help") end end alias_method :default_task, :default_command - # Registers another Thor subclass as a command. + # Registers another Bundler::Thor subclass as a command. # # ==== Parameters - # klass<Class>:: Thor subclass to register + # klass<Class>:: Bundler::Thor subclass to register # command<String>:: Subcommand name to use # usage<String>:: Short usage for the subcommand # description<String>:: Description for the subcommand def register(klass, subcommand_name, usage, description, options = {}) - if klass <= Thor::Group + if klass <= Bundler::Thor::Group desc usage, description, options define_method(subcommand_name) { |*args| invoke(klass, args) } else @@ -147,10 +147,10 @@ class Thor # rubocop:disable ClassLength # def method_option(name, options = {}) scope = if options[:for] - find_and_refresh_command(options[:for]).options - else - method_options - end + find_and_refresh_command(options[:for]).options + else + method_options + end build_option(name, options, scope) end @@ -159,7 +159,7 @@ class Thor # rubocop:disable ClassLength # Prints help information for the given command. # # ==== Parameters - # shell<Thor::Shell> + # shell<Bundler::Thor::Shell> # command_name<String> # def command_help(shell, command_name) @@ -167,12 +167,12 @@ class Thor # rubocop:disable ClassLength command = all_commands[meth] handle_no_command_error(meth) unless command - shell.say 'Usage:' + shell.say "Usage:" shell.say " #{banner(command)}" shell.say class_options_help(shell, nil => command.options.map { |_, o| o }) if command.long_description - shell.say 'Description:' + shell.say "Description:" shell.print_wrapped(command.long_description, :indent => 2) else shell.say command.description @@ -183,11 +183,11 @@ class Thor # rubocop:disable ClassLength # Prints help information for this class. # # ==== Parameters - # shell<Thor::Shell> + # shell<Bundler::Thor::Shell> # def help(shell, subcommand = false) list = printable_commands(true, subcommand) - Thor::Util.thor_classes_in(self).each do |klass| + Bundler::Thor::Util.thor_classes_in(self).each do |klass| list += klass.printable_commands(false) end list.sort! { |a, b| a[0] <=> b[0] } @@ -195,7 +195,7 @@ class Thor # rubocop:disable ClassLength if defined?(@package_name) && @package_name shell.say "#{@package_name} commands:" else - shell.say 'Commands:' + shell.say "Commands:" end shell.print_table(list, :indent => 2, :truncate => true) @@ -209,7 +209,7 @@ class Thor # rubocop:disable ClassLength next if command.hidden? item = [] item << banner(command, false, subcommand) - item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : '') + item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : "") item end.compact end @@ -220,12 +220,17 @@ class Thor # rubocop:disable ClassLength end alias_method :subtasks, :subcommands + def subcommand_classes + @subcommand_classes ||= {} + end + def subcommand(subcommand, subcommand_class) subcommands << subcommand.to_s subcommand_class.subcommand_help subcommand + subcommand_classes[subcommand.to_s] = subcommand_class define_method(subcommand) do |*args| - args, opts = Thor::Arguments.split(args) + args, opts = Bundler::Thor::Arguments.split(args) args.unshift("help") if opts.include? "--help" or opts.include? "-h" invoke subcommand_class, args, opts, :invoked_via_subcommand => true, :class_options => options end @@ -273,14 +278,14 @@ class Thor # rubocop:disable ClassLength # argument is encountered. All remaining arguments are passed to the command. # This is useful if you have a command that can receive arbitrary additional # options, and where those additional options should not be handled by - # Thor. + # Bundler::Thor. # # ==== Example # # To better understand how this is useful, let's consider a command that calls # an external command. A user may want to pass arbitrary options and # arguments to that command. The command itself also accepts some options, - # which should be handled by Thor. + # which should be handled by Bundler::Thor. # # class_option "verbose", :type => :boolean # stop_on_unknown_option! :exec @@ -321,27 +326,18 @@ class Thor # rubocop:disable ClassLength # The method responsible for dispatching given the args. def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength - # There is an edge case when dispatching from a subcommand. - # A problem occurs invoking the default command. This case occurs - # when arguments are passed and a default command is defined, and - # the first given_args does not match the default command. - # Thor use "help" by default so we skip that case. - # Note the call to retrieve_command_name. It's called with - # given_args.dup since that method calls args.shift. Then lookup - # the command normally. If the first item in given_args is not - # a command then use the default command. The given_args will be - # intact later since dup was used. - if config[:invoked_via_subcommand] && given_args.size >= 1 && default_command != 'help' && given_args.first != default_command - meth ||= retrieve_command_name(given_args.dup) - command = all_commands[normalize_command_name(meth)] - command ||= all_commands[normalize_command_name(default_command)] - else - meth ||= retrieve_command_name(given_args) - command = all_commands[normalize_command_name(meth)] + meth ||= retrieve_command_name(given_args) + command = all_commands[normalize_command_name(meth)] + + if !command && config[:invoked_via_subcommand] + # We're a subcommand and our first argument didn't match any of our + # commands. So we put it back and call our default command. + given_args.unshift(meth) + command = all_commands[normalize_command_name(default_command)] end if command - args, opts = Thor::Options.split(given_args) + args, opts = Bundler::Thor::Options.split(given_args) if stop_on_unknown_option?(command) && !args.empty? # given_args starts with a non-option, so we treat everything as # ordinary arguments @@ -364,7 +360,7 @@ class Thor # rubocop:disable ClassLength end # The banner for this class. You can customize it if you are invoking the - # thor class by another ways which is not the Thor::Runner. It receives + # thor class by another ways which is not the Bundler::Thor::Runner. It receives # the command that is going to be invoked and a boolean which indicates if # the namespace should be displayed as arguments. # @@ -373,11 +369,11 @@ class Thor # rubocop:disable ClassLength end def baseclass #:nodoc: - Thor + Bundler::Thor end def dynamic_command_class #:nodoc: - Thor::DynamicCommand + Bundler::Thor::DynamicCommand end def create_command(meth) #:nodoc: @@ -386,15 +382,15 @@ class Thor # rubocop:disable ClassLength @long_desc ||= nil if @usage && @desc - base_class = @hide ? Thor::HiddenCommand : Thor::Command + base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options) @usage, @desc, @long_desc, @method_options, @hide = nil true - elsif all_commands[meth] || meth == 'method_missing' + elsif all_commands[meth] || meth == "method_missing" true else puts "[WARNING] Attempted to create command #{meth.inspect} without usage or description. " << - 'Call desc if you want this method to be available as command or declare it inside a ' << + "Call desc if you want this method to be available as command or declare it inside a " << "no_commands{} block. Invoked from #{caller[1].inspect}." false end @@ -425,7 +421,7 @@ class Thor # rubocop:disable ClassLength # +normalize_command_name+ also converts names like +animal-prison+ # into +animal_prison+. def normalize_command_name(meth) #:nodoc: - return default_command.to_s.gsub('-', '_') unless meth + return default_command.to_s.gsub("-", "_") unless meth possibilities = find_command_possibilities(meth) if possibilities.size > 1 @@ -438,7 +434,7 @@ class Thor # rubocop:disable ClassLength meth = possibilities.first end - meth.to_s.gsub('-', '_') # treat foo-bar as foo_bar + meth.to_s.gsub("-", "_") # treat foo-bar as foo_bar end alias_method :normalize_task_name, :normalize_command_name @@ -461,7 +457,7 @@ class Thor # rubocop:disable ClassLength alias_method :find_task_possibilities, :find_command_possibilities def subcommand_help(cmd) - desc 'help [COMMAND]', 'Describe subcommands or one specific subcommand' + desc "help [COMMAND]", "Describe subcommands or one specific subcommand" class_eval " def help(command = nil, subcommand = true); super; end " @@ -469,12 +465,20 @@ class Thor # rubocop:disable ClassLength alias_method :subtask_help, :subcommand_help end - include Thor::Base + include Bundler::Thor::Base map HELP_MAPPINGS => :help - desc 'help [COMMAND]', 'Describe available commands or one specific command' + desc "help [COMMAND]", "Describe available commands or one specific command" def help(command = nil, subcommand = false) - command ? self.class.command_help(shell, command) : self.class.help(shell, subcommand) + if command + if self.class.subcommands.include? command + self.class.subcommand_classes[command].help(shell, true) + else + self.class.command_help(shell, command) + end + else + self.class.help(shell, subcommand) + end end end diff --git a/lib/bundler/vendor/thor/actions.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb index 617ccebb27..7edc70f472 100644 --- a/lib/bundler/vendor/thor/actions.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb @@ -1,14 +1,14 @@ -require 'fileutils' -require 'uri' -require 'thor/core_ext/io_binary_read' -require 'thor/actions/create_file' -require 'thor/actions/create_link' -require 'thor/actions/directory' -require 'thor/actions/empty_directory' -require 'thor/actions/file_manipulation' -require 'thor/actions/inject_into_file' - -class Thor +require "fileutils" +require "uri" +require "thor/core_ext/io_binary_read" +require "thor/actions/create_file" +require "thor/actions/create_link" +require "thor/actions/directory" +require "thor/actions/empty_directory" +require "thor/actions/file_manipulation" +require "thor/actions/inject_into_file" + +class Bundler::Thor module Actions attr_accessor :behavior @@ -17,7 +17,7 @@ class Thor end module ClassMethods - # Hold source paths for one Thor instance. source_paths_for_search is the + # Hold source paths for one Bundler::Thor instance. source_paths_for_search is the # method responsible to gather source_paths from this current class, # inherited paths and the source root. # @@ -48,17 +48,17 @@ class Thor # Add runtime options that help actions execution. # def add_runtime_options! - class_option :force, :type => :boolean, :aliases => '-f', :group => :runtime, - :desc => 'Overwrite files that already exist' + class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime, + :desc => "Overwrite files that already exist" - class_option :pretend, :type => :boolean, :aliases => '-p', :group => :runtime, - :desc => 'Run but do not make any changes' + class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime, + :desc => "Run but do not make any changes" - class_option :quiet, :type => :boolean, :aliases => '-q', :group => :runtime, - :desc => 'Suppress status output' + class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime, + :desc => "Suppress status output" - class_option :skip, :type => :boolean, :aliases => '-s', :group => :runtime, - :desc => 'Skip files that already exist' + class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime, + :desc => "Skip files that already exist" end end @@ -73,10 +73,10 @@ class Thor # def initialize(args = [], options = {}, config = {}) self.behavior = case config[:behavior].to_s - when 'force', 'skip' + when "force", "skip" _cleanup_options_and_set(options, config[:behavior]) :invoke - when 'revoke' + when "revoke" :revoke else :invoke @@ -106,7 +106,7 @@ class Thor # def destination_root=(root) @destination_stack ||= [] - @destination_stack[0] = File.expand_path(root || '') + @destination_stack[0] = File.expand_path(root || "") end # Returns the given path relative to the absolute root (ie, root where @@ -114,8 +114,8 @@ class Thor # def relative_to_original_destination_root(path, remove_dot = true) path = path.dup - if path.gsub!(@destination_stack[0], '.') - remove_dot ? (path[2..-1] || '') : path + if path.gsub!(@destination_stack[0], ".") + remove_dot ? (path[2..-1] || "") : path else path end @@ -147,7 +147,7 @@ class Thor end if source_paths.empty? - message << 'Currently you have no source paths.' + message << "Currently you have no source paths." else message << "Your current source paths are: \n#{source_paths.join("\n")}" end @@ -164,7 +164,7 @@ class Thor # dir<String>:: the directory to move to. # config<Hash>:: give :verbose => true to log and use padding. # - def inside(dir = '', config = {}, &block) + def inside(dir = "", config = {}, &block) verbose = config.fetch(:verbose, false) pretend = options[:pretend] @@ -215,7 +215,7 @@ class Thor shell.padding += 1 if verbose if is_uri - contents = open(path, 'Accept' => 'application/x-thor-template') { |io| io.read } + contents = open(path, "Accept" => "application/x-thor-template") { |io| io.read } else contents = open(path) { |io| io.read } end @@ -263,7 +263,7 @@ class Thor # def run_ruby_script(command, config = {}) return unless behavior == :invoke - run command, config.merge(:with => Thor::Util.ruby_command) + run command, config.merge(:with => Bundler::Thor::Util.ruby_command) end # Run a thor command. A hash of options can be given and it's converted to @@ -273,7 +273,7 @@ class Thor # command<String>:: the command to be invoked # args<Array>:: arguments to the command # config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output. - # Other options are given as parameter to Thor. + # Other options are given as parameter to Bundler::Thor. # # # ==== Examples @@ -291,8 +291,8 @@ class Thor capture = config.key?(:capture) ? config.delete(:capture) : false args.unshift(command) - args.push Thor::Options.to_switches(config) - command = args.join(' ').strip + args.push Bundler::Thor::Options.to_switches(config) + command = args.join(" ").strip run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture end @@ -308,10 +308,10 @@ class Thor def _cleanup_options_and_set(options, key) #:nodoc: case options when Array - %w(--force -f --skip -s).each { |i| options.delete(i) } + %w[--force -f --skip -s].each { |i| options.delete(i) } options << "--#{key}" when Hash - [:force, :skip, 'force', 'skip'].each { |i| options.delete(i) } + [:force, :skip, "force", "skip"].each { |i| options.delete(i) } options.merge!(key => true) end end diff --git a/lib/bundler/vendor/thor/actions/create_file.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb index 0436e6729d..711ccb7d7b 100644 --- a/lib/bundler/vendor/thor/actions/create_file.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb @@ -1,6 +1,6 @@ -require 'thor/actions/empty_directory' +require "thor/actions/empty_directory" -class Thor +class Bundler::Thor module Actions # Create a new file relative to the destination root with the given data, # which is the return value of a block or a data string. @@ -50,16 +50,16 @@ class Thor # def render @render ||= if data.is_a?(Proc) - data.call - else - data - end + data.call + else + data + end end def invoke! invoke_with_conflict_check do FileUtils.mkdir_p(File.dirname(destination)) - File.open(destination, 'wb') { |f| f.write render } + File.open(destination, "wb") { |f| f.write render } end given_destination end diff --git a/lib/bundler/vendor/thor/actions/create_link.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb index 799e5a208d..f633f25c18 100644 --- a/lib/bundler/vendor/thor/actions/create_link.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb @@ -1,6 +1,6 @@ -require 'thor/actions/create_file' +require "thor/actions/create_file" -class Thor +class Bundler::Thor module Actions # Create a new file relative to the destination root from the given source. # diff --git a/lib/bundler/vendor/thor/actions/directory.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb index 32d9c8d4af..3ed0649c27 100644 --- a/lib/bundler/vendor/thor/actions/directory.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb @@ -1,6 +1,6 @@ -require 'thor/actions/empty_directory' +require "thor/actions/empty_directory" -class Thor +class Bundler::Thor module Actions # Copies recursively the files from source directory to root directory. # If any of the files finishes with .tt, it's considered to be a template @@ -29,9 +29,9 @@ class Thor # rdoc.rb # blog.rb # - # <b>Encoded path note:</b> Since Thor internals use Object#respond_to? to check if it can + # <b>Encoded path note:</b> Since Bundler::Thor internals use Object#respond_to? to check if it can # expand %something%, this `something` should be a public method in the class calling - # #directory. If a method is private, Thor stack raises PrivateMethodEncodedError. + # #directory. If a method is private, Bundler::Thor stack raises PrivateMethodEncodedError. # # ==== Parameters # source<String>:: the relative path to the source root. @@ -74,18 +74,18 @@ class Thor def execute! # rubocop:disable MethodLength lookup = Util.escape_globs(source) - lookup = config[:recursive] ? File.join(lookup, '**') : lookup + lookup = config[:recursive] ? File.join(lookup, "**") : lookup lookup = file_level_lookup(lookup) files(lookup).sort.each do |file_source| next if File.directory?(file_source) next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern]) - file_destination = File.join(given_destination, file_source.gsub(source, '.')) - file_destination.gsub!('/./', '/') + file_destination = File.join(given_destination, file_source.gsub(source, ".")) + file_destination.gsub!("/./", "/") case file_source when /\.empty_directory$/ - dirname = File.dirname(file_destination).gsub(/\/\.$/, '') + dirname = File.dirname(file_destination).gsub(/\/\.$/, "") next if dirname == given_destination base.empty_directory(dirname, config) when /#{TEMPLATE_EXTNAME}$/ @@ -96,9 +96,9 @@ class Thor end end - if RUBY_VERSION < '2.0' + if RUBY_VERSION < "2.0" def file_level_lookup(previous_lookup) - File.join(previous_lookup, '{*,.[a-z]*}') + File.join(previous_lookup, "{*,.[a-z]*}") end def files(lookup) @@ -106,7 +106,7 @@ class Thor end else def file_level_lookup(previous_lookup) - File.join(previous_lookup, '*') + File.join(previous_lookup, "*") end def files(lookup) diff --git a/lib/bundler/vendor/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb index 281d8fb2f4..cdc3768b4c 100644 --- a/lib/bundler/vendor/thor/actions/empty_directory.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor module Actions # Creates an empty directory. # @@ -26,7 +26,7 @@ class Thor # Initializes given the source and destination. # # ==== Parameters - # base<Thor::Base>:: A Thor::Base instance + # base<Bundler::Thor::Base>:: A Bundler::Thor::Base instance # source<String>:: Relative path to the source of this file # destination<String>:: Relative path to the destination of this file # config<Hash>:: give :verbose => false to not log the status. diff --git a/lib/bundler/vendor/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb index 6ccc345fa7..2bdc78f578 100644 --- a/lib/bundler/vendor/thor/actions/file_manipulation.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb @@ -1,7 +1,7 @@ -require 'erb' -require 'open-uri' +require "erb" +require "open-uri" -class Thor +class Bundler::Thor module Actions # Copies the file from the relative source to the relative destination. If # the destination is not given it's assumed to be equal to the source. @@ -82,10 +82,10 @@ class Thor render = open(source) { |input| input.binmode.read } destination ||= if block_given? - block.arity == 1 ? block.call(render) : block.call - else - File.basename(source) - end + block.arity == 1 ? block.call(render) : block.call + else + File.basename(source) + end create_file destination, render, config end @@ -107,13 +107,13 @@ class Thor # def template(source, *args, &block) config = args.last.is_a?(Hash) ? args.pop : {} - destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, '') + destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, "") source = File.expand_path(find_in_source_paths(source.to_s)) - context = instance_eval('binding') + context = instance_eval("binding") create_file destination, nil, config do - content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context) + content = ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context) content = block.call(content) if block content end @@ -230,7 +230,7 @@ class Thor unless options[:pretend] content = File.binread(path) content.gsub!(flag, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } + File.open(path, "wb") { |file| file.write(content) } end end @@ -292,8 +292,8 @@ class Thor end alias_method :remove_dir, :remove_file - attr_accessor :output_buffer - private :output_buffer, :output_buffer= + attr_accessor :output_buffer + private :output_buffer, :output_buffer= private @@ -305,7 +305,7 @@ class Thor with_output_buffer { block.call(*args) } end - def with_output_buffer(buf = '') #:nodoc: + def with_output_buffer(buf = "") #:nodoc: self.output_buffer, old_buffer = buf, output_buffer yield output_buffer diff --git a/lib/bundler/vendor/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb index 3cdd18b578..45a70701b1 100644 --- a/lib/bundler/vendor/thor/actions/inject_into_file.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb @@ -1,6 +1,6 @@ -require 'thor/actions/empty_directory' +require "thor/actions/empty_directory" -class Thor +class Bundler::Thor module Actions # Injects the given content into a file. Different from gsub_file, this # method is reversible. @@ -38,7 +38,7 @@ class Thor super(base, destination, {:verbose => true}.merge(config)) @behavior, @flag = if @config.key?(:after) - [:after, @config.delete(:after)] + [:after, @config.delete(:after)] else [:before, @config.delete(:before)] end @@ -51,10 +51,10 @@ class Thor say_status :invoke content = if @behavior == :after - '\0' + replacement - else - replacement + '\0' - end + '\0' + replacement + else + replacement + '\0' + end replace!(/#{flag}/, content, config[:force]) end @@ -63,12 +63,12 @@ class Thor say_status :revoke regexp = if @behavior == :after - content = '\1\2' - /(#{flag})(.*)(#{Regexp.escape(replacement)})/m - else - content = '\2\3' - /(#{Regexp.escape(replacement)})(.*)(#{flag})/m - end + content = '\1\2' + /(#{flag})(.*)(#{Regexp.escape(replacement)})/m + else + content = '\2\3' + /(#{Regexp.escape(replacement)})(.*)(#{flag})/m + end replace!(regexp, content, true) end @@ -77,16 +77,16 @@ class Thor def say_status(behavior) status = if behavior == :invoke - if flag == /\A/ - :prepend - elsif flag == /\z/ - :append - else - :insert - end - else - :subtract - end + if flag == /\A/ + :prepend + elsif flag == /\z/ + :append + else + :insert + end + else + :subtract + end super(status, config[:verbose]) end @@ -98,7 +98,7 @@ class Thor content = File.binread(destination) if force || !content.include?(replacement) content.gsub!(regexp, string) - File.open(destination, 'wb') { |file| file.write(content) } + File.open(destination, "wb") { |file| file.write(content) } end end end diff --git a/lib/bundler/vendor/thor/base.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb index d42ff4dd5e..56b78ebad6 100644 --- a/lib/bundler/vendor/thor/base.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb @@ -1,26 +1,26 @@ -require 'thor/command' -require 'thor/core_ext/hash_with_indifferent_access' -require 'thor/core_ext/ordered_hash' -require 'thor/error' -require 'thor/invocation' -require 'thor/parser' -require 'thor/shell' -require 'thor/line_editor' -require 'thor/util' - -class Thor - autoload :Actions, 'thor/actions' - autoload :RakeCompat, 'thor/rake_compat' - autoload :Group, 'thor/group' +require "thor/command" +require "thor/core_ext/hash_with_indifferent_access" +require "thor/core_ext/ordered_hash" +require "thor/error" +require "thor/invocation" +require "thor/parser" +require "thor/shell" +require "thor/line_editor" +require "thor/util" + +class Bundler::Thor + autoload :Actions, "thor/actions" + autoload :RakeCompat, "thor/rake_compat" + autoload :Group, "thor/group" # Shortcuts for help. - HELP_MAPPINGS = %w(-h -? --help -D) + HELP_MAPPINGS = %w[-h -? --help -D] - # Thor methods that should not be overwritten by the user. - THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root - action add_file create_file in_root inside run run_ruby_script) + # Bundler::Thor methods that should not be overwritten by the user. + THOR_RESERVED_WORDS = %w[invoke shell options behavior root destination_root relative_root + action add_file create_file in_root inside run run_ruby_script] - TEMPLATE_EXTNAME = '.tt' + TEMPLATE_EXTNAME = ".tt" module Base attr_accessor :options, :parent_options, :args @@ -39,7 +39,7 @@ class Thor # The hash given is converted to a hash with indifferent # access, magic predicates (options.skip?) and then frozen. # - # config<Hash>:: Configuration for this Thor class. + # config<Hash>:: Configuration for this Bundler::Thor class. # def initialize(args = [], local_options = {}, config = {}) # rubocop:disable MethodLength parse_options = self.class.class_options @@ -59,11 +59,11 @@ class Thor array_options, hash_options = [], local_options end - # Let Thor::Options parse the options first, so it can remove + # Let Bundler::Thor::Options parse the options first, so it can remove # declared options from the array. This will leave us with # a list of arguments that weren't declared. stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command] - opts = Thor::Options.new(parse_options, hash_options, stop_on_unknown) + opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown) self.options = opts.parse(array_options) self.options = config[:class_options].merge(options) if config[:class_options] @@ -74,12 +74,12 @@ class Thor # Add the remaining arguments from the options parser to the # arguments passed in to initialize. Then remove any positional # arguments declared using #argument (this is primarily used - # by Thor::Group). Tis will leave us with the remaining + # by Bundler::Thor::Group). Tis will leave us with the remaining # positional arguments. to_parse = args to_parse += opts.remaining unless self.class.strict_args_position?(config) - thor_args = Thor::Arguments.new(self.class.arguments) + thor_args = Bundler::Thor::Arguments.new(self.class.arguments) thor_args.parse(to_parse).each { |k, v| __send__("#{k}=", v) } @args = thor_args.remaining end @@ -91,7 +91,7 @@ class Thor base.send :include, Shell end - # Returns the classes that inherits from Thor or Thor::Group. + # Returns the classes that inherits from Bundler::Thor or Bundler::Thor::Group. # # ==== Returns # Array[Class] @@ -109,14 +109,14 @@ class Thor @subclass_files ||= Hash.new { |h, k| h[k] = [] } end - # Whenever a class inherits from Thor or Thor::Group, we should track the - # class and the file on Thor::Base. This is the method responsible for it. + # Whenever a class inherits from Bundler::Thor or Bundler::Thor::Group, we should track the + # class and the file on Bundler::Thor::Base. This is the method responsable for it. # def register_klass_file(klass) #:nodoc: file = caller[1].match(/(.*):\d+/)[1] - Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass) + Bundler::Thor::Base.subclasses << klass unless Bundler::Thor::Base.subclasses.include?(klass) - file_subclasses = Thor::Base.subclass_files[File.expand_path(file)] + file_subclasses = Bundler::Thor::Base.subclass_files[File.expand_path(file)] file_subclasses << klass unless file_subclasses.include?(klass) end end @@ -210,12 +210,12 @@ class Thor no_commands { attr_accessor name } required = if options.key?(:optional) - !options[:optional] - elsif options.key?(:required) - options[:required] - else - options[:default].nil? - end + !options[:optional] + elsif options.key?(:required) + options[:required] + else + options[:default].nil? + end remove_argument name @@ -227,13 +227,13 @@ class Thor options[:required] = required - arguments << Thor::Argument.new(name, options) + arguments << Bundler::Thor::Argument.new(name, options) end # Returns this class arguments, looking up in the ancestors chain. # # ==== Returns - # Array[Thor::Argument] + # Array[Bundler::Thor::Argument] # def arguments @arguments ||= from_superclass(:arguments, []) @@ -265,7 +265,7 @@ class Thor # :required:: -- If the argument is required or not. # :default:: -- Default value for this argument. # :group:: -- The group for this options. Use by class options to output options in different levels. - # :aliases:: -- Aliases for this option. <b>Note:</b> Thor follows a convention of one-dash-one-letter options. Thus aliases like "-something" wouldn't be parsed; use either "\--something" or "-s" instead. + # :aliases:: -- Aliases for this option. <b>Note:</b> Bundler::Thor follows a convention of one-dash-one-letter options. Thus aliases like "-something" wouldn't be parsed; use either "\--something" or "-s" instead. # :type:: -- The type of the argument, can be :string, :hash, :array, :numeric or :boolean. # :banner:: -- String to show on usage notes. # :hide:: -- If you want to hide this option from the help. @@ -320,34 +320,34 @@ class Thor if name @group = name.to_s else - @group ||= from_superclass(:group, 'standard') + @group ||= from_superclass(:group, "standard") end end - # Returns the commands for this Thor class. + # Returns the commands for this Bundler::Thor class. # # ==== Returns - # OrderedHash:: An ordered hash with commands names as keys and Thor::Command + # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command # objects as values. # def commands - @commands ||= Thor::CoreExt::OrderedHash.new + @commands ||= Bundler::Thor::CoreExt::OrderedHash.new end alias_method :tasks, :commands - # Returns the commands for this Thor class and all subclasses. + # Returns the commands for this Bundler::Thor class and all subclasses. # # ==== Returns - # OrderedHash:: An ordered hash with commands names as keys and Thor::Command + # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command # objects as values. # def all_commands - @all_commands ||= from_superclass(:all_commands, Thor::CoreExt::OrderedHash.new) + @all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new) @all_commands.merge(commands) end alias_method :all_tasks, :all_commands - # Removes a given command from this Thor class. This is usually done if you + # Removes a given command from this Bundler::Thor class. This is usually done if you # are inheriting from another class and don't want it to be available # anymore. # @@ -374,7 +374,7 @@ class Thor # # So you can do: # - # class MyScript < Thor + # class MyScript < Bundler::Thor # no_commands do # def this_is_not_a_command # end @@ -383,7 +383,7 @@ class Thor # # You can also add the method and remove it from the command list: # - # class MyScript < Thor + # class MyScript < Bundler::Thor # def this_is_not_a_command # end # remove_command :this_is_not_a_command @@ -397,8 +397,8 @@ class Thor end alias_method :no_tasks, :no_commands - # Sets the namespace for the Thor or Thor::Group class. By default the - # namespace is retrieved from the class name. If your Thor class is named + # Sets the namespace for the Bundler::Thor or Bundler::Thor::Group class. By default the + # namespace is retrieved from the class name. If your Bundler::Thor class is named # Scripts::MyScript, the help method, for example, will be called as: # # thor scripts:my_script -h @@ -423,23 +423,23 @@ class Thor if name @namespace = name.to_s else - @namespace ||= Thor::Util.namespace_from_thor_class(self) + @namespace ||= Bundler::Thor::Util.namespace_from_thor_class(self) end end # Parses the command and options from the given args, instantiate the class # and invoke the command. This method is used when the arguments must be parsed - # from an array. If you are inside Ruby and want to use a Thor class, you + # from an array. If you are inside Ruby and want to use a Bundler::Thor class, you # can simply initialize it: # # script = MyScript.new(args, options, config) # script.invoke(:command, first_arg, second_arg, third_arg) # def start(given_args = ARGV, config = {}) - config[:shell] ||= Thor::Base.shell.new + config[:shell] ||= Bundler::Thor::Base.shell.new dispatch(nil, given_args.dup, nil, config) - rescue Thor::Error => e - config[:debug] || ENV['THOR_DEBUG'] == '1' ? (raise e) : config[:shell].error(e.message) + rescue Bundler::Thor::Error => e + config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message) exit(1) if exit_on_failure? rescue Errno::EPIPE # This happens if a thor command is piped to something like `head`, @@ -477,8 +477,8 @@ class Thor def handle_argument_error(command, error, args, arity) #:nodoc: msg = "ERROR: \"#{basename} #{command.name}\" was called with " - msg << 'no arguments' if args.empty? - msg << 'arguments ' << args.inspect unless args.empty? + msg << "no arguments" if args.empty? + msg << "arguments " << args.inspect unless args.empty? msg << "\nUsage: #{banner(command).inspect}" fail InvocationError, msg end @@ -515,23 +515,23 @@ class Thor options.each do |option| unless option.hide item = [option.usage(padding)] - item.push(option.description ? "# #{option.description}" : '') + item.push(option.description ? "# #{option.description}" : "") list << item - list << ['', "# Default: #{option.default}"] if option.show_default? - list << ['', "# Possible values: #{option.enum.join(', ')}"] if option.enum + list << ["", "# Default: #{option.default}"] if option.show_default? + list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum end end - shell.say(group_name ? "#{group_name} options:" : 'Options:') + shell.say(group_name ? "#{group_name} options:" : "Options:") shell.print_table(list, :indent => 2) - shell.say '' + shell.say "" end - # Raises an error if the word given is a Thor reserved word. + # Raises an error if the word given is a Bundler::Thor reserved word. def is_thor_reserved_word?(word, type) #:nodoc: return false unless THOR_RESERVED_WORDS.include?(word.to_s) - fail "#{word.inspect} is a Thor reserved word and cannot be defined as #{type}" + fail "#{word.inspect} is a Bundler::Thor reserved word and cannot be defined as #{type}" end # Build an option and adds it to the given scope. @@ -541,7 +541,7 @@ class Thor # options<Hash>:: Described in both class_option and method_option. # scope<Hash>:: Options hash that is being built up def build_option(name, options, scope) #:nodoc: - scope[name] = Thor::Option.new(name, options) + scope[name] = Bundler::Thor::Option.new(name, options) end # Receives a hash of options, parse them and add to the scope. This is a @@ -553,7 +553,7 @@ class Thor # Hash[Symbol => Object] def build_options(options, scope) #:nodoc: options.each do |key, value| - scope[key] = Thor::Option.parse(key, value) + scope[key] = Bundler::Thor::Option.parse(key, value) end end @@ -571,10 +571,10 @@ class Thor end alias_method :find_and_refresh_task, :find_and_refresh_command - # Everytime someone inherits from a Thor class, register the klass + # Everytime someone inherits from a Bundler::Thor class, register the klass # and file into baseclass. def inherited(klass) - Thor::Base.register_klass_file(klass) + Bundler::Thor::Base.register_klass_file(klass) klass.instance_variable_set(:@no_commands, false) end @@ -583,7 +583,7 @@ class Thor def method_added(meth) meth = meth.to_s - if meth == 'initialize' + if meth == "initialize" initialize_added return end @@ -595,7 +595,7 @@ class Thor return if @no_commands || !create_command(meth) is_thor_reserved_word?(meth, :command) - Thor::Base.register_klass_file(self) + Bundler::Thor::Base.register_klass_file(self) end # Retrieves a value from superclass. If it reaches the baseclass, @@ -628,7 +628,7 @@ class Thor # The basename of the program invoking the thor class. # def basename - File.basename($PROGRAM_NAME).split(' ').first + File.basename($PROGRAM_NAME).split(" ").first end # SIGNATURE: Sets the baseclass. This is where the superclass lookup diff --git a/lib/bundler/vendor/thor/command.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb index cada32b1f0..72c8348cb6 100644 --- a/lib/bundler/vendor/thor/command.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor class Command < Struct.new(:name, :description, :long_description, :usage, :options) FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/ @@ -45,12 +45,12 @@ class Thor end formatted = "#{klass.namespace.split(':').last} " if subcommand - formatted ||= '' + formatted ||= "" # Add usage with required arguments formatted << if klass && !klass.arguments.empty? usage.to_s.gsub(/^#{name}/) do |match| - match << ' ' << klass.arguments.map { |a| a.usage }.compact.join(' ') + match << " " << klass.arguments.map { |a| a.usage }.compact.join(" ") end else usage.to_s @@ -70,7 +70,7 @@ class Thor end def required_options - @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(' ') + @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(" ") end # Given a target, checks if this class name is a public method. @@ -88,15 +88,15 @@ class Thor end def sans_backtrace(backtrace, caller) #:nodoc: - saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) } + saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~ /^kernel\// && RUBY_ENGINE =~ /rbx/) } saned - caller end def handle_argument_error?(instance, error, caller) - not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin + not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin saned = sans_backtrace(error.backtrace, caller) # Ruby 1.9 always include the called method in the backtrace - saned.empty? || (saned.size == 1 && RUBY_VERSION >= '1.9') + saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9") end end @@ -118,7 +118,7 @@ class Thor # A dynamic command that handles method missing scenarios. class DynamicCommand < Command def initialize(name, options = nil) - super(name.to_s, 'A dynamically-generated command', name.to_s, name.to_s, options) + super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options) end def run(instance, args = []) diff --git a/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb index 35dbf070b8..6cf61db812 100644 --- a/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb @@ -1,8 +1,8 @@ -class Thor +class Bundler::Thor module CoreExt #:nodoc: # A hash with indifferent access and magic predicates. # - # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true + # hash = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true # # hash[:foo] #=> 'bar' # hash['foo'] #=> 'bar' diff --git a/lib/bundler/vendor/thor/core_ext/io_binary_read.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb index 496446f5e9..19f3c3d43e 100644 --- a/lib/bundler/vendor/thor/core_ext/io_binary_read.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb @@ -2,7 +2,7 @@ class IO #:nodoc: class << self def binread(file, *args) fail ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3 - File.open(file, 'rb') do |f| + File.open(file, "rb") do |f| f.read(*args) end end unless method_defined? :binread diff --git a/lib/bundler/vendor/thor/core_ext/ordered_hash.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb index 8ddeb9eae1..7e80672a07 100644 --- a/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb @@ -1,6 +1,6 @@ -class Thor +class Bundler::Thor module CoreExt #:nodoc: - if RUBY_VERSION >= '1.9' + if RUBY_VERSION >= "1.9" class OrderedHash < ::Hash end else diff --git a/lib/bundler/vendor/thor/error.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb index c53be49b41..fc34c11268 100644 --- a/lib/bundler/vendor/thor/error.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb @@ -1,9 +1,9 @@ -class Thor - # Thor::Error is raised when it's caused by wrong usage of thor classes. Those +class Bundler::Thor + # Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those # errors have their backtrace suppressed and are nicely shown to the user. # # Errors that are caused by the developer, like declaring a method which - # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we + # overwrites a thor keyword, it SHOULD NOT raise a Bundler::Thor::Error. This way, we # ensure that developer errors are shown with full backtrace. class Error < StandardError end diff --git a/lib/bundler/vendor/thor/group.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb index 231f8b1a05..71e7f1c3b8 100644 --- a/lib/bundler/vendor/thor/group.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb @@ -1,17 +1,17 @@ -require 'thor/base' +require "thor/base" -# Thor has a special class called Thor::Group. The main difference to Thor class +# Bundler::Thor has a special class called Bundler::Thor::Group. The main difference to Bundler::Thor class # is that it invokes all commands at once. It also include some methods that allows -# invocations to be done at the class method, which are not available to Thor +# invocations to be done at the class method, which are not available to Bundler::Thor # commands. -class Thor::Group # rubocop:disable ClassLength +class Bundler::Thor::Group # rubocop:disable ClassLength class << self - # The description for this Thor::Group. If none is provided, but a source root + # The description for this Bundler::Thor::Group. If none is provided, but a source root # exists, tries to find the USAGE one folder above it, otherwise searches # in the superclass. # # ==== Parameters - # description<String>:: The description for this Thor::Group. + # description<String>:: The description for this Bundler::Thor::Group. # def desc(description = nil) if description @@ -27,7 +27,7 @@ class Thor::Group # rubocop:disable ClassLength # short:: When true, shows only usage. # def help(shell) - shell.say 'Usage:' + shell.say "Usage:" shell.say " #{banner}\n" shell.say class_options_help(shell) @@ -62,7 +62,7 @@ class Thor::Group # rubocop:disable ClassLength invocation_blocks[name] = block if block_given? class_eval <<-METHOD, __FILE__, __LINE__ - def _invoke_#{name.to_s.gsub(/\W/, '_')} + def _invoke_#{name.to_s.gsub(/\W/, "_")} klass, command = self.class.prepare_for_invocation(nil, #{name.inspect}) if klass @@ -83,7 +83,7 @@ class Thor::Group # rubocop:disable ClassLength # # ==== Examples # - # class GemGenerator < Thor::Group + # class GemGenerator < Bundler::Thor::Group # class_option :test_framework, :type => :string # invoke_from_option :test_framework # end @@ -114,18 +114,18 @@ class Thor::Group # rubocop:disable ClassLength names.each do |name| unless class_options.key?(name) fail ArgumentError, "You have to define the option #{name.inspect} " << - 'before setting invoke_from_option.' + "before setting invoke_from_option." end invocations[name] = true invocation_blocks[name] = block if block_given? class_eval <<-METHOD, __FILE__, __LINE__ - def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')} + def _invoke_from_option_#{name.to_s.gsub(/\W/, "_")} return unless options[#{name.inspect}] value = options[#{name.inspect}] - value = #{name.inspect} if value.is_a?(TrueClass) + value = #{name.inspect} if TrueClass === value klass, command = self.class.prepare_for_invocation(#{name.inspect}, value) if klass @@ -172,11 +172,11 @@ class Thor::Group # rubocop:disable ClassLength def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength invocations.each do |name, from_option| value = if from_option - option = class_options[name] - option.type == :boolean ? name : option.default - else - name - end + option = class_options[name] + option.type == :boolean ? name : option.default + else + name + end next unless value klass, _ = prepare_for_invocation(name, value) @@ -199,15 +199,15 @@ class Thor::Group # rubocop:disable ClassLength def printable_commands(*) item = [] item << banner - item << (desc ? "# #{desc.gsub(/\s+/m, ' ')}" : '') + item << (desc ? "# #{desc.gsub(/\s+/m, ' ')}" : "") [item] end alias_method :printable_tasks, :printable_commands def handle_argument_error(command, error, args, arity) #:nodoc: msg = "#{basename} #{command.name} takes #{arity} argument" - msg << 's' if arity > 1 - msg << ', but it should not.' + msg << "s" if arity > 1 + msg << ", but it should not." fail error, msg end @@ -215,12 +215,12 @@ class Thor::Group # rubocop:disable ClassLength # The method responsible for dispatching given the args. def dispatch(command, given_args, given_opts, config) #:nodoc: - if Thor::HELP_MAPPINGS.include?(given_args.first) + if Bundler::Thor::HELP_MAPPINGS.include?(given_args.first) help(config[:shell]) return end - args, opts = Thor::Options.split(given_args) + args, opts = Bundler::Thor::Options.split(given_args) opts = given_opts || opts instance = new(args, opts, config) @@ -234,29 +234,29 @@ class Thor::Group # rubocop:disable ClassLength end # The banner for this class. You can customize it if you are invoking the - # thor class by another ways which is not the Thor::Runner. + # thor class by another ways which is not the Bundler::Thor::Runner. def banner "#{basename} #{self_command.formatted_usage(self, false)}" end # Represents the whole class as a command. def self_command #:nodoc: - Thor::DynamicCommand.new(namespace, class_options) + Bundler::Thor::DynamicCommand.new(namespace, class_options) end alias_method :self_task, :self_command def baseclass #:nodoc: - Thor::Group + Bundler::Thor::Group end def create_command(meth) #:nodoc: - commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil) + commands[meth.to_s] = Bundler::Thor::Command.new(meth, nil, nil, nil, nil) true end alias_method :create_task, :create_command end - include Thor::Base + include Bundler::Thor::Base protected diff --git a/lib/bundler/vendor/thor/invocation.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb index afe4cab01d..684df2c616 100644 --- a/lib/bundler/vendor/thor/invocation.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor module Invocation def self.included(base) #:nodoc: base.extend ClassMethods @@ -7,11 +7,11 @@ class Thor module ClassMethods # This method is responsible for receiving a name and find the proper # class and command for it. The key is an optional parameter which is - # available only in class methods invocations (i.e. in Thor::Group). + # available only in class methods invocations (i.e. in Bundler::Thor::Group). def prepare_for_invocation(key, name) #:nodoc: case name when Symbol, String - Thor::Util.find_class_and_command_by_namespace(name.to_s, !key) + Bundler::Thor::Util.find_class_and_command_by_namespace(name.to_s, !key) else name end @@ -25,8 +25,13 @@ class Thor super end + # Make the current command chain accessible with in a Bundler::Thor-(sub)command + def current_command_chain + @_invocations.values.flatten.map(&:to_sym) + end + # Receives a name and invokes it. The name can be a string (either "command" or - # "namespace:command"), a Thor::Command, a Class or a Thor instance. If the + # "namespace:command"), a Bundler::Thor::Command, a Class or a Bundler::Thor instance. If the # command cannot be guessed by name, it can also be supplied as second argument. # # You can also supply the arguments, options and configuration values for @@ -37,7 +42,7 @@ class Thor # # ==== Examples # - # class A < Thor + # class A < Bundler::Thor # def foo # invoke :bar # invoke "b:hello", ["Erik"] @@ -48,7 +53,7 @@ class Thor # end # end # - # class B < Thor + # class B < Bundler::Thor # def hello(name) # puts "hello #{name}" # end @@ -65,7 +70,7 @@ class Thor # supplied to B. This allows lazy parse of options. Let's suppose you have # some rspec commands: # - # class Rspec < Thor::Group + # class Rspec < Bundler::Thor::Group # class_option :mock_framework, :type => :string, :default => :rr # # def invoke_mock_framework @@ -76,7 +81,7 @@ class Thor # As you noticed, it invokes the given mock framework, which might have its # own options: # - # class Rspec::RR < Thor::Group + # class Rspec::RR < Bundler::Thor::Group # class_option :style, :type => :string, :default => :mock # end # @@ -95,7 +100,7 @@ class Thor # def invoke(name = nil, *args) if name.nil? - warn "[Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}" + warn "[Bundler::Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}" return invoke_all end @@ -103,8 +108,8 @@ class Thor command, args, opts, config = args klass, command = _retrieve_class_and_command(name, command) - fail "Missing Thor class for invoke #{name}" unless klass - fail "Expected Thor class, got #{klass}" unless klass <= Thor::Base + fail "Missing Bundler::Thor class for invoke #{name}" unless klass + fail "Expected Bundler::Thor class, got #{klass}" unless klass <= Bundler::Thor::Base args, opts, config = _parse_initialization_options(args, opts, config) klass.send(:dispatch, command, args, opts, config) do |instance| diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb new file mode 100644 index 0000000000..95c848e0e3 --- /dev/null +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb @@ -0,0 +1,17 @@ +require "thor/line_editor/basic" +require "thor/line_editor/readline" + +class Bundler::Thor + module LineEditor + def self.readline(prompt, options = {}) + best_available.new(prompt, options).readline + end + + def self.best_available + [ + Bundler::Thor::LineEditor::Readline, + Bundler::Thor::LineEditor::Basic + ].detect(&:available?) + end + end +end diff --git a/lib/bundler/vendor/thor/line_editor/basic.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb index 0084059320..b121e95575 100644 --- a/lib/bundler/vendor/thor/line_editor/basic.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor module LineEditor class Basic attr_reader :prompt, :options @@ -17,7 +17,7 @@ class Thor get_input end - private + private def get_input if echo? diff --git a/lib/bundler/vendor/thor/line_editor/readline.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb index c7973fa80b..dd39cff35d 100644 --- a/lib/bundler/vendor/thor/line_editor/readline.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb @@ -1,9 +1,9 @@ begin - require 'readline' + require "readline" rescue LoadError end -class Thor +class Bundler::Thor module LineEditor class Readline < Basic def self.available? @@ -23,7 +23,7 @@ class Thor end end - private + private def add_to_history? options.fetch(:add_to_history, true) @@ -31,9 +31,9 @@ class Thor def completion_proc if use_path_completion? - Proc.new { |text| PathCompletion.new(text).matches } + proc { |text| PathCompletion.new(text).matches } elsif completion_options.any? - Proc.new do |text| + proc do |text| completion_options.select { |option| option.start_with?(text) } end end @@ -59,10 +59,10 @@ class Thor relative_matches end - private + private def relative_matches - absolute_matches.map { |path| path.sub(base_path, '') } + absolute_matches.map { |path| path.sub(base_path, "") } end def absolute_matches diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb new file mode 100644 index 0000000000..74c789b763 --- /dev/null +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb @@ -0,0 +1,4 @@ +require "thor/parser/argument" +require "thor/parser/arguments" +require "thor/parser/option" +require "thor/parser/options" diff --git a/lib/bundler/vendor/thor/parser/argument.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb index baa75e4903..84957903cd 100644 --- a/lib/bundler/vendor/thor/parser/argument.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor class Argument #:nodoc: VALID_TYPES = [:numeric, :hash, :array, :string] @@ -6,7 +6,7 @@ class Thor alias_method :human_name, :name def initialize(name, options = {}) - class_name = self.class.name.split('::').last + class_name = self.class.name.split("::").last type = options[:type] @@ -45,9 +45,9 @@ class Thor def validate! if required? && !default.nil? - fail ArgumentError, 'An argument cannot be required and have default value.' + fail ArgumentError, "An argument cannot be required and have default value." elsif @enum && !@enum.is_a?(Array) - fail ArgumentError, 'An argument cannot have an enum other than an array.' + fail ArgumentError, "An argument cannot have an enum other than an array." end end @@ -62,11 +62,11 @@ class Thor when :string, :default human_name.upcase when :numeric - 'N' + "N" when :hash - 'key:value' + "key:value" when :array - 'one two three' + "one two three" end end end diff --git a/lib/bundler/vendor/thor/parser/arguments.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb index 1cdddcc7ee..c7bb648e31 100644 --- a/lib/bundler/vendor/thor/parser/arguments.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor class Arguments #:nodoc: # rubocop:disable ClassLength NUMERIC = /(\d*\.\d+|\d+)/ @@ -21,7 +21,7 @@ class Thor new(*args).parse(to_parse) end - # Takes an array of Thor::Argument objects. + # Takes an array of Bundler::Thor::Argument objects. # def initialize(arguments = []) @assigns, @non_assigned_required = {}, [] @@ -97,8 +97,8 @@ class Thor return shift if peek.is_a?(Hash) hash = {} - while current_is_value? && peek.include?(':') - key, value = shift.split(':', 2) + while current_is_value? && peek.include?(":") + key, value = shift.split(":", 2) hash[key] = value end hash @@ -131,12 +131,12 @@ class Thor fail MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}" end - value = $&.index('.') ? shift.to_f : shift.to_i - if @switches.is_a?(Hash) && switch = @switches[name] - if switch.enum && !switch.enum.include?(value) - raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}" - end + value = $&.index(".") ? shift.to_f : shift.to_i + if @switches.is_a?(Hash) && switch = @switches[name] + if switch.enum && !switch.enum.include?(value) + fail MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}" end + end value end @@ -167,7 +167,7 @@ class Thor o.respond_to?(:switch_name) ? o.switch_name : o.human_name end.join("', '") - class_name = self.class.name.split('::').last.downcase + class_name = self.class.name.split("::").last.downcase fail RequiredArgumentMissingError, "No value provided for required #{class_name} '#{names}'" end end diff --git a/lib/bundler/vendor/thor/parser/option.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb index a076045d15..eb893617f4 100644 --- a/lib/bundler/vendor/thor/parser/option.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb @@ -1,4 +1,4 @@ -class Thor +class Bundler::Thor class Option < Argument #:nodoc: attr_reader :aliases, :group, :lazy_default, :hide @@ -78,15 +78,19 @@ class Thor def usage(padding = 0) sample = if banner && !banner.to_s.empty? - "#{switch_name}=#{banner}" - else - switch_name - end + "#{switch_name}=#{banner}" + else + switch_name + end sample = "[#{sample}]" unless required? + if boolean? + sample << ", [#{dasherize("no-" + human_name)}]" unless name == "force" + end + if aliases.empty? - (' ' * padding) << sample + (" " * padding) << sample else "#{aliases.join(', ')}, #{sample}" end @@ -103,19 +107,19 @@ class Thor protected def validate! - fail ArgumentError, 'An option cannot be boolean and required.' if boolean? && required? + fail ArgumentError, "An option cannot be boolean and required." if boolean? && required? end def dasherized? - name.index('-') == 0 + name.index("-") == 0 end def undasherize(str) - str.sub(/^-{1,2}/, '') + str.sub(/^-{1,2}/, "") end def dasherize(str) - (str.length > 1 ? '--' : '-') + str.gsub('_', '-') + (str.length > 1 ? "--" : "-") + str.gsub("_", "-") end end end diff --git a/lib/bundler/vendor/thor/parser/options.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb index fb3fd1e0c0..deac6a0c16 100644 --- a/lib/bundler/vendor/thor/parser/options.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb @@ -1,11 +1,11 @@ -class Thor +class Bundler::Thor class Options < Arguments #:nodoc: # rubocop:disable ClassLength LONG_RE = /^(--\w+(?:-\w+)*)$/ SHORT_RE = /^(-[a-z])$/i EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i - OPTS_END = '--'.freeze + OPTS_END = "--".freeze # Receives a hash and makes it switches. def self.to_switches(options) @@ -18,14 +18,14 @@ class Thor when Hash "--#{key} #{value.map { |k, v| "#{k}:#{v}" }.join(' ')}" when nil, false - '' + "" else "--#{key} #{value.inspect}" end - end.join(' ') + end.join(" ") end - # Takes a hash of Thor::Option and a hash with defaults. + # Takes a hash of Bundler::Thor::Option and a hash with defaults. # # If +stop_on_unknown+ is true, #parse will stop as soon as it encounters # an unknown option or a regular argument. @@ -46,7 +46,7 @@ class Thor @switches[option.switch_name] = option option.aliases.each do |short| - name = short.to_s.sub(/^(?!\-)/, '-') + name = short.to_s.sub(/^(?!\-)/, "-") @shorts[name] ||= option.switch_name end end @@ -81,7 +81,7 @@ class Thor if is_switch case shifted when SHORT_SQ_RE - unshift($1.split('').map { |f| "-#{f}" }) + unshift($1.split("").map { |f| "-#{f}" }) next when EQ_RE, SHORT_NUM unshift($2) @@ -111,7 +111,7 @@ class Thor check_requirement! - assigns = Thor::CoreExt::HashWithIndifferentAccess.new(@assigns) + assigns = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new(@assigns) assigns.freeze assigns end @@ -133,7 +133,7 @@ class Thor when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM [true, switch?($1)] when SHORT_SQ_RE - [true, $1.split('').any? { |f| switch?("-#{f}") }] + [true, $1.split("").any? { |f| switch?("-#{f}") }] else [false, false] end @@ -167,7 +167,7 @@ class Thor # Check if the given argument is actually a shortcut. # def normalize_switch(arg) - (@shorts[arg] || arg).tr('_', '-') + (@shorts[arg] || arg).tr("_", "-") end def parsing_options? @@ -179,10 +179,10 @@ class Thor # def parse_boolean(switch) if current_is_value? - if ['true', 'TRUE', 't', 'T', true].include?(peek) + if ["true", "TRUE", "t", "T", true].include?(peek) shift true - elsif ['false', 'FALSE', 'f', 'F', false].include?(peek) + elsif ["false", "FALSE", "f", "F", false].include?(peek) shift false else diff --git a/lib/bundler/vendor/thor/rake_compat.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb index d347672d79..fcf6719df6 100644 --- a/lib/bundler/vendor/thor/rake_compat.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb @@ -1,15 +1,15 @@ -require 'rake' -require 'rake/dsl_definition' +require "rake" +require "rake/dsl_definition" -class Thor - # Adds a compatibility layer to your Thor classes which allows you to use +class Bundler::Thor + # Adds a compatibility layer to your Bundler::Thor classes which allows you to use # rake package tasks. For example, to use rspec rake tasks, one can do: # # require 'thor/rake_compat' # require 'rspec/core/rake_task' # - # class Default < Thor - # include Thor::RakeCompat + # class Default < Bundler::Thor + # include Bundler::Thor::RakeCompat # # RSpec::Core::RakeTask.new(:spec) do |t| # t.spec_opts = ['--options', './.rspec'] @@ -40,11 +40,11 @@ instance_eval do def task(*) task = super - if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition - non_namespaced_name = task.name.split(':').last + if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition + non_namespaced_name = task.name.split(":").last description = non_namespaced_name - description << task.arg_names.map { |n| n.to_s.upcase }.join(' ') + description << task.arg_names.map { |n| n.to_s.upcase }.join(" ") description.strip! klass.desc description, Rake.application.last_description || non_namespaced_name @@ -58,14 +58,14 @@ instance_eval do end def namespace(name) - if klass = Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition - const_name = Thor::Util.camel_case(name.to_s).to_sym - klass.const_set(const_name, Class.new(Thor)) + if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable 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) - Thor::RakeCompat.rake_classes << new_klass + Bundler::Thor::RakeCompat.rake_classes << new_klass end super - Thor::RakeCompat.rake_classes.pop + Bundler::Thor::RakeCompat.rake_classes.pop end end diff --git a/lib/bundler/vendor/thor/runner.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb index 761b7b3147..5552fe44bd 100644 --- a/lib/bundler/vendor/thor/runner.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb @@ -1,42 +1,42 @@ -require 'thor' -require 'thor/group' -require 'thor/core_ext/io_binary_read' +require "thor" +require "thor/group" +require "thor/core_ext/io_binary_read" -require 'fileutils' -require 'open-uri' -require 'yaml' -require 'digest/md5' -require 'pathname' +require "fileutils" +require "open-uri" +require "yaml" +require "digest/md5" +require "pathname" -class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength - map '-T' => :list, '-i' => :install, '-u' => :update, '-v' => :version +class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength + map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version - # Override Thor#help so it can give information about any class and any method. + # Override Bundler::Thor#help so it can give information about any class and any method. # def help(meth = nil) if meth && !self.respond_to?(meth) initialize_thorfiles(meth) - klass, command = Thor::Util.find_class_and_command_by_namespace(meth) + klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth) self.class.handle_no_command_error(command, false) if klass.nil? - klass.start(['-h', command].compact, :shell => shell) + klass.start(["-h", command].compact, :shell => shell) else super end end - # If a command is not found on Thor::Runner, method missing is invoked and - # Thor::Runner is then responsible for finding the command in all classes. + # If a command is not found on Bundler::Thor::Runner, method missing is invoked and + # Bundler::Thor::Runner is then responsible for finding the command in all classes. # def method_missing(meth, *args) meth = meth.to_s initialize_thorfiles(meth) - klass, command = Thor::Util.find_class_and_command_by_namespace(meth) + klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth) self.class.handle_no_command_error(command, false) if klass.nil? args.unshift(command) if command klass.start(args, :shell => shell) end - desc 'install NAME', 'Install an optionally named Thor file into your system commands' + 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 initialize_thorfiles @@ -45,7 +45,7 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength # command in said directory. begin if File.directory?(File.expand_path(name)) - base, package = File.join(name, 'main.thor'), :directory + base, package = File.join(name, "main.thor"), :directory contents = open(base) { |input| input.read } else base, package = name, :file @@ -57,14 +57,14 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength fail Error, "Error opening file '#{name}'" end - say 'Your Thorfile contains:' + say "Your Bundler::Thorfile contains:" say contents - unless options['force'] - return false if no?('Do you wish to continue [y/N]?') + unless options["force"] + return false if no?("Do you wish to continue [y/N]?") end - as = options['as'] || begin + as = options["as"] || begin first_line = contents.split("\n")[0] (match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil end @@ -76,23 +76,23 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength end location = if options[:relative] || name =~ %r{^https?://} - name - else - File.expand_path(name) - end + name + else + File.expand_path(name) + end thor_yaml[as] = { :filename => Digest::MD5.hexdigest(name + as), :location => location, - :namespaces => Thor::Util.namespaces_in_content(contents, base) + :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base) } save_yaml(thor_yaml) - say 'Storing thor file in your system repository' + say "Storing thor file in your system repository" destination = File.join(thor_root, thor_yaml[as][:filename]) if package == :file - File.open(destination, 'w') { |f| f.puts contents } + File.open(destination, "w") { |f| f.puts contents } else FileUtils.cp_r(name, destination) end @@ -100,13 +100,13 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength thor_yaml[as][:filename] # Indicate success end - desc 'version', 'Show Thor version' + desc "version", "Show Bundler::Thor version" def version - require 'thor/version' - say "Thor #{Thor::VERSION}" + require "thor/version" + say "Bundler::Thor #{Bundler::Thor::VERSION}" end - desc 'uninstall NAME', 'Uninstall a named Thor module' + desc "uninstall NAME", "Uninstall a named Bundler::Thor module" def uninstall(name) fail Error, "Can't find module '#{name}'" unless thor_yaml[name] say "Uninstalling #{name}." @@ -115,17 +115,17 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength thor_yaml.delete(name) save_yaml(thor_yaml) - puts 'Done.' + puts "Done." end - desc 'update NAME', 'Update a Thor file from its original location' + desc "update NAME", "Update a Bundler::Thor file from its original location" def update(name) fail Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location] say "Updating '#{name}' from #{thor_yaml[name][:location]}" old_filename = thor_yaml[name][:filename] - self.options = options.merge('as' => name) + self.options = options.merge("as" => name) if File.directory? File.expand_path(name) FileUtils.rm_rf(File.join(thor_root, old_filename)) @@ -143,23 +143,23 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength end end - desc 'installed', 'List the installed Thor modules and commands' + desc "installed", "List the installed Bundler::Thor modules and commands" method_options :internal => :boolean def installed initialize_thorfiles(nil, true) - display_klasses(true, options['internal']) + display_klasses(true, options["internal"]) end - desc 'list [SEARCH]', 'List the available thor commands (--substring means .*SEARCH)' + desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)" method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean - def list(search = '') + def list(search = "") initialize_thorfiles - search = ".*#{search}" if options['substring'] + search = ".*#{search}" if options["substring"] search = /^#{search}.*/i - group = options[:group] || 'standard' + group = options[:group] || "standard" - klasses = Thor::Base.subclasses.select do |k| + klasses = Bundler::Thor::Base.subclasses.select do |k| (options[:all] || k.group == group) && k.namespace =~ search end @@ -169,16 +169,16 @@ class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength private def self.banner(command, all = false, subcommand = false) - 'thor ' + command.formatted_usage(self, all, subcommand) + "thor " + command.formatted_usage(self, all, subcommand) end def thor_root - Thor::Util.thor_root + Bundler::Thor::Util.thor_root end def thor_yaml @thor_yaml ||= begin - yaml_file = File.join(thor_root, 'thor.yml') + yaml_file = File.join(thor_root, "thor.yml") yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file) yaml || {} end @@ -187,39 +187,39 @@ private # Save the yaml file. If none exists in thor root, creates one. # def save_yaml(yaml) - yaml_file = File.join(thor_root, 'thor.yml') + yaml_file = File.join(thor_root, "thor.yml") unless File.exist?(yaml_file) FileUtils.mkdir_p(thor_root) - yaml_file = File.join(thor_root, 'thor.yml') + yaml_file = File.join(thor_root, "thor.yml") FileUtils.touch(yaml_file) end - File.open(yaml_file, 'w') { |f| f.puts yaml.to_yaml } + File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml } end def self.exit_on_failure? true end - # Load the Thorfiles. If relevant_to is supplied, looks for specific files + # Load the Bundler::Thorfiles. If relevant_to is supplied, looks for specific files # in the thor_root instead of loading them all. # - # By default, it also traverses the current path until find Thor files, as + # By default, it also traverses the current path until find Bundler::Thor files, as # described in thorfiles. This look up can be skipped by supplying # skip_lookup true. # def initialize_thorfiles(relevant_to = nil, skip_lookup = false) thorfiles(relevant_to, skip_lookup).each do |f| - Thor::Util.load_thorfile(f, nil, options[:debug]) unless Thor::Base.subclass_files.keys.include?(File.expand_path(f)) + Bundler::Thor::Util.load_thorfile(f, nil, options[:debug]) unless Bundler::Thor::Base.subclass_files.keys.include?(File.expand_path(f)) end end - # Finds Thorfiles by traversing from your current directory down to the root - # directory of your system. If at any time we find a Thor file, we stop. + # Finds Bundler::Thorfiles by traversing from your current directory down to the root + # directory of your system. If at any time we find a Bundler::Thor file, we stop. # - # We also ensure that system-wide Thorfiles are loaded first, so local - # Thorfiles can override them. + # We also ensure that system-wide Bundler::Thorfiles are loaded first, so local + # Bundler::Thorfiles can override them. # # ==== Example # @@ -227,7 +227,7 @@ private # # 1. /Users/wycats/dev/thor # 2. /Users/wycats/dev - # 3. /Users/wycats <-- we find a Thorfile here, so we stop + # 3. /Users/wycats <-- we find a Bundler::Thorfile here, so we stop # # Suppose we start at c:\Documents and Settings\james\dev\thor ... # @@ -235,33 +235,33 @@ private # 2. c:\Documents and Settings\james\dev # 3. c:\Documents and Settings\james # 4. c:\Documents and Settings - # 5. c:\ <-- no Thorfiles found! + # 5. c:\ <-- no Bundler::Thorfiles found! # def thorfiles(relevant_to = nil, skip_lookup = false) thorfiles = [] unless skip_lookup Pathname.pwd.ascend do |path| - thorfiles = Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten + thorfiles = Bundler::Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten break unless thorfiles.empty? end end - files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Thor::Util.thor_root_glob) + files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Bundler::Thor::Util.thor_root_glob) files += thorfiles files -= ["#{thor_root}/thor.yml"] files.map! do |file| - File.directory?(file) ? File.join(file, 'main.thor') : file + File.directory?(file) ? File.join(file, "main.thor") : file end end - # Load Thorfiles relevant to the given method. If you provide "foo:bar" it + # Load Bundler::Thorfiles relevant to the given method. If you provide "foo:bar" it # will load all thor files in the thor.yaml that has "foo" e "foo:bar" # namespaces registered. # def thorfiles_relevant_to(meth) - lookup = [meth, meth.split(':')[0...-1].join(':')] + lookup = [meth, meth.split(":")[0...-1].join(":")] files = thor_yaml.select do |k, v| v[:namespaces] && !(v[:namespaces] & lookup).empty? @@ -273,24 +273,24 @@ private # Display information about the given klasses. If with_module is given, # it shows a table with information extracted from the yaml file. # - def display_klasses(with_modules = false, show_internal = false, klasses = Thor::Base.subclasses) - klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal + def display_klasses(with_modules = false, show_internal = false, klasses = Bundler::Thor::Base.subclasses) + klasses -= [Bundler::Thor, Bundler::Thor::Runner, Bundler::Thor::Group] unless show_internal - fail Error, 'No Thor commands available' if klasses.empty? + fail Error, "No Bundler::Thor commands available" if klasses.empty? show_modules if with_modules && !thor_yaml.empty? list = Hash.new { |h, k| h[k] = [] } - groups = klasses.select { |k| k.ancestors.include?(Thor::Group) } + groups = klasses.select { |k| k.ancestors.include?(Bundler::Thor::Group) } - # Get classes which inherit from Thor - (klasses - groups).each { |k| list[k.namespace.split(':').first] += k.printable_commands(false) } + # Get classes which inherit from Bundler::Thor + (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_commands(false) } - # Get classes which inherit from Thor::Base + # Get classes which inherit from Bundler::Thor::Base groups.map! { |k| k.printable_commands(false).first } - list['root'] = groups + list["root"] = groups # Order namespaces with default coming first - list = list.sort { |a, b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') } + list = list.sort { |a, b| a[0].sub(/^default/, "") <=> b[0].sub(/^default/, "") } list.each { |n, commands| display_commands(n, commands) unless commands.empty? } end @@ -298,7 +298,7 @@ private list.sort! { |a, b| a[0] <=> b[0] } say shell.set_color(namespace, :blue, true) - say '-' * namespace.size + say "-" * namespace.size print_table(list, :truncate => true) say @@ -310,13 +310,13 @@ private labels = %w[Modules Namespaces] info << labels - info << ['-' * labels[0].size, '-' * labels[1].size] + info << ["-" * labels[0].size, "-" * labels[1].size] thor_yaml.each do |name, hash| - info << [name, hash[:namespaces].join(', ')] + info << [name, hash[:namespaces].join(", ")] end print_table info - say '' + say "" end end diff --git a/lib/bundler/vendor/thor/shell.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb index 848dc9a1ea..6a6ec5e0a4 100644 --- a/lib/bundler/vendor/thor/shell.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb @@ -1,21 +1,21 @@ -require 'rbconfig' +require "rbconfig" -class Thor +class Bundler::Thor module Base class << self attr_writer :shell - # Returns the shell used in all Thor classes. If you are in a Unix platform + # Returns the shell used in all Bundler::Thor classes. If you are in a Unix platform # it will use a colored log, otherwise it will use a basic one without color. # def shell - @shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0 - Thor::Shell.const_get(ENV['THOR_SHELL']) - elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ && !ENV['ANSICON'] - Thor::Shell::Basic - else - Thor::Shell::Color - end + @shell ||= if ENV["THOR_SHELL"] && ENV["THOR_SHELL"].size > 0 + Bundler::Thor::Shell.const_get(ENV["THOR_SHELL"]) + elsif RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && !ENV["ANSICON"] + Bundler::Thor::Shell::Basic + else + Bundler::Thor::Shell::Color + end end end end @@ -24,9 +24,9 @@ class Thor SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width] attr_writer :shell - autoload :Basic, 'thor/shell/basic' - autoload :Color, 'thor/shell/color' - autoload :HTML, 'thor/shell/html' + autoload :Basic, "thor/shell/basic" + autoload :Color, "thor/shell/color" + autoload :HTML, "thor/shell/html" # Add shell to initialize config values. # @@ -35,11 +35,11 @@ class Thor # # ==== Examples # - # class MyScript < Thor + # class MyScript < Bundler::Thor # argument :first, :type => :numeric # end # - # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new + # MyScript.new [1.0], { :foo => :bar }, :shell => Bundler::Thor::Shell::Basic.new # def initialize(args = [], options = {}, config = {}) super @@ -47,10 +47,10 @@ class Thor shell.base ||= self if shell.respond_to?(:base) end - # Holds the shell for the given Thor instance. If no shell is given, - # it gets a default shell from Thor::Base.shell. + # Holds the shell for the given Bundler::Thor instance. If no shell is given, + # it gets a default shell from Bundler::Thor::Base.shell. def shell - @shell ||= Thor::Base.shell.new + @shell ||= Bundler::Thor::Base.shell.new end # Common methods that are delegated to the shell. diff --git a/lib/bundler/vendor/thor/shell/basic.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb index 1f4502066f..278ffa3df0 100644 --- a/lib/bundler/vendor/thor/shell/basic.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb @@ -1,6 +1,7 @@ -require 'tempfile' +require "tempfile" +require "io/console" if RUBY_VERSION > "1.9.2" -class Thor +class Bundler::Thor module Shell class Basic # rubocop:disable ClassLength attr_accessor :base @@ -75,9 +76,9 @@ class Thor # ==== Example # say("I know you knew that.") # - def say(message = '', color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) + def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) buffer = prepare_message(message, *color) - buffer << "\n" if force_new_line && !message.end_with?("\n") + buffer << "\n" if force_new_line && !message.to_s.end_with?("\n") stdout.print(buffer) stdout.flush @@ -90,7 +91,7 @@ class Thor # def say_status(status, message, log_status = true) return if quiet? || log_status == false - spaces = ' ' * (padding + 1) + spaces = " " * (padding + 1) color = log_status.is_a?(Symbol) ? log_status : :green status = status.to_s.rjust(12) @@ -162,17 +163,17 @@ class Thor maximas << maxima if index == colcount - 1 # Don't output 2 trailing spaces when printing the last column - formats << '%-s' + formats << "%-s" else formats << "%-#{maxima + 2}s" end end - formats[0] = formats[0].insert(0, ' ' * indent) - formats << '%s' + formats[0] = formats[0].insert(0, " " * indent) + formats << "%s" array.each do |row| - sentence = '' + sentence = "" row.each_with_index do |column, index| maxima = maximas[index] @@ -210,12 +211,12 @@ class Thor paras = message.split("\n\n") paras.map! do |unwrapped| - unwrapped.strip.gsub(/\n/, ' ').squeeze(' ').gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") } + unwrapped.strip.gsub(/\n/, " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") } end paras.each do |para| para.split("\n").each do |line| - stdout.puts line.insert(0, ' ' * indent) + stdout.puts line.insert(0, " " * indent) end stdout.puts unless para == paras.last end @@ -231,7 +232,7 @@ class Thor # def file_collision(destination) # rubocop:disable MethodLength return true if @always_force - options = block_given? ? '[Ynaqdh]' : '[Ynaqh]' + options = block_given? ? "[Ynaqdh]" : "[Ynaqh]" loop do answer = ask( @@ -240,18 +241,18 @@ class Thor ) case answer - when is?(:yes), is?(:force), '' + when is?(:yes), is?(:force), "" return true when is?(:no), is?(:skip) return false when is?(:always) return @always_force = true when is?(:quit) - say 'Aborting...' + say "Aborting..." fail SystemExit when is?(:diff) show_diff(destination, yield) if block_given? - say 'Retrying...' + say "Retrying..." else say file_collision_help end @@ -261,8 +262,8 @@ class Thor # This code was copied from Rake, available under MIT-LICENSE # Copyright (c) 2003, 2004 Jim Weirich def terminal_width - if ENV['THOR_COLUMNS'] - result = ENV['THOR_COLUMNS'].to_i + if ENV["THOR_COLUMNS"] + result = ENV["THOR_COLUMNS"].to_i else result = unix? ? dynamic_width : 80 end @@ -271,9 +272,9 @@ class Thor 80 end - # Called if something goes wrong during the execution. This is used by Thor + # Called if something goes wrong during the execution. This is used by Bundler::Thor # internally and should not be used inside your scripts. If something went - # wrong, you can always raise an exception. If you raise a Thor::Error, it + # wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it # will be rescued and wrapped in the method below. # def error(statement) @@ -281,7 +282,7 @@ class Thor end # Apply color to the given string with optional bold. Disabled in the - # Thor::Shell::Basic class. + # Bundler::Thor::Shell::Basic class. # def set_color(string, *args) #:nodoc: string @@ -333,7 +334,7 @@ class Thor end def show_diff(destination, content) #:nodoc: - diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u' + diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u" Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp| temp.write content @@ -352,11 +353,11 @@ class Thor end def dynamic_width_stty - %x{stty size 2>/dev/null}.split[1].to_i + %x(stty size 2>/dev/null).split[1].to_i end def dynamic_width_tput - %x{tput cols 2>/dev/null}.to_i + %x(tput cols 2>/dev/null).to_i end def unix? @@ -369,18 +370,18 @@ class Thor if chars.length <= width chars.join else - ( chars[0, width - 3].join) + '...' + ( chars[0, width - 3].join) + "..." end end end - if ''.respond_to?(:encode) + if "".respond_to?(:encode) def as_unicode yield end else def as_unicode - old, $KCODE = $KCODE, 'U' + old, $KCODE = $KCODE, "U" yield ensure $KCODE = old @@ -389,15 +390,15 @@ class Thor def ask_simply(statement, color, options) default = options[:default] - message = [statement, ("(#{default})" if default), nil].uniq.join(' ') + message = [statement, ("(#{default})" if default), nil].uniq.join(" ") message = prepare_message(message, color) - result = Thor::LineEditor.readline(message, options) + result = Bundler::Thor::LineEditor.readline(message, options) return unless result result.strip! - if default && result == '' + if default && result == "" default else result @@ -408,7 +409,7 @@ class Thor answer_set = options[:limited_to] correct_answer = nil until correct_answer - answers = answer_set.join(', ') + answers = answer_set.join(", ") answer = ask_simply("#{statement} [#{answers}]", color, options) correct_answer = answer_set.include?(answer) ? answer : nil say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer diff --git a/lib/bundler/vendor/thor/shell/color.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb index db3dcfc081..3c2feba4e5 100644 --- a/lib/bundler/vendor/thor/shell/color.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb @@ -1,9 +1,9 @@ -require 'thor/shell/basic' +require "thor/shell/basic" -class Thor +class Bundler::Thor module Shell - # Inherit from Thor::Shell::Basic and add set_color behavior. Check - # Thor::Shell::Basic to see all available methods. + # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check + # Bundler::Thor::Shell::Basic to see all available methods. # class Color < Basic # Embed in a String to clear all previous ANSI sequences. @@ -89,7 +89,7 @@ class Thor foreground, bold = colors foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol) - bold = bold ? BOLD : '' + bold = bold ? BOLD : "" "#{bold}#{foreground}#{string}#{CLEAR}" end end @@ -104,7 +104,7 @@ class Thor # available. # def show_diff(destination, content) #:nodoc: - if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil? + if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil? actual = File.binread(destination).to_s.split("\n") content = content.to_s.split("\n") @@ -118,11 +118,11 @@ class Thor def output_diff_line(diff) #:nodoc: case diff.action - when '-' + when "-" say "- #{diff.old_element.chomp}", :red, true - when '+' + when "+" say "+ #{diff.new_element.chomp}", :green, true - when '!' + when "!" say "- #{diff.old_element.chomp}", :red, true say "+ #{diff.new_element.chomp}", :green, true else @@ -138,7 +138,7 @@ class Thor return @diff_lcs_loaded unless @diff_lcs_loaded.nil? @diff_lcs_loaded = begin - require 'diff/lcs' + require "diff/lcs" true rescue LoadError false diff --git a/lib/bundler/vendor/thor/shell/html.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb index 296293b2ea..9e28690ad0 100644 --- a/lib/bundler/vendor/thor/shell/html.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb @@ -1,47 +1,47 @@ -require 'thor/shell/basic' +require "thor/shell/basic" -class Thor +class Bundler::Thor module Shell - # Inherit from Thor::Shell::Basic and add set_color behavior. Check - # Thor::Shell::Basic to see all available methods. + # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check + # Bundler::Thor::Shell::Basic to see all available methods. # class HTML < Basic # The start of an HTML bold sequence. - BOLD = 'font-weight: bold' + BOLD = "font-weight: bold" # Set the terminal's foreground HTML color to black. - BLACK = 'color: black' + BLACK = "color: black" # Set the terminal's foreground HTML color to red. - RED = 'color: red' + RED = "color: red" # Set the terminal's foreground HTML color to green. - GREEN = 'color: green' + GREEN = "color: green" # Set the terminal's foreground HTML color to yellow. - YELLOW = 'color: yellow' + YELLOW = "color: yellow" # Set the terminal's foreground HTML color to blue. - BLUE = 'color: blue' + BLUE = "color: blue" # Set the terminal's foreground HTML color to magenta. - MAGENTA = 'color: magenta' + MAGENTA = "color: magenta" # Set the terminal's foreground HTML color to cyan. - CYAN = 'color: cyan' + CYAN = "color: cyan" # Set the terminal's foreground HTML color to white. - WHITE = 'color: white' + WHITE = "color: white" # Set the terminal's background HTML color to black. - ON_BLACK = 'background-color: black' + ON_BLACK = "background-color: black" # Set the terminal's background HTML color to red. - ON_RED = 'background-color: red' + ON_RED = "background-color: red" # Set the terminal's background HTML color to green. - ON_GREEN = 'background-color: green' + ON_GREEN = "background-color: green" # Set the terminal's background HTML color to yellow. - ON_YELLOW = 'background-color: yellow' + ON_YELLOW = "background-color: yellow" # Set the terminal's background HTML color to blue. - ON_BLUE = 'background-color: blue' + ON_BLUE = "background-color: blue" # Set the terminal's background HTML color to magenta. - ON_MAGENTA = 'background-color: magenta' + ON_MAGENTA = "background-color: magenta" # Set the terminal's background HTML color to cyan. - ON_CYAN = 'background-color: cyan' + ON_CYAN = "background-color: cyan" # Set the terminal's background HTML color to white. - ON_WHITE = 'background-color: white' + ON_WHITE = "background-color: white" # Set color by using a string or one of the defined constants. If a third # option is set to true, it also adds bold to the string. This is based @@ -66,9 +66,9 @@ class Thor # ==== Example # ask("What is your name?") # - # TODO: Implement #ask for Thor::Shell::HTML + # TODO: Implement #ask for Bundler::Thor::Shell::HTML def ask(statement, color = nil) - fail NotImplementedError, 'Implement #ask for Thor::Shell::HTML' + fail NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML" end protected @@ -81,7 +81,7 @@ class Thor # available. # def show_diff(destination, content) #:nodoc: - if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil? + if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil? actual = File.binread(destination).to_s.split("\n") content = content.to_s.split("\n") @@ -95,11 +95,11 @@ class Thor def output_diff_line(diff) #:nodoc: case diff.action - when '-' + when "-" say "- #{diff.old_element.chomp}", :red, true - when '+' + when "+" say "+ #{diff.new_element.chomp}", :green, true - when '!' + when "!" say "- #{diff.old_element.chomp}", :red, true say "+ #{diff.new_element.chomp}", :green, true else @@ -115,7 +115,7 @@ class Thor return @diff_lcs_loaded unless @diff_lcs_loaded.nil? @diff_lcs_loaded = begin - require 'diff/lcs' + require "diff/lcs" true rescue LoadError false diff --git a/lib/bundler/vendor/thor/util.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb index a551b7d9cb..f4e98fc19f 100644 --- a/lib/bundler/vendor/thor/util.rb +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb @@ -1,6 +1,6 @@ -require 'rbconfig' +require "rbconfig" -class Thor +class Bundler::Thor module Sandbox #:nodoc: end @@ -8,30 +8,30 @@ class Thor # # 1) Methods to convert thor namespaces to constants and vice-versa. # - # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" + # Bundler::Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" # # 2) Loading thor files and sandboxing: # - # Thor::Util.load_thorfile("~/.thor/foo") + # Bundler::Thor::Util.load_thorfile("~/.thor/foo") # module Util class << self - # Receives a namespace and search for it in the Thor::Base subclasses. + # Receives a namespace and search for it in the Bundler::Thor::Base subclasses. # # ==== Parameters # namespace<String>:: The namespace to search for. # def find_by_namespace(namespace) namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/ - Thor::Base.subclasses.detect { |klass| klass.namespace == namespace } + Bundler::Thor::Base.subclasses.detect { |klass| klass.namespace == namespace } end - # Receives a constant and converts it to a Thor namespace. Since Thor + # Receives a constant and converts it to a Bundler::Thor namespace. Since Bundler::Thor # commands can be added to a sandbox, this method is also responsable for # removing the sandbox namespace. # # This method should not be used in general because it's used to deal with - # older versions of Thor. On current versions, if you need to get the + # older versions of Bundler::Thor. On current versions, if you need to get the # namespace from a class, just call namespace on it. # # ==== Parameters @@ -41,8 +41,8 @@ class Thor # String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz" # def namespace_from_thor_class(constant) - constant = constant.to_s.gsub(/^Thor::Sandbox::/, '') - constant = snake_case(constant).squeeze(':') + constant = constant.to_s.gsub(/^Bundler::Thor::Sandbox::/, "") + constant = snake_case(constant).squeeze(":") constant end @@ -56,13 +56,13 @@ class Thor # Array[Object] # def namespaces_in_content(contents, file = __FILE__) - old_constants = Thor::Base.subclasses.dup - Thor::Base.subclasses.clear + old_constants = Bundler::Thor::Base.subclasses.dup + Bundler::Thor::Base.subclasses.clear load_thorfile(file, contents) - new_constants = Thor::Base.subclasses.dup - Thor::Base.subclasses.replace(old_constants) + new_constants = Bundler::Thor::Base.subclasses.dup + Bundler::Thor::Base.subclasses.replace(old_constants) new_constants.map! { |c| c.namespace } new_constants.compact! @@ -73,9 +73,9 @@ class Thor # def thor_classes_in(klass) stringfied_constants = klass.constants.map { |c| c.to_s } - Thor::Base.subclasses.select do |subclass| + Bundler::Thor::Base.subclasses.select do |subclass| next unless subclass.name - stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", '')) + stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", "")) end end @@ -89,7 +89,7 @@ class Thor # def snake_case(str) return str.downcase if str =~ /^[A-Z_]+$/ - str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/ + str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/ $+.downcase end @@ -103,43 +103,43 @@ class Thor # def camel_case(str) return str if str !~ /_/ && str =~ /[A-Z]+.*/ - str.split('_').map { |i| i.capitalize }.join + str.split("_").map { |i| i.capitalize }.join end - # Receives a namespace and tries to retrieve a Thor or Thor::Group class + # Receives a namespace and tries to retrieve a Bundler::Thor or Bundler::Thor::Group class # from it. It first searches for a class using the all the given namespace, # if it's not found, removes the highest entry and searches for the class # again. If found, returns the highest entry as the class name. # # ==== Examples # - # class Foo::Bar < Thor + # class Foo::Bar < Bundler::Thor # def baz # end # end # - # class Baz::Foo < Thor::Group + # class Baz::Foo < Bundler::Thor::Group # end # - # Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command - # Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil - # Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz" + # Bundler::Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command + # Bundler::Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil + # Bundler::Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz" # # ==== Parameters # namespace<String> # def find_class_and_command_by_namespace(namespace, fallback = true) - if namespace.include?(':') # look for a namespaced command - pieces = namespace.split(':') + if namespace.include?(":") # look for a namespaced command + pieces = namespace.split(":") command = pieces.pop - klass = Thor::Util.find_by_namespace(pieces.join(':')) + klass = Bundler::Thor::Util.find_by_namespace(pieces.join(":")) end - unless klass # look for a Thor::Group with the right name - klass, command = Thor::Util.find_by_namespace(namespace), nil + unless klass # look for a Bundler::Thor::Group with the right name + klass, command = Bundler::Thor::Util.find_by_namespace(namespace), nil end if !klass && fallback # try a command in the default namespace command = namespace - klass = Thor::Util.find_by_namespace('') + klass = Bundler::Thor::Util.find_by_namespace("") end [klass, command] end @@ -152,7 +152,7 @@ class Thor content ||= File.binread(path) begin - Thor::Sandbox.class_eval(content, path) + Bundler::Thor::Sandbox.class_eval(content, path) rescue StandardError => e $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}") if debug @@ -164,31 +164,31 @@ class Thor end def user_home # rubocop:disable MethodLength - @@user_home ||= if ENV['HOME'] - ENV['HOME'] - elsif ENV['USERPROFILE'] - ENV['USERPROFILE'] - elsif ENV['HOMEDRIVE'] && ENV['HOMEPATH'] - File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH']) - elsif ENV['APPDATA'] - ENV['APPDATA'] - else - begin - File.expand_path('~') - rescue - if File::ALT_SEPARATOR - 'C:/' - else - '/' - end - end - end + @@user_home ||= if ENV["HOME"] + ENV["HOME"] + elsif ENV["USERPROFILE"] + ENV["USERPROFILE"] + elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"] + File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"]) + elsif ENV["APPDATA"] + ENV["APPDATA"] + else + begin + File.expand_path("~") + rescue + if File::ALT_SEPARATOR + "C:/" + else + "/" + end + end + end end # Returns the root where thor files are located, depending on the OS. # def thor_root - File.join(user_home, '.thor').gsub(/\\/, '/') + File.join(user_home, ".thor").gsub(/\\/, "/") end # Returns the files in the thor root. On Windows thor_root will be something @@ -202,15 +202,15 @@ class Thor files = Dir["#{escape_globs(thor_root)}/*"] files.map! do |file| - File.directory?(file) ? File.join(file, 'main.thor') : file + File.directory?(file) ? File.join(file, "main.thor") : file end end - # Where to look for Thor files. + # Where to look for Bundler::Thor files. # def globs_for(path) path = escape_globs(path) - ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"] + ["#{path}/Bundler::Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"] end # Return the path to the ruby interpreter taking into account multiple @@ -218,15 +218,15 @@ class Thor # def ruby_command # rubocop:disable MethodLength @ruby_command ||= begin - ruby_name = RbConfig::CONFIG['ruby_install_name'] - ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name) - ruby << RbConfig::CONFIG['EXEEXT'] + ruby_name = RbConfig::CONFIG["ruby_install_name"] + ruby = File.join(RbConfig::CONFIG["bindir"], ruby_name) + ruby << RbConfig::CONFIG["EXEEXT"] # avoid using different name than ruby (on platforms supporting links) - if ruby_name != 'ruby' && File.respond_to?(:readlink) + if ruby_name != "ruby" && File.respond_to?(:readlink) begin - alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby') - alternate_ruby << RbConfig::CONFIG['EXEEXT'] + alternate_ruby = File.join(RbConfig::CONFIG["bindir"], "ruby") + alternate_ruby << RbConfig::CONFIG["EXEEXT"] # ruby is a symlink if File.symlink? alternate_ruby @@ -251,7 +251,7 @@ class Thor # # ==== Examples # - # Thor::Util.escape_globs('[apps]') # => '\[apps\]' + # Bundler::Thor::Util.escape_globs('[apps]') # => '\[apps\]' # # ==== Parameters # String diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb new file mode 100644 index 0000000000..74b020a5ab --- /dev/null +++ b/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb @@ -0,0 +1,3 @@ +class Bundler::Thor + VERSION = "0.19.1" +end diff --git a/lib/bundler/vendor/thor/line_editor.rb b/lib/bundler/vendor/thor/line_editor.rb deleted file mode 100644 index 021c926cfe..0000000000 --- a/lib/bundler/vendor/thor/line_editor.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'thor/line_editor/basic' -require 'thor/line_editor/readline' - -class Thor - module LineEditor - def self.readline(prompt, options={}) - best_available.new(prompt, options).readline - end - - def self.best_available - [ - Thor::LineEditor::Readline, - Thor::LineEditor::Basic - ].detect(&:available?) - end - end -end diff --git a/lib/bundler/vendor/thor/parser.rb b/lib/bundler/vendor/thor/parser.rb deleted file mode 100644 index 57a3f6e1a5..0000000000 --- a/lib/bundler/vendor/thor/parser.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'thor/parser/argument' -require 'thor/parser/arguments' -require 'thor/parser/option' -require 'thor/parser/options' diff --git a/lib/bundler/vendor/thor/version.rb b/lib/bundler/vendor/thor/version.rb deleted file mode 100644 index 41784aaeca..0000000000 --- a/lib/bundler/vendor/thor/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Thor - VERSION = '0.18.1' -end diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb index a6434268ed..2426f0c406 100644 --- a/lib/bundler/vendored_thor.rb +++ b/lib/bundler/vendored_thor.rb @@ -1,8 +1,5 @@ -if defined?(Thor) - Bundler.ui.warn "Thor has already been required. " + - "This may cause Bundler to malfunction in unexpected ways." -end -vendor = File.expand_path('../vendor', __FILE__) -$:.unshift(vendor) unless $:.include?(vendor) +vendor = File.expand_path('../vendor/thor-0.19.1/lib', __FILE__) +loaded = $:.include?(vendor) +$:.unshift(vendor) unless loaded require 'thor' require 'thor/actions' |