main 6.2.2 → 6.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWI1M2RiNjdkN2U2MjdlODRiYmJkYTI0NmFmMTU3MmQzZDJhM2JjMQ==
5
- data.tar.gz: !binary |-
6
- NzQ0ZDRkYzc1MDVlMjAwMGRkYzUxNGU0Y2I1MmRhNzJjYzlkNjY1NQ==
2
+ SHA256:
3
+ metadata.gz: 812f2f08f43b6fe2bd462ccbe6e7bf61b1aa32918e0c7e32c8df3a5b712755a4
4
+ data.tar.gz: 7f4f1c339134823e8e0c05c162128bdca697f596b5de84ac0cfee9d1857d3aec
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- N2Q2MzAxY2JlNDUxNDczMGE0M2Y4MmJjYjAxMGQzYzllYTkxOTRjNmNmOGZl
10
- YzhlMDRkZTMyY2EwZTcwN2Q4YmU1NmQ1MGRlZTU3MGUxNDkwMDc4MTM5M2Ix
11
- ZTg3OTdjMWE0YmZmYzA3YjlkNzI5ZWJmNTRhYTNhZWYwMTkyYzY=
12
- data.tar.gz: !binary |-
13
- OTVjZjcwODE3ODIyODk5Yzk4NzQxYTc4Zjk4MTVhNTY3MjFlMTVjMzA2MTBi
14
- MzE2YzI3NzRkM2IyN2ZkNGIzNzE2NjI2OWUzZmQ4ZDY2MzdkODBiYWMwZTcx
15
- ZTU5YmE2ZGM0MzI1YTgyNzNiMGMyMzBlZTNjNjQ5ZmEzMTZiNjk=
6
+ metadata.gz: 9ece9cb6324614bb8dad6dd6d068ee213dc3cd0a6ab843e6e9d1c42b5ac0fc31731d30a74367ecf438aff8caff7ebdddb1851e93849bac437da9948da2718a9d
7
+ data.tar.gz: 86149dd72cefee37a167642925a2aeb9e16770bde7109b285aedbd747aba4a4dff782928c239a1fd696b4882574ecb0e0c394bb4cc3496d6172a7e2c56fa010c
@@ -1,7 +1,7 @@
1
1
  module Main
2
2
  # top level constants
3
3
  #
4
- Main::VERSION = '6.2.2' unless
4
+ Main::VERSION = '6.2.3' unless
5
5
  defined? Main::VERSION
6
6
  def Main.version() Main::VERSION end
7
7
 
@@ -11,7 +11,6 @@ module Main
11
11
 
12
12
  Main::LIBDIR = File.join(File.dirname(File.expand_path(__FILE__)), self.name.downcase, '') unless
13
13
  defined? Main::LIBDIR
14
- def self.libdir() Main::LIBDIR end
15
14
 
16
15
  Main::EXIT_SUCCESS = 0 unless defined? Main::EXIT_SUCCESS
17
16
  Main::EXIT_FAILURE = 1 unless defined? Main::EXIT_FAILURE
@@ -7,10 +7,15 @@ module Main
7
7
 
8
8
  List = []
9
9
 
10
- def self.cast m, &b
11
- define_method m, &b
12
- export m
13
- List << m.to_s
10
+ def Cast.cast(*args, &block)
11
+ if args.first && block
12
+ method = args.shift
13
+ define_method(method, &block)
14
+ export(method)
15
+ List << (method.to_s)
16
+ else
17
+ Cast.send(*args)
18
+ end
14
19
  end
15
20
 
16
21
  cast :boolean do |obj|
@@ -152,12 +157,7 @@ module Main
152
157
  m
153
158
  raise ArgumentError, "ambiguous cast: #{ sym.inspect } (#{ List.join ',' })" unless
154
159
  candidates.empty? or m.to_s == sym.to_s
155
- this = self
156
160
  lambda{|obj| method(m).call obj}
157
161
  end
158
-
159
- def Cast.cast(which, *args, &block)
160
- Cast.send(which, *args, &block)
161
- end
162
162
  end
163
163
  end
