diff options
author | mmoll <mmoll@FreeBSD.org> | 2015-06-09 03:10:16 +0800 |
---|---|---|
committer | mmoll <mmoll@FreeBSD.org> | 2015-06-09 03:10:16 +0800 |
commit | 14a611edbe2fb28562e4e23cd4427b457f0494f3 (patch) | |
tree | 8a895cca163c77c6c4b5ef0e3b36dfe3da83d9bb | |
parent | 84cceb687296292bc6a76a991cc2a63724f27fa5 (diff) | |
download | freebsd-ports-gnome-14a611edbe2fb28562e4e23cd4427b457f0494f3.tar.gz freebsd-ports-gnome-14a611edbe2fb28562e4e23cd4427b457f0494f3.tar.zst freebsd-ports-gnome-14a611edbe2fb28562e4e23cd4427b457f0494f3.zip |
devel/rubygem-clamp: update to 1.0.0
Differential Revision: https://reviews.freebsd.org/D2757
Approved by: mat (mentor)
-rw-r--r-- | devel/rubygem-clamp/Makefile | 4 | ||||
-rw-r--r-- | devel/rubygem-clamp/distinfo | 4 | ||||
-rw-r--r-- | devel/rubygem-clamp/files/patch-i18n | 215 |
3 files changed, 5 insertions, 218 deletions
diff --git a/devel/rubygem-clamp/Makefile b/devel/rubygem-clamp/Makefile index 951fecfd8696..58f6ad28133e 100644 --- a/devel/rubygem-clamp/Makefile +++ b/devel/rubygem-clamp/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= clamp -PORTVERSION= 0.6.5 +PORTVERSION= 1.0.0 CATEGORIES= devel ruby MASTER_SITES= RG @@ -10,7 +10,9 @@ MAINTAINER= mmoll@FreeBSD.org COMMENT= Command-line utility framework for Ruby LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE +NO_ARCH= yes USE_RUBY= yes USE_RUBYGEMS= yes RUBYGEM_AUTOPLIST= yes diff --git a/devel/rubygem-clamp/distinfo b/devel/rubygem-clamp/distinfo index 6748fc021908..36c6c5b14736 100644 --- a/devel/rubygem-clamp/distinfo +++ b/devel/rubygem-clamp/distinfo @@ -1,2 +1,2 @@ -SHA256 (rubygem/clamp-0.6.5.gem) = 384b6c144171d00afd1d588bca37ddb26efdfd7e6534ec6a47f9bef0b64cffbe -SIZE (rubygem/clamp-0.6.5.gem) = 24576 +SHA256 (rubygem/clamp-1.0.0.gem) = 1c16a29eac75477176a0f94d7558612ed2cc79031f0cf5e95798209a3e7cc66f +SIZE (rubygem/clamp-1.0.0.gem) = 26112 diff --git a/devel/rubygem-clamp/files/patch-i18n b/devel/rubygem-clamp/files/patch-i18n deleted file mode 100644 index e7366385efca..000000000000 --- a/devel/rubygem-clamp/files/patch-i18n +++ /dev/null @@ -1,215 +0,0 @@ ---- clamp.gemspec.orig 2015-02-28 19:33:22.833353000 +0000 -+++ clamp.gemspec 2015-02-28 19:33:51.000931000 +0000 -@@ -11,7 +11,7 @@ - s.date = "2015-05-02" - s.description = "Clamp provides an object-model for command-line utilities.\nIt handles parsing of command-line options, and generation of usage help.\n" - s.email = "mdub@dogbiscuit.org" -- s.files = [".autotest", ".gitignore", ".rspec", ".travis.yml", "CHANGES.md", "Gemfile", "LICENSE", "README.md", "Rakefile", "clamp.gemspec", "examples/admin", "examples/flipflop", "examples/fubar", "examples/gitdown", "examples/scoop", "examples/speak", "lib/clamp.rb", "lib/clamp/attribute/declaration.rb", "lib/clamp/attribute/definition.rb", "lib/clamp/attribute/instance.rb", "lib/clamp/command.rb", "lib/clamp/errors.rb", "lib/clamp/help.rb", "lib/clamp/option/declaration.rb", "lib/clamp/option/definition.rb", "lib/clamp/option/parsing.rb", "lib/clamp/parameter/declaration.rb", "lib/clamp/parameter/definition.rb", "lib/clamp/parameter/parsing.rb", "lib/clamp/subcommand/declaration.rb", "lib/clamp/subcommand/definition.rb", "lib/clamp/subcommand/execution.rb", "lib/clamp/subcommand/parsing.rb", "lib/clamp/truthy.rb", "lib/clamp/version.rb", "spec/clamp/command_group_spec.rb", "spec/clamp/command_spec.rb", "spec/clamp/option/definition_spec.rb", "spec/clamp/option_module_spec.rb", "spec/clamp/parameter/definition_spec.rb", "spec/spec_helper.rb"] -+ s.files = [".autotest", ".gitignore", ".rspec", ".travis.yml", "CHANGES.md", "Gemfile", "LICENSE", "README.md", "Rakefile", "clamp.gemspec", "examples/admin", "examples/flipflop", "examples/fubar", "examples/gitdown", "examples/scoop", "examples/speak", "lib/clamp.rb", "lib/clamp/attribute/declaration.rb", "lib/clamp/attribute/definition.rb", "lib/clamp/attribute/instance.rb", "lib/clamp/command.rb", "lib/clamp/errors.rb", "lib/clamp/help.rb", "lib/clamp/messages.rb", "lib/clamp/option/declaration.rb", "lib/clamp/option/definition.rb", "lib/clamp/option/parsing.rb", "lib/clamp/parameter/declaration.rb", "lib/clamp/parameter/definition.rb", "lib/clamp/parameter/parsing.rb", "lib/clamp/subcommand/declaration.rb", "lib/clamp/subcommand/definition.rb", "lib/clamp/subcommand/execution.rb", "lib/clamp/subcommand/parsing.rb", "lib/clamp/truthy.rb", "lib/clamp/version.rb", "spec/clamp/command_group_spec.rb", "spec/clamp/command_spec.rb", "spec/clamp/option/definition_spec.rb", "spec/clamp/option_module_spec.rb", "spec/clamp/parameter/definition_spec.rb", "spec/spec_helper.rb"] - s.homepage = "http://github.com/mdub/clamp" - s.licenses = ["MIT"] - s.rubygems_version = "2.4.6" -diff --git a/lib/clamp/attribute/instance.rb b/lib/clamp/attribute/instance.rb -index 8f51cc3..acab485 100644 ---- lib/clamp/attribute/instance.rb -+++ lib/clamp/attribute/instance.rb -@@ -69,7 +69,7 @@ def default_from_environment - begin - take(value) - rescue ArgumentError => e -- command.send(:signal_usage_error, "$#{attribute.environment_variable}: #{e.message}") -+ command.send(:signal_usage_error, Clamp.message(:env_argument_error, :env => attribute.environment_variable, :message => e.message)) - end - end - -diff --git a/lib/clamp/command.rb b/lib/clamp/command.rb -index c6c50f4..52187ab 100644 ---- lib/clamp/command.rb -+++ lib/clamp/command.rb -@@ -1,3 +1,4 @@ -+require 'clamp/messages' - require 'clamp/errors' - require 'clamp/help' - require 'clamp/option/declaration' -@@ -91,7 +92,7 @@ def help - - def handle_remaining_arguments - unless remaining_arguments.empty? -- signal_usage_error "too many arguments" -+ signal_usage_error Clamp.message(:too_many_arguments) - end - end - -diff --git a/lib/clamp/help.rb b/lib/clamp/help.rb -index e09731a..1e57530 100644 ---- lib/clamp/help.rb -+++ lib/clamp/help.rb -@@ -1,4 +1,5 @@ - require 'stringio' -+require 'clamp/messages' - - module Clamp - -@@ -41,12 +42,12 @@ def help(invocation_path, builder = Builder.new) - help.add_usage(invocation_path, usage_descriptions) - help.add_description(description) - if has_parameters? -- help.add_list("Parameters", parameters) -+ help.add_list(Clamp.message(:parameters_heading), parameters) - end - if has_subcommands? -- help.add_list("Subcommands", recognised_subcommands) -+ help.add_list(Clamp.message(:subcommands_heading), recognised_subcommands) - end -- help.add_list("Options", recognised_options) -+ help.add_list(Clamp.message(:options_heading), recognised_options) - help.string - end - -@@ -61,7 +62,7 @@ def string - end - - def add_usage(invocation_path, usage_descriptions) -- puts "Usage:" -+ puts usage_heading - usage_descriptions.each do |usage| - puts " #{invocation_path} #{usage}".rstrip - end -@@ -87,6 +88,12 @@ def add_list(heading, items) - end - end - -+ protected -+ -+ def usage_heading -+ Clamp.message(:usage_heading) + ":" -+ end -+ - private - - def puts(*args) -diff --git a/lib/clamp/messages.rb b/lib/clamp/messages.rb -new file mode 100644 -index 0000000..61cce94 ---- /dev/null -+++ lib/clamp/messages.rb -@@ -0,0 +1,43 @@ -+module Clamp -+ -+ def self.messages=(messages) -+ @user_defined_messages = messages -+ end -+ -+ def self.message(key, options={}) -+ @user_defined_messages ||= {} -+ msg = @user_defined_messages[key] || messages[key] -+ format_string(msg, options) -+ end -+ -+ def self.messages -+ { -+ :too_many_arguments => "too many arguments", -+ :option_required => "option '%<option>s' is required", -+ :option_or_env_required => "option '%<option>s' (or env %<env>s) is required", -+ :option_argument_error => "option '%<switch>s': %<message>s", -+ :parameter_argument_error => "parameter '%<param>s': %<message>s", -+ :env_argument_error => "$%<env>s: %<message>s", -+ :unrecognised_option => "Unrecognised option '%<switch>s'", -+ :no_such_subcommand => "No such sub-command '%<name>s'", -+ :no_value_provided => "no value provided", -+ :usage_heading => "Usage", -+ :parameters_heading => "Parameters", -+ :subcommands_heading => "Subcommands", -+ :options_heading => "Options" -+ } -+ end -+ -+ private -+ -+ # string formatting for ruby 1.8 -+ def self.format_string(string, params) -+ array_params = string.scan(/%[<{]([^>}]*)[>}]/).collect do |name| -+ name = name[0] -+ params[name.to_s] || params[name.to_sym] -+ end -+ -+ string.gsub(/%[<]([^>]*)[>]/, '%').gsub(/%[{]([^}]*)[}]/, '%s') % array_params -+ end -+ -+end -diff --git a/lib/clamp/option/parsing.rb b/lib/clamp/option/parsing.rb -index 9f057f1..bb7b41c 100644 ---- lib/clamp/option/parsing.rb -+++ lib/clamp/option/parsing.rb -@@ -31,7 +31,7 @@ def parse_options - begin - option.of(self).take(value) - rescue ArgumentError => e -- signal_usage_error "option '#{switch}': #{e.message}" -+ signal_usage_error Clamp.message(:option_argument_error, :switch => switch, :message => e.message) - end - - end -@@ -45,11 +45,11 @@ def parse_options - self.class.recognised_options.each do |option| - # If this option is required and the value is nil, there's an error. - if option.required? and send(option.attribute_name).nil? -- message = "option '#{option.switches.first}'" - if option.environment_variable -- message += " (or env #{option.environment_variable})" -+ message = Clamp.message(:option_or_env_required, :option => option.switches.first, :env => option.environment_variable) -+ else -+ message = Clamp.message(:option_required, :option => option.switches.first) - end -- message += " is required" - signal_usage_error message - end - end -@@ -59,7 +59,7 @@ def parse_options - - def find_option(switch) - self.class.find_option(switch) || -- signal_usage_error("Unrecognised option '#{switch}'") -+ signal_usage_error(Clamp.message(:unrecognised_option, :switch => switch)) - end - - end -diff --git a/lib/clamp/parameter/definition.rb b/lib/clamp/parameter/definition.rb -index 6412546..a276dea 100644 ---- lib/clamp/parameter/definition.rb -+++ lib/clamp/parameter/definition.rb -@@ -22,7 +22,7 @@ def help_lhs - end - - def consume(arguments) -- raise ArgumentError, "no value provided" if required? && arguments.empty? -+ raise ArgumentError, Clamp.message(:no_value_provided) if required? && arguments.empty? - arguments.shift(multivalued? ? arguments.length : 1) - end - -diff --git a/lib/clamp/parameter/parsing.rb b/lib/clamp/parameter/parsing.rb -index 8a70719..95aa422 100644 ---- lib/clamp/parameter/parsing.rb -+++ lib/clamp/parameter/parsing.rb -@@ -13,7 +13,7 @@ def parse_parameters - parameter.of(self).take(value) - end - rescue ArgumentError => e -- signal_usage_error "parameter '#{parameter.name}': #{e.message}" -+ signal_usage_error Clamp.message(:parameter_argument_error, :param => parameter.name, :message => e.message) - end - end - -diff --git a/lib/clamp/subcommand/execution.rb b/lib/clamp/subcommand/execution.rb -index d15c56b..c341df6 100644 ---- lib/clamp/subcommand/execution.rb -+++ lib/clamp/subcommand/execution.rb -@@ -25,7 +25,7 @@ def instatiate_subcommand(name) - end - - def find_subcommand_class(name) -- subcommand_def = self.class.find_subcommand(name) || signal_usage_error("No such sub-command '#{name}'") -+ subcommand_def = self.class.find_subcommand(name) || signal_usage_error(Clamp.message(:no_such_subcommand, :name => name)) - subcommand_def.subcommand_class - end - |