cleaning up warnings under ruby 2.6.x

master
ahoward 3 years ago
parent b1aebb74ac
commit 1836de02e5
  1. 3
      lib/main.rb
  2. 18
      lib/main/cast.rb
  3. 2
      lib/main/daemon.rb
  4. 1
      lib/main/mode.rb
  5. 4
      lib/main/parameter.rb
  6. 5
      lib/main/program/class_methods.rb
  7. 8
      lib/main/test.rb
  8. 35
      lib/main/usage.rb
  9. 2
      lib/main/util.rb
  10. 3
      main.gemspec
  11. BIN
      pkg/main-6.2.2.gem
  12. 21
      test/main_test.rb

@ -1,7 +1,7 @@
module Main
# top level constants
#
Main::VERSION = '6.2.2' unless
Main::VERSION = '6.2.3' unless
defined? Main::VERSION
def Main.version() Main::VERSION end
@ -11,7 +11,6 @@ module Main
Main::LIBDIR = File.join(File.dirname(File.expand_path(__FILE__)), self.name.downcase, '') unless
defined? Main::LIBDIR
def self.libdir() Main::LIBDIR end
Main::EXIT_SUCCESS = 0 unless defined? Main::EXIT_SUCCESS
Main::EXIT_FAILURE = 1 unless defined? Main::EXIT_FAILURE

@ -7,10 +7,15 @@ module Main
List = []
def self.cast m, &b
define_method m, &b
export m
List << m.to_s
def Cast.cast(*args, &block)
if args.first && block
method = args.shift
define_method(method, &block)
export(method)
List << (method.to_s)
else
Cast.send(*args)
end
end
cast :boolean do |obj|
@ -152,12 +157,7 @@ module Main
m
raise ArgumentError, "ambiguous cast: #{ sym.inspect } (#{ List.join ',' })" unless
candidates.empty? or m.to_s == sym.to_s
this = self
lambda{|obj| method(m).call obj}
end
def Cast.cast(which, *args, &block)
Cast.send(which, *args, &block)
end
end
end

@ -225,7 +225,7 @@ module Main
begin
cmd_stop
break
rescue Object => e
rescue Object
if alive?
sleep(rand)
else

@ -20,7 +20,6 @@ module Main
end
def find_by_mode m, options = {}
quiet = options['quiet'] || options[:quiet]
each_pair do |mode, klass|
return mode if mode == m
end

@ -240,8 +240,6 @@ module Main
self
end
this = self
%w[ before instead after ].each do |which|
getter = "error_handler_#{ which }"
query = "error_handler_#{ which }?"
@ -462,7 +460,7 @@ module Main
i += 1
b = argv[idx + 1]
s = "#{ a }#{ b }"
m, key, *ignored = kre.match(s).to_a
m, key, * = kre.match(s).to_a
if m
replacements[i] ||= a.gsub %r/^\s*#{ key }/, opt
next

@ -107,7 +107,6 @@ module Main
#
def dynamically_extend_via_commandline_modes!
self.breadth_first_modes = modes.dup
size = modes.size
loop do
modes.each do |mode|
@ -185,7 +184,7 @@ module Main
def usage(*args, &block)
usage! unless defined? @usage
return @usage if args.empty? and block.nil?
key, value, *ignored = args
key, value, * = args
value = block.call if block
@usage[key.to_s] = value.to_s
end
@ -367,7 +366,7 @@ module Main
else
[]
end
dash = lines.shift if lines.first.to_s =~ /^---/
lines.shift if lines.first.to_s =~ /^---/
require 'fileutils' unless defined?(FileUtils)
FileUtils.mkdir_p(File.dirname(config_path))
open(config_path, 'w') do |fd|

@ -11,10 +11,10 @@ module Main
argv = options[:argv]
env = options[:env]
logger = options[:logger]
stdin = options[:stdin]
stdout = options[:stdout]
stderr = options[:stderr]
#logger = options[:logger]
#stdin = options[:stdin]
#stdout = options[:stdout]
#stderr = options[:stderr]
Main.push_ios!