@@ -225,7 +225,7 @@ module Main
225
225
  begin
226
226
  cmd_stop
227
227
  break
228
- rescue Object => e
228
+ rescue Object
229
229
  if alive?
230
230
  sleep(rand)
231
231
  else
@@ -20,7 +20,6 @@ module Main
20
20
  end
21
21
 
22
22
  def find_by_mode m, options = {}
23
- quiet = options['quiet'] || options[:quiet]
24
23
  each_pair do |mode, klass|
25
24
  return mode if mode == m
26
25
  end
@@ -240,8 +240,6 @@ module Main
240
240
  self
241
241
  end
242
242
 
243
- this = self
244
-
245
243
  %w[ before instead after ].each do |which|
246
244
  getter = "error_handler_#{ which }"
247
245
  query = "error_handler_#{ which }?"
@@ -462,7 +460,7 @@ module Main
462
460
  i += 1
463
461
  b = argv[idx + 1]
464
462
  s = "#{ a }#{ b }"
465
- m, key, *ignored = kre.match(s).to_a
463
+ m, key, * = kre.match(s).to_a
466
464
  if m
467
465
  replacements[i] ||= a.gsub %r/^\s*#{ key }/, opt
468
466
  next
@@ -107,7 +107,6 @@ module Main
107
107
  #
108
108
  def dynamically_extend_via_commandline_modes!
109
109
  self.breadth_first_modes = modes.dup
110
- size = modes.size
111
110
 
112
111
  loop do
113
112
  modes.each do |mode|
@@ -185,7 +184,7 @@ module Main
185
184
  def usage(*args, &block)
186
185
  usage! unless defined? @usage
187
186
  return @usage if args.empty? and block.nil?
188
- key, value, *ignored = args
187
+ key, value, * = args
189
188
  value = block.call if block
190
189
  @usage[key.to_s] = value.to_s
191
190
  end
@@ -367,7 +366,7 @@ module Main
367
366
  else
368
367
  []
369
368
  end
370
- dash = lines.shift if lines.first.to_s =~ /^---/
369
+ lines.shift if lines.first.to_s =~ /^---/
371
370
  require 'fileutils' unless defined?(FileUtils)
372
371
  FileUtils.mkdir_p(File.dirname(config_path))
373
372
  open(config_path, 'w') do |fd|
@@ -11,10 +11,10 @@ module Main
11
11
 
12
12
  argv = options[:argv]
13
13
  env = options[:env]
14
- logger = options[:logger]
15
- stdin = options[:stdin]
16
- stdout = options[:stdout]
17
- stderr = options[:stderr]
14
+ #logger = options[:logger]
15
+ #stdin = options[:stdin]
16
+ #stdout = options[:stdout]
17
+ #stderr = options[:stderr]
18
18
 
19
19
  Main.push_ios!
20
20
 
@@ -142,27 +142,26 @@ module Main
142
142
 
143
143
  parameters = arguments + keywords + options + environment
144
144
 
145
- s =
146
- parameters.map do |p|
147
- ps = ''
148
- ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78)
149
- #ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78)
145
+ parameters.map do |p|
146
+ ps = ''
147
+ ps << Util.columnize("#{ p.synopsis }", :indent => 2, :width => 78)
148
+ #ps << Util.columnize("* #{ p.synopsis }", :indent => 2, :width => 78)
149
+ #ps << "\n"
150
+ if p.description?
151
+ ps << "\n"
152
+ ps << Util.columnize("#{ p.description }", :indent => 6, :width => 78)
153
+ #ps << Util.columnize(p.description, :indent => 6, :width => 78)
150
154
  #ps << "\n"
151
- if p.description?
155
+ end
156
+ #ps << "\n"
157
+ unless(p.examples.nil? or p.examples.empty?)
158
+ p.examples.each do |example|
152
159
  ps << "\n"
153
- ps << Util.columnize("#{ p.description }", :indent => 6, :width => 78)
154
- #ps << Util.columnize(p.description, :indent => 6, :width => 78)
155
- #ps << "\n"
160
+ ps << Util.columnize("#{ example }", :indent => 8, :width => 78)
156
161
  end
