Hello community, here is the log from the commit of package rubygem-mercenary for openSUSE:Factory checked in at 2020-03-07 21:38:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-mercenary (Old) and /work/SRC/openSUSE:Factory/.rubygem-mercenary.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-mercenary" Sat Mar 7 21:38:41 2020 rev:2 rq:773781 version:0.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-mercenary/rubygem-mercenary.changes 2016-07-15 12:51:27.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-mercenary.new.26092/rubygem-mercenary.changes 2020-03-07 21:38:42.568291227 +0100 @@ -1,0 +2,24 @@ +Mon Feb 10 15:05:14 UTC 2020 - Stephan Kulow <co...@suse.com> + +- updated to version 0.4.0 + see installed History.markdown + + ## 0.4.0 / 2020-01-18 + + ### Major Enhancements + + * Drop Ruby 2.3 support + + ### Minor Enhancements + + * Remove parent command's flags from subcommand usage (#44) + + ### Development Fixes + + * Adopt Jekyll's rubocop config for consistency + + ### Documentation + + * fixes the readme (#52) + +------------------------------------------------------------------- Old: ---- mercenary-0.3.6.gem New: ---- mercenary-0.4.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-mercenary.spec ++++++ --- /var/tmp/diff_new_pack.b2DO5K/_old 2020-03-07 21:38:43.256291693 +0100 +++ /var/tmp/diff_new_pack.b2DO5K/_new 2020-03-07 21:38:43.264291698 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-mercenary # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -24,16 +24,16 @@ # Name: rubygem-mercenary -Version: 0.3.6 +Version: 0.4.0 Release: 0 %define mod_name mercenary %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{ruby >= 2.4.0} BuildRequires: %{rubygem gem2rpm} -BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 -Url: https://github.com/jekyll/mercenary -Source: http://rubygems.org/gems/%{mod_full_name}.gem +URL: https://github.com/jekyll/mercenary +Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: Lightweight and flexible library for writing command-line apps in License: MIT ++++++ mercenary-0.3.6.gem -> mercenary-0.4.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 2016-04-08 02:56:20.000000000 +0200 +++ new/.gitignore 2020-01-18 15:51:55.000000000 +0100 @@ -15,3 +15,4 @@ test/tmp test/version_tmp tmp +vendor/bundle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml --- old/.rubocop.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/.rubocop.yml 2020-01-18 15:51:55.000000000 +0100 @@ -0,0 +1,10 @@ +inherit_from: .rubocop_todo.yml + +require: rubocop-jekyll +inherit_gem: + rubocop-jekyll: .rubocop.yml + +AllCops: + TargetRubyVersion: 2.4 + Exclude: + - vendor/**/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop_todo.yml new/.rubocop_todo.yml --- old/.rubocop_todo.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/.rubocop_todo.yml 2020-01-18 15:51:55.000000000 +0100 @@ -0,0 +1,79 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2020-01-18 15:09:24 +0100 using RuboCop version 0.71.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +Jekyll/NoPAllowed: + Exclude: + - 'examples/help_dialogue.rb' + +# Offense count: 2 +Jekyll/NoPutsAllowed: + Exclude: + - 'lib/mercenary/command.rb' + +# Offense count: 4 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/mercenary/command.rb' + - 'lib/mercenary/option.rb' + - 'lib/mercenary/presenter.rb' + +# Offense count: 2 +Lint/DuplicateMethods: + Exclude: + - 'lib/mercenary/command.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/HandleExceptions: + Exclude: + - 'lib/mercenary/option.rb' + +# Offense count: 1 +Lint/UselessAssignment: + Exclude: + - 'lib/mercenary/presenter.rb' + +# Offense count: 1 +Metrics/AbcSize: + Max: 25 + +# Offense count: 1 +# Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 28 + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 319 + +# Offense count: 1 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/MethodLength: + Max: 24 + +# Offense count: 1 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/mercenary/command.rb' + +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/mercenary/presenter.rb' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2016-04-08 02:56:20.000000000 +0200 +++ new/.travis.yml 2020-01-18 15:51:55.000000000 +0100 @@ -1,12 +1,12 @@ language: ruby -rvm: - - 1.9.3 - - 2.0.0 - - 2.1 -sudo: false cache: bundler +rvm: + - 2.4 + - 2.6 + before_script: bundle update -script: "./script/cibuild" +script: script/cibuild + notifications: email: recipients: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2016-04-08 02:56:20.000000000 +0200 +++ new/Gemfile 2020-01-18 15:51:55.000000000 +0100 @@ -1,4 +1,6 @@ -source 'https://rubygems.org' +# frozen_string_literal: true + +source "https://rubygems.org" # Specify your gem's dependencies in mercenary.gemspec gemspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.markdown new/History.markdown --- old/History.markdown 2016-04-08 02:56:20.000000000 +0200 +++ new/History.markdown 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,21 @@ +## 0.4.0 / 2020-01-18 + +### Major Enhancements + + * Drop Ruby 2.3 support + +### Minor Enhancements + + * Remove parent command's flags from subcommand usage (#44) + +### Development Fixes + + * Adopt Jekyll's rubocop config for consistency + +### Documentation + + * fixes the readme (#52) + ## 0.3.6 / 2016-04-07 ### Bug Fixes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/LICENSE.txt new/LICENSE.txt --- old/LICENSE.txt 2016-04-08 02:56:20.000000000 +0200 +++ new/LICENSE.txt 2020-01-18 15:51:55.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright (c) 2013-2014 Parker Moore +Copyright (c) 2013-present Parker Moore and the mercenary contributors MIT License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-04-08 02:56:20.000000000 +0200 +++ new/README.md 2020-01-18 15:51:55.000000000 +0100 @@ -97,10 +97,9 @@ #### `#new` -Create a new command. Accepts two arguments: +Create a new command. Accepts one argument: - `name` - the name of your command, as a symbol -- `parent` - (optional) the parent Command #### `#version` @@ -167,7 +166,7 @@ in your code from this option's value. The description is also optional, but it's highly recommended to include a description. -#### `#alias` +#### `#alias` Specifies an alias for this command such that the alias may be used in place of the command during execution. Accepts one argument: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2016-04-08 02:56:20.000000000 +0200 +++ new/Rakefile 2020-01-18 15:51:55.000000000 +0100 @@ -1 +1,3 @@ +# frozen_string_literal: true + require "bundler/gem_tasks" Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/examples/help_dialogue.rb new/examples/help_dialogue.rb --- old/examples/help_dialogue.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/examples/help_dialogue.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,6 +1,7 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") require "mercenary" @@ -9,23 +10,22 @@ # be output to STDOUT. Mercenary.program(:help_dialogue) do |p| - p.version "2.0.1" - p.description 'An example of the help dialogue in Mercenary' - p.syntax 'help_dialogue <subcommand>' + p.description "An example of the help dialogue in Mercenary" + p.syntax "help_dialogue <subcommand>" p.command(:some_subcommand) do |c| - c.version '1.4.2' - c.syntax 'some_subcommand <subcommand> [options]' - c.description 'Some subcommand to do something' - c.option 'an_option', '-o', '--option', 'Some option' + c.version "1.4.2" + c.syntax "some_subcommand <subcommand> [options]" + c.description "Some subcommand to do something" + c.option "an_option", "-o", "--option", "Some option" c.alias(:blah) c.command(:yet_another_sub) do |f| - f.syntax 'yet_another_sub [options]' - f.description 'Do amazing things' - f.option 'blah', '-b', '--blah', 'Trigger blah flag' - f.option 'heh', '-H ARG', '--heh ARG', 'Give a heh' + f.syntax "yet_another_sub [options]" + f.description "Do amazing things" + f.option "blah", "-b", "--blah", "Trigger blah flag" + f.option "heh", "-H ARG", "--heh ARG", "Give a heh" f.action do |args, options| print "Args: " @@ -37,10 +37,9 @@ end p.command(:another_subcommand) do |c| - c.syntax 'another_subcommand <subcommand> [options]' - c.description 'Another subcommand to do something different.' - c.option 'an_option', '-O', '--option', 'Some option' - c.option 'another_options', '--pluginzzz', 'Set where the plugins should be found from' + c.syntax "another_subcommand <subcommand> [options]" + c.description "Another subcommand to do something different." + c.option "an_option", "-O", "--option", "Some option" + c.option "another_options", "--pluginzzz", "Set where the plugins should be found from" end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/examples/logging.rb new/examples/logging.rb --- old/examples/logging.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/examples/logging.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,6 +1,7 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") require "mercenary" @@ -9,18 +10,16 @@ # be output to STDOUT. Mercenary.program(:logger_output) do |p| - p.version "5.2.6" - p.description 'An example of turning on logging for Mercenary.' - p.syntax 'logger_output' - + p.description "An example of turning on logging for Mercenary." + p.syntax "logger_output" p.logger.info "The default log level is INFO. So this will output." p.logger.debug "Since DEBUG is below INFO, this will not output." p.logger(Logger::DEBUG) p.logger.debug "Logger level now set to DEBUG. So everything will output." - + p.logger.debug "Example of DEBUG level message." p.logger.info "Example of INFO level message." p.logger.warn "Example of WARN level message." @@ -28,12 +27,9 @@ p.logger.fatal "Example of FATAL level message." p.logger.unknown "Example of UNKNOWN level message." - p.action do |args, options| - + p.action do |_args, _options| p.logger(Logger::INFO) p.logger.debug "Logger level back to INFO. This line will not output." p.logger.info "This INFO message will output." - end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/examples/trace.rb new/examples/trace.rb --- old/examples/trace.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/examples/trace.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,6 +1,7 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib }) +$LOAD_PATH.unshift File.join(__dir__, "..", "lib") require "mercenary" @@ -9,13 +10,11 @@ # be output to STDOUT. Mercenary.program(:trace) do |p| - p.version "2.0.1" - p.description 'An example of traces in Mercenary' - p.syntax 'trace <subcommand>' + p.description "An example of traces in Mercenary" + p.syntax "trace <subcommand>" p.action do |_, _| - raise ArgumentError.new("YOU DID SOMETHING TERRIBLE YOU BUFFOON") + raise ArgumentError, "YOU DID SOMETHING TERRIBLE YOU BUFFOON" end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary/command.rb new/lib/mercenary/command.rb --- old/lib/mercenary/command.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary/command.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,5 @@ +# frozen_string_literal: false + module Mercenary class Command attr_reader :name @@ -47,9 +49,7 @@ def syntax(syntax = nil) @syntax = syntax if syntax syntax_list = [] - if parent - syntax_list << parent.syntax.to_s.gsub(/<[\w\s-]+>/, '').gsub(/\[[\w\s-]+\]/, '').strip - end + syntax_list << parent.syntax.to_s.gsub(%r!<[\w\s-]+>!, "").gsub(%r!\[[\w\s-]+\]!, "").strip if parent syntax_list << (@syntax || name.to_s) syntax_list.join(" ") end @@ -72,11 +72,11 @@ # Returns the default command if there is one, `nil` otherwise def default_command(command_name = nil) if command_name - if commands.has_key?(command_name) + if commands.key?(command_name) @default_command = commands[command_name] if command_name @default_command else - raise ArgumentError.new("'#{command_name}' couldn't be found in this command's list of commands.") + raise ArgumentError, "'#{command_name}' couldn't be found in this command's list of commands." end else @default_command @@ -133,11 +133,12 @@ # level - the logger level (a Logger constant, see docs for more info) # # Returns the instance of Logger + def logger(level = nil) unless @logger @logger = Logger.new(STDOUT) @logger.level = level || Logger::INFO - @logger.formatter = proc do |severity, datetime, progname, msg| + @logger.formatter = proc do |severity, _datetime, _progname, msg| "#{identity} | " << "#{severity.downcase.capitalize}:".ljust(7) << " #{msg}\n" end end @@ -189,15 +190,15 @@ # # Returns nothing def add_default_options(opts) - option 'show_help', '-h', '--help', 'Show this message' - option 'show_version', '-v', '--version', 'Print the name and version' - option 'show_backtrace', '-t', '--trace', 'Show the full backtrace when an error occurs' + option "show_help", "-h", "--help", "Show this message" + option "show_version", "-v", "--version", "Print the name and version" + option "show_backtrace", "-t", "--trace", "Show the full backtrace when an error occurs" opts.on("-v", "--version", "Print the version") do puts "#{name} #{version}" exit(0) end - opts.on('-t', '--trace', 'Show full backtrace if an error occurs') do + opts.on("-t", "--trace", "Show full backtrace if an error occurs") do @trace = true end @@ -228,7 +229,7 @@ # Returns true if this command is the parent of a command of name # 'sub_command' and false otherwise def has_command?(sub_command) - commands.keys.include?(sub_command) + commands.key?(sub_command) end # Public: Identify this command @@ -242,7 +243,7 @@ # # Returns a string containing the name and version if it exists def identity - "#{full_name} #{version if version}".strip + "#{full_name} #{version}".strip end # Public: Get the name of the current command plus that of @@ -251,7 +252,7 @@ # Returns the full name of the command def full_name the_name = [] - the_name << parent.full_name if parent && parent.full_name + the_name << parent.full_name if parent&.full_name the_name << name the_name.join(" ") end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary/option.rb new/lib/mercenary/option.rb --- old/lib/mercenary/option.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary/option.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mercenary class Option attr_reader :config_key, :description, :short, :long, :return_type @@ -11,10 +13,10 @@ # # Returns nothing def initialize(config_key, info) - @config_key = config_key + @config_key = config_key while arg = info.shift begin - @return_type = Object.const_get("#{arg}") + @return_type = Object.const_get(arg.to_s) next rescue NameError end @@ -34,7 +36,7 @@ # # Returns the array which OptionParser#on wants def for_option_parser - [short, long, return_type, description].flatten.reject{ |o| o.to_s.empty? } + [short, long, return_type, description].flatten.reject { |o| o.to_s.empty? } end # Public: Build a string representation of this option including the @@ -51,8 +53,8 @@ def formatted_switches [ switches.first.rjust(10), - switches.last.ljust(13) - ].join(", ").gsub(/ , /, ' ').gsub(/, /, ' ') + switches.last.ljust(13), + ].join(", ").gsub(%r! , !, " ").gsub(%r!, !, " ") end # Public: Hash based on the hash value of instance variables @@ -70,6 +72,7 @@ # Returns true if all the instance variables are equal, false otherwise def eql?(other) return false unless self.class.eql?(other.class) + instance_variables.map do |var| instance_variable_get(var).eql?(other.instance_variable_get(var)) end.all? @@ -82,6 +85,5 @@ def switches [short, long].map(&:to_s) end - end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary/presenter.rb new/lib/mercenary/presenter.rb --- old/lib/mercenary/presenter.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary/presenter.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mercenary class Presenter attr_accessor :command @@ -23,12 +25,16 @@ # Returns the string representation of the options def options_presentation return nil unless command_options_presentation || parent_command_options_presentation + [command_options_presentation, parent_command_options_presentation].compact.join("\n") end def command_options_presentation - return nil unless command.options.size > 0 - command.options.map(&:to_s).join("\n") + return nil if command.options.empty? + + options = command.options + options -= command.parent.options if command.parent + options.map(&:to_s).join("\n") end # Public: Builds a string representation of the options for parent @@ -37,6 +43,7 @@ # Returns the string representation of the options for parent commands def parent_command_options_presentation return nil unless command.parent + Presenter.new(command.parent).options_presentation end @@ -44,7 +51,8 @@ # # Returns the string representation of the subcommands def subcommands_presentation - return nil unless command.commands.size > 0 + return nil if command.commands.empty? + command.commands.values.uniq.map(&:summarize).join("\n") end @@ -52,7 +60,7 @@ # # Returns the command header as a String def command_header - header = "#{command.identity}" + header = command.identity.to_s header << " -- #{command.description}" if command.description header end @@ -83,11 +91,12 @@ # # Returns the value of whatever function is called def method_missing(meth, *args, &block) - if meth.to_s =~ /^print_(.+)$/ - send("#{$1.downcase}_presentation") + if meth.to_s =~ %r!^print_(.+)$! + send("#{Regexp.last_match(1).downcase}_presentation") else - super # You *must* call super if you don't handle the method, - # otherwise you'll mess up Ruby's method lookup. + # You *must* call super if you don't handle the method, + # otherwise you'll mess up Ruby's method lookup. + super end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary/program.rb new/lib/mercenary/program.rb --- old/lib/mercenary/program.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary/program.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mercenary class Program < Command attr_reader :optparse @@ -31,7 +33,7 @@ @optparse.parse!(argv) rescue OptionParser::InvalidOption => e logger.error "Whoops, we can't understand your command." - logger.error "#{e.message}" + logger.error e.message.to_s logger.error "Run your command again with the --help switch to see available options." abort end @@ -40,7 +42,7 @@ begin cmd.execute(argv, @config) - rescue => e + rescue StandardError => e if cmd.trace raise e else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary/version.rb new/lib/mercenary/version.rb --- old/lib/mercenary/version.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary/version.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mercenary - VERSION = "0.3.6" + VERSION = "0.4.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mercenary.rb new/lib/mercenary.rb --- old/lib/mercenary.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/lib/mercenary.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,12 +1,14 @@ -require File.expand_path("../mercenary/version", __FILE__) +# frozen_string_literal: true + +require File.expand_path("mercenary/version", __dir__) require "optparse" require "logger" module Mercenary - autoload :Command, File.expand_path("../mercenary/command", __FILE__) - autoload :Option, File.expand_path("../mercenary/option", __FILE__) - autoload :Presenter, File.expand_path("../mercenary/presenter", __FILE__) - autoload :Program, File.expand_path("../mercenary/program", __FILE__) + autoload :Command, File.expand_path("mercenary/command", __dir__) + autoload :Option, File.expand_path("mercenary/option", __dir__) + autoload :Presenter, File.expand_path("mercenary/presenter", __dir__) + autoload :Program, File.expand_path("mercenary/program", __dir__) # Public: Instantiate a new program and execute. # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mercenary.gemspec new/mercenary.gemspec --- old/mercenary.gemspec 2016-04-08 02:56:20.000000000 +0200 +++ new/mercenary.gemspec 2020-01-18 15:51:55.000000000 +0100 @@ -1,24 +1,28 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'mercenary/version' +require "mercenary/version" Gem::Specification.new do |spec| spec.name = "mercenary" spec.version = Mercenary::VERSION spec.authors = ["Tom Preston-Werner", "Parker Moore"] spec.email = ["t...@mojombo.com", "parkrmo...@gmail.com"] - spec.description = %q{Lightweight and flexible library for writing command-line apps in Ruby.} - spec.summary = %q{Lightweight and flexible library for writing command-line apps in Ruby.} + spec.description = "Lightweight and flexible library for writing command-line apps in Ruby." + spec.summary = "Lightweight and flexible library for writing command-line apps in Ruby." spec.homepage = "https://github.com/jekyll/mercenary" spec.license = "MIT" - spec.files = `git ls-files`.split($/) - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) + spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r!^(test|spec|features)/!) spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.3" + spec.required_ruby_version = ">= 2.4.0" + + spec.add_development_dependency "bundler" spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "rubocop-jekyll", "~> 0.10.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-04-08 02:56:20.000000000 +0200 +++ new/metadata 2020-01-18 15:51:55.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: mercenary version: !ruby/object:Gem::Version - version: 0.3.6 + version: 0.4.0 platform: ruby authors: - Tom Preston-Werner @@ -9,22 +9,22 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-04-08 00:00:00.000000000 Z +date: 2020-01-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ">=" - !ruby/object:Gem::Version - version: '1.3' + version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ">=" - !ruby/object:Gem::Version - version: '1.3' + version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement @@ -53,6 +53,20 @@ - - "~>" - !ruby/object:Gem::Version version: '3.0' +- !ruby/object:Gem::Dependency + name: rubocop-jekyll + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: 0.10.0 + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: 0.10.0 description: Lightweight and flexible library for writing command-line apps in Ruby. email: - t...@mojombo.com @@ -63,6 +77,8 @@ files: - ".gitignore" - ".rspec" +- ".rubocop.yml" +- ".rubocop_todo.yml" - ".travis.yml" - Gemfile - History.markdown @@ -83,6 +99,7 @@ - script/cibuild - script/console - script/examples +- script/fmt - spec/command_spec.rb - spec/option_spec.rb - spec/presenter_spec.rb @@ -100,15 +117,14 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: '0' + version: 2.4.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] -rubyforge_project: -rubygems_version: 2.5.1 +rubygems_version: 3.0.6 signing_key: specification_version: 4 summary: Lightweight and flexible library for writing command-line apps in Ruby. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/script/cibuild new/script/cibuild --- old/script/cibuild 2016-04-08 02:56:20.000000000 +0200 +++ new/script/cibuild 2020-01-18 15:51:55.000000000 +0100 @@ -3,4 +3,5 @@ set -ex bundle exec rspec -./script/examples +script/fmt +script/examples diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/script/fmt new/script/fmt --- old/script/fmt 1970-01-01 01:00:00.000000000 +0100 +++ new/script/fmt 2020-01-18 15:51:55.000000000 +0100 @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Rubocop $(bundle exec rubocop --version)" +bundle exec rubocop -S -D -E $@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/command_spec.rb new/spec/command_spec.rb --- old/spec/command_spec.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/spec/command_spec.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require "spec_helper" describe(Mercenary::Command) do - context "a basic command" do let(:command) { Mercenary::Command.new(:my_name) } let(:parent) { Mercenary::Command.new(:my_parent) } @@ -17,7 +18,7 @@ ) end let(:add_sub) do - Proc.new do |c| + proc do |c| c.command(:sub_command) { |p| } end end @@ -56,7 +57,7 @@ it "can set its options" do name = "show_drafts" - opts = ['--drafts', 'Render posts in the _drafts folder'] + opts = ["--drafts", "Render posts in the _drafts folder"] option = Mercenary::Option.new(name, opts) command.option name, *opts expect(command.options).to eql([option]) @@ -68,7 +69,7 @@ end it "knows its identity" do - command_with_parent.version '1.8.7' + command_with_parent.version "1.8.7" expect(command_with_parent.identity).to eql("my_parent i_have_parent 1.8.7") end @@ -94,5 +95,4 @@ end end end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/option_spec.rb new/spec/option_spec.rb --- old/spec/option_spec.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/spec/option_spec.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,9 +1,11 @@ -require 'spec_helper' +# frozen_string_literal: true + +require "spec_helper" describe(Mercenary::Option) do let(:config_key) { "largo" } let(:description) { "This is a description" } - let(:switches) { ['-l', '--largo'] } + let(:switches) { ["-l", "--largo"] } let(:option) { described_class.new(config_key, [switches, description].flatten.reject(&:nil?)) } it "knows its config key" do @@ -27,20 +29,20 @@ end it "compares itself with other options well" do - new_option = described_class.new(config_key, ['-l', '--largo', description]) + new_option = described_class.new(config_key, ["-l", "--largo", description]) expect(option.eql?(new_option)).to be(true) expect(option.hash.eql?(new_option.hash)).to be(true) end it "has a custom #hash" do - expect(option.hash.to_s).to match(/\d+/) + expect(option.hash.to_s).to match(%r!\d+!) end context "with just the long switch" do - let(:switches) { ['--largo'] } + let(:switches) { ["--largo"] } it "adds an empty string in place of the short switch" do - expect(option.switches).to eql(['', '--largo']) + expect(option.switches).to eql(["", "--largo"]) end it "sets its description properly" do @@ -53,10 +55,10 @@ end context "with just the short switch" do - let(:switches) { ['-l'] } + let(:switches) { ["-l"] } it "adds an empty string in place of the long switch" do - expect(option.switches).to eql(['-l', '']) + expect(option.switches).to eql(["-l", ""]) end it "sets its description properly" do @@ -79,5 +81,4 @@ expect(option.switches).to eql(switches) end end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/presenter_spec.rb new/spec/presenter_spec.rb --- old/spec/presenter_spec.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/spec/presenter_spec.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,4 +1,6 @@ -require 'spec_helper' +# frozen_string_literal: true + +require "spec_helper" describe(Mercenary::Presenter) do let(:supercommand) { Mercenary::Command.new(:script_name) } @@ -6,16 +8,20 @@ let(:presenter) { described_class.new(command) } before(:each) do - command.version '1.4.2' - command.description 'Do all the things.' - command.option 'one', '-1', '--one', 'The first option' - command.option 'two', '-2', '--two', 'The second option' + supercommand.option "version", "-v", "--version", "Show version" + supercommand.option "help", "-h", "--help", "Help!" + + command.version "1.4.2" + command.description "Do all the things." + command.option "help", "-h", "--help", "Help!" + command.option "one", "-1", "--one", "The first option" + command.option "two", "-2", "--two", "The second option" command.alias :cmd supercommand.commands[command.name] = command end it "knows how to present the command" do - expect(presenter.command_presentation).to eql("script_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option") + expect(presenter.command_presentation).to eql("script_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") end it "knows how to present the subcommands, without duplicates for aliases" do @@ -27,7 +33,7 @@ end it "knows how to present the options" do - expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option") + expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") end it "allows you to say print_* instead of *_presentation" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/program_spec.rb new/spec/program_spec.rb --- old/spec/program_spec.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/spec/program_spec.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require "spec_helper" describe(Mercenary::Program) do - context "a basic program" do let(:program) { Mercenary::Program.new(:my_name) } @@ -15,5 +16,4 @@ expect(program.version).to eq(version) end end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb --- old/spec/spec_helper.rb 2016-04-08 02:56:20.000000000 +0200 +++ new/spec/spec_helper.rb 2020-01-18 15:51:55.000000000 +0100 @@ -1,6 +1,8 @@ -lib = File.expand_path('../../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path("../lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'mercenary' +require "mercenary" RSpec.configure do |config| config.run_all_when_everything_filtered = true @@ -10,5 +12,5 @@ # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = 'random' + config.order = "random" end