@ -142,27 +142,26 @@ module Main
parameters = arguments + keywords + options + environment
s =
parameters.map do |p|
ps = ''
ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78)
#ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78)
parameters.map do |p|
ps = ''
ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78)
#ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78)
#ps << "\n"
if p.description?
ps << "\n"
ps << Util.columnize("#{ p.description }", :indent => 6, :width => 78)
#ps << Util.columnize(p.description, :indent => 6, :width => 78)
#ps << "\n"
if p.description?
end
#ps << "\n"
unless(p.examples.nil? or p.examples.empty?)
p.examples.each do |example|
ps << "\n"
ps << Util.columnize("#{ p.description }", :indent => 6, :width => 78)
#ps << Util.columnize(p.description, :indent => 6, :width => 78)
#ps << "\n"
ps << Util.columnize("#{ example }", :indent => 8, :width => 78)
end
#ps << "\n"
unless(p.examples.nil? or p.examples.empty?)
p.examples.each do |example|
ps << "\n"
ps << Util.columnize("#{ example }", :indent => 8, :width => 78)
end
end
ps
end.join("\n")
end
ps
end.join("\n")
end
def author_section

@ -44,7 +44,7 @@ module Main
def columnize buf, opts = {}
width = Util.getopt 'width', opts, 80
indent = Util.getopt 'indent', opts
indent = Fixnum === indent ? (' ' * indent) : "#{ indent }"
indent = Numeric === indent ? (' ' * indent.to_i) : "#{ indent }"
column = []
words = buf.split %r/\s+/o
row = "#{ indent }"

@ -3,7 +3,7 @@
Gem::Specification::new do |spec|
spec.name = "main"
spec.version = "6.2.2"
spec.version = "6.2.3"
spec.platform = Gem::Platform::RUBY
spec.summary = "main"
spec.description = "a class factory and dsl for generating command line programs real quick"
@ -14,7 +14,6 @@ Gem::Specification::new do |spec|
"README.erb",
"Rakefile",
"TODO",
"a.rb",
"lib",
"lib/main",
"lib/main.rb",

Binary file not shown.

@ -117,7 +117,6 @@ class T < Test::Unit::TestCase
# parameter parsing
#
def test_0080
p = nil
assert_raises(Main::Parameter::NotGiven){
main(){
argument 'foo'
@ -129,7 +128,6 @@ class T < Test::Unit::TestCase
p = nil
m = nil
argv = %w[ 42 ]
given = nil
assert_nothing_raised{
main(argv.dup){
argument 'foo'
@ -144,7 +142,6 @@ class T < Test::Unit::TestCase
def test_0100
p = nil
argv = %w[]
given = nil
assert_nothing_raised{
main(argv){
p = argument('foo'){ optional }
@ -160,7 +157,6 @@ class T < Test::Unit::TestCase
def test_0101
p = nil
argv = %w[]
given = nil
assert_nothing_raised{
main(argv){
p = argument('foo'){ required false }
@ -492,12 +488,12 @@ class T < Test::Unit::TestCase
#
def test_0280
assert_nothing_raised{
u = Main::Usage.new
Main::Usage.new
}
end
def test_0290
assert_nothing_raised{
u = Main::Usage.default(Main.factory)
Main::Usage.default(Main.factory)
}
end
def test_0300
@ -733,32 +729,29 @@ class T < Test::Unit::TestCase
assert m.param['zero_or_more'].values == argv
end
def test_0450
m = nil
argv = %w()
assert_raises(Main::Parameter::NotGiven){
main(argv.dup) {
argument('one_or_more'){ arity(-2) }
run{ m = self }
run{ self }
}
}
end
def test_0460
m = nil
argv = %w( a )
assert_raises(Main::Parameter::Arity){
main(argv.dup) {
argument('two_or_more'){ arity(-3) }
run{ m = self }
run{ self }
}
}
end
def test_0470
m = nil
argv = %w( a )
assert_raises(Main::Parameter::Arity){
main(argv.dup) {
argument('two_or_more'){ arity(-4) }
run{ m = self }
run{ self }
}
}
end
@ -830,12 +823,11 @@ class T < Test::Unit::TestCase
#
def test_0500
name = 'arity_zero_paramter_attr'
m = nil
argv = %w( )
assert_raises(Main::Parameter::Arity){
main(argv.dup) {
argument(name){ arity 0 }
run{ m = self }
run{ self }
}
}
end
@ -897,7 +889,6 @@ class T < Test::Unit::TestCase
end
def test_0550
name = 'mode_argument_with_help_parameter_outputs_help'
p = nil
argv = %w( foo help )
assert_nothing_raised{

Loading…
Cancel
Save