157
- #ps << "\n"
158
- unless(p.examples.nil? or p.examples.empty?)
159
- p.examples.each do |example|
160
- ps << "\n"
161
- ps << Util.columnize("#{ example }", :indent => 8, :width => 78)
162
- end
163
- end
164
- ps
165
- end.join("\n")
162
+ end
163
+ ps
164
+ end.join("\n")
166
165
  end
167
166
 
168
167
  def author_section
@@ -44,7 +44,7 @@ module Main
44
44
  def columnize buf, opts = {}
45
45
  width = Util.getopt 'width', opts, 80
46
46
  indent = Util.getopt 'indent', opts
47
- indent = Fixnum === indent ? (' ' * indent) : "#{ indent }"
47
+ indent = Numeric === indent ? (' ' * indent.to_i) : "#{ indent }"
48
48
  column = []
49
49
  words = buf.split %r/\s+/o
50
50
  row = "#{ indent }"
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "main"
6
- spec.version = "6.2.2"
6
+ spec.version = "6.2.3"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "main"
9
9
  spec.description = "a class factory and dsl for generating command line programs real quick"
@@ -14,7 +14,6 @@ Gem::Specification::new do |spec|
14
14
  "README.erb",
15
15
  "Rakefile",
16
16
  "TODO",
17
- "a.rb",
18
17
  "lib",
19
18
  "lib/main",
20
19
  "lib/main.rb",
@@ -117,7 +117,6 @@ class T < Test::Unit::TestCase
117
117
  # parameter parsing
118
118
  #
119
119
  def test_0080
