Hello community, here is the log from the commit of package rubygem-thor for openSUSE:Factory checked in at 2017-08-22 11:09:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-thor (Old) and /work/SRC/openSUSE:Factory/.rubygem-thor.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-thor" Tue Aug 22 11:09:31 2017 rev:19 rq:517890 version:0.20.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-thor/rubygem-thor.changes 2017-06-15 11:24:25.718629912 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-thor.new/rubygem-thor.changes 2017-08-22 11:09:33.712938794 +0200 @@ -1,0 +2,12 @@ +Mon Aug 21 06:00:39 UTC 2017 - [email protected] + +- updated to version 0.20.0 + * Add check_default_type! to check if the default value of an option + matches the defined type. It removes the warning on usage and gives + the command authors the possibility to check for programming errors. + * Add disable_required_check! to disable check for required options in + some commands. It is a substitute of disable_class_options that was + not working as intended. + * Add inject_into_module. + +------------------------------------------------------------------- Old: ---- thor-0.19.4.gem New: ---- thor-0.20.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-thor.spec ++++++ --- /var/tmp/diff_new_pack.uHUGVl/_old 2017-08-22 11:09:35.188730995 +0200 +++ /var/tmp/diff_new_pack.uHUGVl/_new 2017-08-22 11:09:35.200729305 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-thor -Version: 0.19.4 +Version: 0.20.0 Release: 0 %define mod_name thor %define mod_full_name %{mod_name}-%{version} @@ -34,7 +34,7 @@ BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives Url: http://whatisthor.com/ -Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: Thor is a toolkit for building powerful command-line interfaces License: MIT ++++++ thor-0.19.4.gem -> thor-0.20.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-11-28 07:37:51.000000000 +0100 +++ new/CHANGELOG.md 2017-08-16 19:50:22.000000000 +0200 @@ -1,3 +1,33 @@ +## 0.20.0 +* Add `check_default_type!` to check if the default value of an option matches the defined type. + It removes the warning on usage and gives the command authors the possibility to check for programming errors. + +* Add `disable_required_check!` to disable check for required options in some commands. + It is a substitute of `disable_class_options` that was not working as intended. + +* Add `inject_into_module`. + +## 0.19.4, release 2016-11-28 +* Rename `Thor::Base#thor_reserved_word?` to `#is_thor_reserved_word?` + +## 0.19.3, release 2016-11-27 +* Output a warning instead of raising an exception when a default option value doesn't match its specified type + +## 0.19.2, release 2016-11-26 +* Fix bug with handling of colors passed to `ask` (and methods like `yes?` and `no?` which it underpins) +* Allow numeric arguments to be negative +* Ensure that default option values are of the specified type (e.g. you can't specify `"foo"` as the default for a numeric option), but make symbols and strings interchangeable +* Add `Thor::Shell::Basic#indent` method for intending output +* Fix `remove_command` for an inherited command (see #451) +* Allow hash arguments to only have each key provided once (see #455) +* Allow commands to disable class options, for instance for "help" commands (see #363) +* Do not generate a negative option (`--no-no-foo`) for already negative boolean options (`--no-foo`) +* Improve compatibility of `Thor::CoreExt::HashWithIndifferentAccess` with Ruby standard library `Hash` +* Allow specifying a custom binding for template evaluation (e.g. `#key?` and `#fetch`) +* Fix support for subcommand-specific "help"s +* Use a string buffer when handling ERB for Ruby 2.3 compatibility +* Update dependencies + ## 0.19.1, release 2014-03-24 * Fix `say` non-String break regression Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions/create_file.rb new/lib/thor/actions/create_file.rb --- old/lib/thor/actions/create_file.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions/create_file.rb 2017-08-16 19:50:22.000000000 +0200 @@ -58,6 +58,7 @@ def invoke! invoke_with_conflict_check do + require "fileutils" FileUtils.mkdir_p(File.dirname(destination)) File.open(destination, "wb") { |f| f.write render } end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions/create_link.rb new/lib/thor/actions/create_link.rb --- old/lib/thor/actions/create_link.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions/create_link.rb 2017-08-16 19:50:22.000000000 +0200 @@ -38,6 +38,7 @@ def invoke! invoke_with_conflict_check do + require "fileutils" FileUtils.mkdir_p(File.dirname(destination)) # Create a symlink by default config[:symbolic] = true if config[:symbolic].nil? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions/empty_directory.rb new/lib/thor/actions/empty_directory.rb --- old/lib/thor/actions/empty_directory.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions/empty_directory.rb 2017-08-16 19:50:22.000000000 +0200 @@ -48,12 +48,14 @@ def invoke! invoke_with_conflict_check do + require "fileutils" ::FileUtils.mkdir_p(destination) end end def revoke! say_status :remove, :red + require "fileutils" ::FileUtils.rm_rf(destination) if !pretend? && exists? given_destination end @@ -112,11 +114,17 @@ if exists? on_conflict_behavior(&block) else - say_status :create, :green yield unless pretend? + say_status :create, :green end destination + rescue Errno::EISDIR, Errno::EEXIST + on_file_clash_behavior + end + + def on_file_clash_behavior + say_status :file_clash, :red end # What to do when the destination file already exists. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions/file_manipulation.rb new/lib/thor/actions/file_manipulation.rb --- old/lib/thor/actions/file_manipulation.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions/file_manipulation.rb 2017-08-16 19:50:22.000000000 +0200 @@ -1,5 +1,4 @@ require "erb" -require "open-uri" class Thor module Actions @@ -78,7 +77,12 @@ config = args.last.is_a?(Hash) ? args.pop : {} destination = args.first - source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ %r{^https?\://} + if source =~ %r{^https?\://} + require "open-uri" + else + source = File.expand_path(find_in_source_paths(source.to_s)) + end + render = open(source) { |input| input.binmode.read } destination ||= if block_given? @@ -113,7 +117,9 @@ context = config.delete(:context) || instance_eval("binding") create_file destination, nil, config do - content = CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context) + content = CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer").tap do |erb| + erb.filename = source + end.result(context) content = yield(content) if block content end @@ -134,7 +140,10 @@ return unless behavior == :invoke path = File.expand_path(path, destination_root) say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true) - FileUtils.chmod_R(mode, path) unless options[:pretend] + unless options[:pretend] + require "fileutils" + FileUtils.chmod_R(mode, path) + end end # Prepend text to a file. Since it depends on insert_into_file, it's reversible. @@ -204,6 +213,29 @@ insert_into_file(path, *(args << config), &block) end + # Injects text right after the module definition. Since it depends on + # insert_into_file, it's reversible. + # + # ==== Parameters + # path<String>:: path of the file to be changed + # module_name<String|Class>:: the module to be manipulated + # data<String>:: the data to append to the class, can be also given as a block. + # config<Hash>:: give :verbose => false to not log the status. + # + # ==== Examples + # + # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n" + # + # inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do + # " def help; 'help'; end\n" + # end + # + def inject_into_module(path, module_name, *args, &block) + config = args.last.is_a?(Hash) ? args.pop : {} + config[:after] = /module #{module_name}\n|module #{module_name} .*\n/ + insert_into_file(path, *(args << config), &block) + end + # Run a regular expression replacement on a file. # # ==== Parameters @@ -288,7 +320,10 @@ path = File.expand_path(path, destination_root) say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true) - ::FileUtils.rm_rf(path) if !options[:pretend] && File.exist?(path) + if !options[:pretend] && File.exist?(path) + require "fileutils" + ::FileUtils.rm_rf(path) + end end alias_method :remove_dir, :remove_file @@ -305,8 +340,10 @@ with_output_buffer { yield(*args) } end - def with_output_buffer(buf = "") #:nodoc: - self.output_buffer, old_buffer = buf, output_buffer + def with_output_buffer(buf = "".dup) #:nodoc: + raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen? + old_buffer = output_buffer + self.output_buffer = buf yield output_buffer ensure @@ -319,7 +356,7 @@ def set_eoutvar(compiler, eoutvar = "_erbout") compiler.put_cmd = "#{eoutvar}.concat" compiler.insert_cmd = "#{eoutvar}.concat" - compiler.pre_cmd = ["#{eoutvar} = ''"] + compiler.pre_cmd = ["#{eoutvar} = ''.dup"] compiler.post_cmd = [eoutvar] end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions/inject_into_file.rb new/lib/thor/actions/inject_into_file.rb --- old/lib/thor/actions/inject_into_file.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions/inject_into_file.rb 2017-08-16 19:50:22.000000000 +0200 @@ -53,7 +53,13 @@ replacement + '\0' end - replace!(/#{flag}/, content, config[:force]) + if exists? + replace!(/#{flag}/, content, config[:force]) + else + unless pretend? + raise Thor::Error, "The file #{ destination } does not appear to exist" + end + end end def revoke! @@ -91,8 +97,8 @@ # Adds the content to the file. # def replace!(regexp, string, force) - return if base.options[:pretend] - content = File.binread(destination) + return if pretend? + content = File.read(destination) if force || !content.include?(replacement) content.gsub!(regexp, string) File.open(destination, "wb") { |file| file.write(content) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/actions.rb new/lib/thor/actions.rb --- old/lib/thor/actions.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/actions.rb 2017-08-16 19:50:22.000000000 +0200 @@ -1,4 +1,3 @@ -require "fileutils" require "uri" require "thor/core_ext/io_binary_read" require "thor/actions/create_file" @@ -141,7 +140,7 @@ end end - message = "Could not find #{file.inspect} in any of your source paths. " + message = "Could not find #{file.inspect} in any of your source paths. ".dup unless self.class.source_root message << "Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. " @@ -175,6 +174,7 @@ # If the directory doesnt exist and we're not pretending if !File.exist?(destination_root) && !pretend + require "fileutils" FileUtils.mkdir_p(destination_root) end @@ -182,6 +182,7 @@ # In pretend mode, just yield down to the block block.arity == 1 ? yield(destination_root) : yield else + require "fileutils" FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield } end @@ -251,7 +252,9 @@ say_status :run, desc, config.fetch(:verbose, true) - !options[:pretend] && config[:capture] ? `#{command}` : system(command.to_s) + unless options[:pretend] + config[:capture] ? `#{command}` : system(command.to_s) + end end # Executes a ruby script (taking into account WIN32 platform quirks). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/base.rb new/lib/thor/base.rb --- old/lib/thor/base.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/base.rb 2017-08-16 19:50:22.000000000 +0200 @@ -42,7 +42,7 @@ # config<Hash>:: Configuration for this Thor class. # def initialize(args = [], local_options = {}, config = {}) - parse_options = config[:current_command] && config[:current_command].disable_class_options ? {} : self.class.class_options + parse_options = self.class.class_options # The start method splits inbound arguments at the first argument # that looks like an option (starts with - or --). It then calls @@ -65,7 +65,8 @@ # 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) + disable_required_check = self.class.disable_required_check? config[:current_command] + opts = Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check) self.options = opts.parse(array_options) self.options = config[:class_options].merge(options) if config[:class_options] @@ -150,6 +151,21 @@ !!check_unknown_options end + # If you want to raise an error when the default value of an option does not match + # the type call check_default_type! + # This is disabled by default for compatibility. + def check_default_type! + @check_default_type = true + end + + def check_default_type #:nodoc: + @check_default_type ||= from_superclass(:check_default_type, false) + end + + def check_default_type? #:nodoc: + !!check_default_type + end + # If true, option parsing is suspended as soon as an unknown option or a # regular argument is encountered. All remaining arguments are passed to # the command as regular arguments. @@ -157,6 +173,12 @@ false end + # If true, option set will not suspend the execution of the command when + # a required option is not provided. + def disable_required_check?(command_name) #:nodoc: + false + end + # If you want only strict string args (useful when cascading thor classes), # call strict_args_position! This is disabled by default to allow dynamic # invocations. @@ -477,7 +499,8 @@ alias_method :handle_no_task_error, :handle_no_command_error def handle_argument_error(command, error, args, arity) #:nodoc: - msg = "ERROR: \"#{basename} #{command.name}\" was called with " + name = [command.ancestor_name, command.name].compact.join(" ") + msg = "ERROR: \"#{basename} #{name}\" was called with ".dup msg << "no arguments" if args.empty? msg << "arguments " << args.inspect unless args.empty? msg << "\nUsage: #{banner(command).inspect}" @@ -541,7 +564,7 @@ # 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] = Thor::Option.new(name, options.merge(:check_default_type => check_default_type?)) end # Receives a hash of options, parse them and add to the scope. This is a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/command.rb new/lib/thor/command.rb --- old/lib/thor/command.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/command.rb 2017-08-16 19:50:22.000000000 +0200 @@ -1,9 +1,9 @@ class Thor - class Command < Struct.new(:name, :description, :long_description, :usage, :options, :disable_class_options) + class Command < Struct.new(:name, :description, :long_description, :usage, :options, :ancestor_name) FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/ - def initialize(name, description, long_description, usage, options = nil, disable_class_options = false) - super(name.to_s, description, long_description, usage, options || {}, disable_class_options) + def initialize(name, description, long_description, usage, options = nil) + super(name.to_s, description, long_description, usage, options || {}) end def initialize_copy(other) #:nodoc: @@ -39,13 +39,15 @@ # Returns the formatted usage by injecting given required arguments # and required options into the given usage. def formatted_usage(klass, namespace = true, subcommand = false) - if namespace + if ancestor_name + formatted = "#{ancestor_name} ".dup # add space + elsif namespace namespace = klass.namespace - formatted = "#{namespace.gsub(/^(default)/, '')}:" + formatted = "#{namespace.gsub(/^(default)/, '')}:".dup end - formatted = "#{klass.namespace.split(':').last} " if subcommand + formatted ||= "#{klass.namespace.split(':').last} ".dup if subcommand - formatted ||= "" + formatted ||= "".dup # Add usage with required arguments formatted << if klass && !klass.arguments.empty? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/core_ext/hash_with_indifferent_access.rb new/lib/thor/core_ext/hash_with_indifferent_access.rb --- old/lib/thor/core_ext/hash_with_indifferent_access.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/core_ext/hash_with_indifferent_access.rb 2017-08-16 19:50:22.000000000 +0200 @@ -51,6 +51,18 @@ self end + def reverse_merge(other) + self.class.new(other).merge(self) + end + + def reverse_merge!(other_hash) + replace(reverse_merge(other_hash)) + end + + def replace(other_hash) + super(other_hash) + end + # Convert to a Hash with String keys. def to_hash Hash.new(default).merge!(self) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/group.rb new/lib/thor/group.rb --- old/lib/thor/group.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/group.rb 2017-08-16 19:50:22.000000000 +0200 @@ -205,7 +205,7 @@ alias_method :printable_tasks, :printable_commands def handle_argument_error(command, error, _args, arity) #:nodoc: - msg = "#{basename} #{command.name} takes #{arity} argument" + msg = "#{basename} #{command.name} takes #{arity} argument".dup msg << "s" if arity > 1 msg << ", but it should not." raise error, msg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/line_editor/basic.rb new/lib/thor/line_editor/basic.rb --- old/lib/thor/line_editor/basic.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/line_editor/basic.rb 2017-08-16 19:50:22.000000000 +0200 @@ -23,6 +23,8 @@ if echo? $stdin.gets else + # Lazy-load io/console since it is gem-ified as of 2.3 + require "io/console" if RUBY_VERSION > "1.9.2" $stdin.noecho(&:gets) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/parser/option.rb new/lib/thor/parser/option.rb --- old/lib/thor/parser/option.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/parser/option.rb 2017-08-16 19:50:22.000000000 +0200 @@ -5,6 +5,7 @@ VALID_TYPES = [:boolean, :numeric, :hash, :array, :string] def initialize(name, options = {}) + @check_default_type = options[:check_default_type] options[:required] = false unless options.key?(:required) super @lazy_default = options[:lazy_default] @@ -80,12 +81,12 @@ def usage(padding = 0) sample = if banner && !banner.to_s.empty? - "#{switch_name}=#{banner}" + "#{switch_name}=#{banner}".dup else switch_name end - sample = "[#{sample}]" unless required? + sample = "[#{sample}]".dup unless required? if boolean? sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-") @@ -110,7 +111,7 @@ def validate! raise ArgumentError, "An option cannot be boolean and required." if boolean? && required? - validate_default_type! + validate_default_type! if @check_default_type end def validate_default_type! @@ -127,8 +128,7 @@ @default.class.name.downcase.to_sym end - # TODO: This should raise an ArgumentError in a future version of Thor - warn "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type + raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type end def dasherized? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/parser/options.rb new/lib/thor/parser/options.rb --- old/lib/thor/parser/options.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/parser/options.rb 2017-08-16 19:50:22.000000000 +0200 @@ -18,19 +18,20 @@ when Hash "--#{key} #{value.map { |k, v| "#{k}:#{v}" }.join(' ')}" when nil, false - "" + nil else "--#{key} #{value.inspect}" end - end.join(" ") + end.compact.join(" ") end # Takes a hash of 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. - def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false) + def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false) @stop_on_unknown = stop_on_unknown + @disable_required_check = disable_required_check options = hash_options.values super(options) @@ -111,7 +112,7 @@ end end - check_requirement! + check_requirement! unless @disable_required_check assigns = Thor::CoreExt::HashWithIndifferentAccess.new(@assigns) assigns.freeze @@ -188,7 +189,7 @@ shift false else - true + !no_or_skip?(switch) end else @switches.key?(switch) || !no_or_skip?(switch) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/runner.rb new/lib/thor/runner.rb --- old/lib/thor/runner.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/runner.rb 2017-08-16 19:50:22.000000000 +0200 @@ -2,8 +2,6 @@ require "thor/group" require "thor/core_ext/io_binary_read" -require "fileutils" -require "open-uri" require "yaml" require "digest/md5" require "pathname" @@ -104,6 +102,7 @@ if package == :file File.open(destination, "w") { |f| f.puts contents } else + require "fileutils" FileUtils.cp_r(name, destination) end @@ -120,6 +119,7 @@ def uninstall(name) raise Error, "Can't find module '#{name}'" unless thor_yaml[name] say "Uninstalling #{name}." + require "fileutils" FileUtils.rm_rf(File.join(thor_root, (thor_yaml[name][:filename]).to_s)) thor_yaml.delete(name) @@ -138,6 +138,7 @@ self.options = options.merge("as" => name) if File.directory? File.expand_path(name) + require "fileutils" FileUtils.rm_rf(File.join(thor_root, old_filename)) thor_yaml.delete(old_filename) @@ -194,6 +195,7 @@ yaml_file = File.join(thor_root, "thor.yml") unless File.exist?(yaml_file) + require "fileutils" FileUtils.mkdir_p(thor_root) yaml_file = File.join(thor_root, "thor.yml") FileUtils.touch(yaml_file) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/shell/basic.rb new/lib/thor/shell/basic.rb --- old/lib/thor/shell/basic.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/shell/basic.rb 2017-08-16 19:50:22.000000000 +0200 @@ -1,6 +1,3 @@ -require "tempfile" -require "io/console" if RUBY_VERSION > "1.9.2" - class Thor module Shell class Basic @@ -110,7 +107,7 @@ status = set_color status, color, true if color buffer = "#{status}#{spaces}#{message}" - buffer << "\n" unless buffer.end_with?("\n") + buffer = "#{buffer}\n" unless buffer.end_with?("\n") stdout.print(buffer) stdout.flush @@ -165,7 +162,7 @@ colwidth = options[:colwidth] options[:truncate] = terminal_width if options[:truncate] == true - formats << "%-#{colwidth + 2}s" if colwidth + formats << "%-#{colwidth + 2}s".dup if colwidth start = colwidth ? 1 : 0 colcount = array.max { |a, b| a.size <=> b.size }.size @@ -177,9 +174,9 @@ maximas << maxima formats << if index == colcount - 1 # Don't output 2 trailing spaces when printing the last column - "%-s" + "%-s".dup else - "%-#{maxima + 2}s" + "%-#{maxima + 2}s".dup end end @@ -187,7 +184,7 @@ formats << "%s" array.each do |row| - sentence = "" + sentence = "".dup row.each_with_index do |column, index| maxima = maximas[index] @@ -255,6 +252,9 @@ ) case answer + when nil + say "" + return true when is?(:yes), is?(:force), "" return true when is?(:no), is?(:skip) @@ -350,6 +350,7 @@ def show_diff(destination, content) #:nodoc: diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u" + require "tempfile" Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp| temp.write content temp.rewind @@ -411,7 +412,7 @@ return unless result - result.strip! + result = result.strip if default && result == "" default diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor/version.rb new/lib/thor/version.rb --- old/lib/thor/version.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor/version.rb 2017-08-16 19:50:22.000000000 +0200 @@ -1,3 +1,3 @@ class Thor - VERSION = "0.19.4" + VERSION = "0.20.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/thor.rb new/lib/thor.rb --- old/lib/thor.rb 2016-11-28 07:37:51.000000000 +0100 +++ new/lib/thor.rb 2017-08-16 19:50:22.000000000 +0200 @@ -158,10 +158,6 @@ end alias_method :option, :method_option - def disable_class_options - @disable_class_options = true - end - # Prints help information for the given command. # # ==== Parameters @@ -241,6 +237,9 @@ invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h") invoke subcommand_class, *invoke_args end + subcommand_class.commands.each do |_meth, command| + command.ancestor_name = subcommand + end end alias_method :subtask, :subcommand @@ -326,12 +325,31 @@ command && stop_on_unknown_option.include?(command.name.to_sym) end + # Disable the check for required options for the given commands. + # This is useful if you have a command that does not need the required options + # to work, like help. + # + # ==== Parameters + # Symbol ...:: A list of commands that should be affected. + def disable_required_check!(*command_names) + disable_required_check.merge(command_names) + end + + def disable_required_check?(command) #:nodoc: + command && disable_required_check.include?(command.name.to_sym) + end + protected def stop_on_unknown_option #:nodoc: @stop_on_unknown_option ||= Set.new end + # help command has the required check disabled by default. + def disable_required_check #:nodoc: + @disable_required_check ||= Set.new([:help]) + end + # The method responsible for dispatching given the args. def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength meth ||= retrieve_command_name(given_args) @@ -390,12 +408,12 @@ @usage ||= nil @desc ||= nil @long_desc ||= nil - @disable_class_options ||= nil + @hide ||= nil if @usage && @desc base_class = @hide ? Thor::HiddenCommand : Thor::Command - commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options, @disable_class_options) - @usage, @desc, @long_desc, @method_options, @hide, @disable_class_options = nil + 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" true @@ -477,7 +495,6 @@ map HELP_MAPPINGS => :help desc "help [COMMAND]", "Describe available commands or one specific command" - disable_class_options def help(command = nil, subcommand = false) if command if self.class.subcommands.include? command diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-11-28 07:37:51.000000000 +0100 +++ new/metadata 2017-08-16 19:50:22.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: thor version: !ruby/object:Gem::Version - version: 0.19.4 + version: 0.20.0 platform: ruby authors: - Yehuda Katz @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-11-28 00:00:00.000000000 Z +date: 2017-08-16 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler @@ -91,7 +91,7 @@ version: 1.3.5 requirements: [] rubyforge_project: -rubygems_version: 2.5.2 +rubygems_version: 2.6.12 signing_key: specification_version: 4 summary: Thor is a toolkit for building powerful command-line interfaces.