120
- p = nil
121
120
  assert_raises(Main::Parameter::NotGiven){
122
121
  main(){
123
122
  argument 'foo'
@@ -129,7 +128,6 @@ class T < Test::Unit::TestCase
129
128
  p = nil
130
129
  m = nil
131
130
  argv = %w[ 42 ]
132
- given = nil
133
131
  assert_nothing_raised{
134
132
  main(argv.dup){
135
133
  argument 'foo'
@@ -144,7 +142,6 @@ class T < Test::Unit::TestCase
144
142
  def test_0100
145
143
  p = nil
146
144
  argv = %w[]
147
- given = nil
148
145
  assert_nothing_raised{
149
146
  main(argv){
150
147
  p = argument('foo'){ optional }
@@ -160,7 +157,6 @@ class T < Test::Unit::TestCase
160
157
  def test_0101
161
158
  p = nil
162
159
  argv = %w[]
163
- given = nil
164
160
  assert_nothing_raised{
165
161
  main(argv){
166
162
  p = argument('foo'){ required false }
@@ -492,12 +488,12 @@ class T < Test::Unit::TestCase
492
488
  #
493
489
  def test_0280
494
490
  assert_nothing_raised{
495
- u = Main::Usage.new
491
+ Main::Usage.new
496
492
  }
497
493
  end
498
494
  def test_0290
499
495
  assert_nothing_raised{
500
- u = Main::Usage.default(Main.factory)
496
+ Main::Usage.default(Main.factory)
501
497
  }
502
498
  end
503
499
  def test_0300
@@ -733,32 +729,29 @@ class T < Test::Unit::TestCase
733
729
  assert m.param['zero_or_more'].values == argv
734
730
  end
735
731
  def test_0450
736
- m = nil
737
732
  argv = %w()
738
733
  assert_raises(Main::Parameter::NotGiven){
739
734
  main(argv.dup) {
740
735
  argument('one_or_more'){ arity(-2) }
741
- run{ m = self }
736
+ run{ self }
742
737
  }
743
738
  }
744
739
  end
745
740
  def test_0460
746
- m = nil
747
741
  argv = %w( a )
748
742
  assert_raises(Main::Parameter::Arity){
749
743
  main(argv.dup) {
750
744
  argument('two_or_more'){ arity(-3) }
751
- run{ m = self }
745
+ run{ self }
752
746
  }
753
747
  }
754
748
  end
755
749
  def test_0470
756
- m = nil
757
750
  argv = %w( a )
758
751
  assert_raises(Main::Parameter::Arity){
759
752
  main(argv.dup) {
760
753
  argument('two_or_more'){ arity(-4) }
761
- run{ m = self }
754
+ run{ self }
762
755
  }
763
756
  }
764
757
  end
@@ -830,12 +823,11 @@ class T < Test::Unit::TestCase
830
823
  #
831
824
  def test_0500
832
825
  name = 'arity_zero_paramter_attr'
833
- m = nil
834
826
  argv = %w( )
835
827
  assert_raises(Main::Parameter::Arity){
836
828
  main(argv.dup) {
837
829
  argument(name){ arity 0 }
838
- run{ m = self }
830
+ run{ self }
839
831
  }
840
832
  }
841
833
  end
@@ -897,7 +889,6 @@ class T < Test::Unit::TestCase
897
889
  end
898
890
 
899
891
  def test_0550
900
- name = 'mode_argument_with_help_parameter_outputs_help'
901
892
  p = nil
902
893
  argv = %w( foo help )
903
894
  assert_nothing_raised{
metadata CHANGED
@@ -1,95 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: main
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.2
4
+ version: 6.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-20 00:00:00.000000000 Z
11
+ date: 2019-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.6'
20
- - - ! '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.6.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.6'
30
- - - ! '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.6.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: fattr
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
38
- - !ruby/object:Gem::Version
39
- version: '2.2'
40
- - - ! '>='
37
+ - - ">="
41
38
  - !ruby/object:Gem::Version
42
39
  version: 2.2.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
48
- - !ruby/object:Gem::Version
49
- version: '2.2'
50
- - - ! '>='
47
+ - - ">="
51
48
  - !ruby/object:Gem::Version
52
49
  version: 2.2.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: arrayfields
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ~>
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '4.7'
60
- - - ! '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 4.7.4
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '4.7'
70
- - - ! '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 4.7.4
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: map
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ~>
78
- - !ruby/object:Gem::Version
79
- version: '6.1'
80
- - - ! '>='
77
+ - - ">="
81
78
  - !ruby/object:Gem::Version
82
79
  version: 6.1.0
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.1'
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '6.1'
90
- - - ! '>='
87
+ - - ">="
91
88
  - !ruby/object:Gem::Version
92
89
  version: 6.1.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '6.1'
93
93
  description: a class factory and dsl for generating command line programs real quick
94
94
  email: ara.t.howard@gmail.com
95
95
  executables: []
@@ -100,7 +100,6 @@ files:
100
100
  - README.erb
101
101
  - Rakefile
102
102
  - TODO
103
- - a.rb
104
103
  - lib/main.rb
105
104
  - lib/main/cast.rb
106
105
  - lib/main/daemon.rb
@@ -139,19 +138,17 @@ require_paths:
139
138
  - lib
140
139
  required_ruby_version: !ruby/object:Gem::Requirement
141
140
  requirements:
142
- - - ! '>='
141
+ - - ">="
143
142
  - !ruby/object:Gem::Version
144
143
  version: '0'
145
144
  required_rubygems_version: !ruby/object:Gem::Requirement
146
145
  requirements:
147
- - - ! '>='
146
+ - - ">="
148
147
  - !ruby/object:Gem::Version
149
148
  version: '0'
150
149
  requirements: []
151
- rubyforge_project: codeforpeople
152
- rubygems_version: 2.6.8
150
+ rubygems_version: 3.0.3
153
151
  signing_key:
154
152
  specification_version: 4
155
153
  summary: main
156
154
  test_files: []
157
- has_rdoc:
data/a.rb DELETED
@@ -1,28 +0,0 @@
1
- require_relative './lib/main.rb'
2
-
3
- Main{
4
- daemonizes!
5
-
6
- def run
7
- i = 0
8
-
9
- loop do
10
- p argv
11
- p i
12
- sleep(3 + rand)
13
- i += 1
14
- end
15
- end
16
-
17
-
18
-
19
-
20
-
21
- }
22
-
23
-
24
- __END__
25
-
26
-
27
- a.rb daemon start
28
- a.rb daemon stop