clasp-ruby 0.18.0 → 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## Summary
4
4
 
5
- Example illustrating various kinds of *flag* and *option* aliases, including the combination of short-names.
5
+ Example illustrating various kinds of *flag* and *option* specifications, including the combination of short-names.
6
6
 
7
7
  ## Source
8
8
 
9
9
  ```ruby
10
10
  #!/usr/bin/env ruby
11
11
 
12
- # examples/flag_and_option_aliases.rb
12
+ # examples/flag_and_option_specifications.rb
13
13
 
14
14
  # requires
15
15
 
@@ -23,11 +23,11 @@ InfoLines = [
23
23
 
24
24
  'CLASP.Ruby examples',
25
25
  :version,
26
- "Illustrates use of CLASP.Ruby's use of flags, options, and aliases",
26
+ "Illustrates use of CLASP.Ruby's use of flags, options, and specifications",
27
27
  '',
28
28
  ]
29
29
 
30
- # Specify aliases, parse, and checking standard flags
30
+ # Specify specifications, parse, and checking standard flags
31
31
 
32
32
  Flag_Debug = CLASP.Flag('--debug', alias: '-d', help: 'runs in Debug mode')
33
33
  Option_Verbosity = CLASP.Option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ])
@@ -87,13 +87,13 @@ end
87
87
  If executed with no arguments
88
88
 
89
89
  ```
90
- ruby examples/flag_and_option_aliases.rb
90
+ ruby examples/flag_and_option_specifications.rb
91
91
  ```
92
92
 
93
93
  or (in a Unix shell):
94
94
 
95
95
  ```
96
- ./examples/flag_and_option_aliases.rb
96
+ ./examples/flag_and_option_specifications.rb
97
97
  ```
98
98
 
99
99
  it gives the output:
@@ -106,17 +106,17 @@ it gives the output:
106
106
  If executed with the arguments
107
107
 
108
108
  ```
109
- ruby examples/flag_and_option_aliases.rb --help
109
+ ruby examples/flag_and_option_specifications.rb --help
110
110
  ```
111
111
 
112
112
  it gives the output:
113
113
 
114
114
  ```
115
115
  CLASP.Ruby examples
116
- flag_and_option_aliases.rb 0.0.1
116
+ flag_and_option_specifications.rb 0.0.1
117
117
  Illustrates use of CLASP.Ruby's use of flags, options, and aliases
118
118
 
119
- USAGE: flag_and_option_aliases.rb [ ... flags and options ... ]
119
+ USAGE: flag_and_option_specifications.rb [ ... flags and options ... ]
120
120
 
121
121
  flags/options:
122
122
 
@@ -146,7 +146,7 @@ flags/options:
146
146
  If executed with the arguments
147
147
 
148
148
  ```
149
- ruby examples/flag_and_option_aliases.rb --debug --verbosity=silent
149
+ ruby examples/flag_and_option_specifications.rb --debug --verbosity=silent
150
150
  ```
151
151
 
152
152
  it gives the output:
@@ -161,7 +161,7 @@ Debug mode is specified
161
161
  If executed with the arguments
162
162
 
163
163
  ```
164
- ruby examples/flag_and_option_aliases.rb -v silent -d
164
+ ruby examples/flag_and_option_specifications.rb -v silent -d
165
165
  ```
166
166
 
167
167
  it gives the (same) output:
@@ -176,7 +176,7 @@ Debug mode is specified
176
176
  If executed with the arguments
177
177
 
178
178
  ```
179
- ruby examples/flag_and_option_aliases.rb -c -d
179
+ ruby examples/flag_and_option_specifications.rb -c -d
180
180
  ```
181
181
 
182
182
  it gives the output:
@@ -191,7 +191,7 @@ Debug mode is specified
191
191
  If executed with the arguments
192
192
 
193
193
  ```
194
- ruby examples/flag_and_option_aliases.rb -dc
194
+ ruby examples/flag_and_option_specifications.rb -dc
195
195
  ```
196
196
 
197
197
  it gives the (same) output:
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # examples/flag_and_option_aliases.rb
3
+ # examples/flag_and_option_specifications.rb
4
4
 
5
5
  # requires
6
6
 
@@ -18,7 +18,7 @@ InfoLines = [
18
18
  '',
19
19
  ]
20
20
 
21
- # Specify aliases, parse, and checking standard flags
21
+ # Specify specifications, parse, and checking standard flags
22
22
 
23
23
  Flag_Debug = CLASP.Flag('--debug', alias: '-d', help: 'runs in Debug mode')
24
24
  Option_Verbosity = CLASP.Option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ])
@@ -27,7 +27,7 @@ InfoLines = [
27
27
  '',
28
28
  ]
29
29
 
30
- # Specify aliases, parse, and checking standard flags
30
+ # Specify specifications, parse, and checking standard flags
31
31
 
32
32
  Specifications = [
33
33
 
@@ -18,7 +18,7 @@ InfoLines = [
18
18
  '',
19
19
  ]
20
20
 
21
- # Specify aliases, parse, and checking standard flags
21
+ # Specify specifications, parse, and checking standard flags
22
22
 
23
23
  Specifications = [
24
24
 
@@ -6,7 +6,7 @@
6
6
  # CLASP.Ruby
7
7
  #
8
8
  # Created: 14th February 2014
9
- # Updated: 10th April 2019
9
+ # Updated: 11th April 2019
10
10
  #
11
11
  # Home: http://github.com/synesissoftware/CLASP.Ruby
12
12
  #
@@ -46,7 +46,7 @@
46
46
 
47
47
 
48
48
 
49
- require File.join(File.dirname(__FILE__), 'aliases.rb')
49
+ require File.join(File.dirname(__FILE__), 'specifications.rb')
50
50
 
51
51
  require 'yaml'
52
52
 
@@ -575,7 +575,7 @@ class Arguments
575
575
 
576
576
  raise ArgumentError, "options must be nil or Hash - #{option.class} given" unless options.is_a? ::Hash
577
577
 
578
- specifications = options[:aliases] || @specifications
578
+ specifications = options[:specifications] || options[:aliases] || @specifications
579
579
 
580
580
  raise ArgumentError, "specifications may not be nil" if specifications.nil?
581
581
 
data/lib/clasp/clasp.rb CHANGED
@@ -5,13 +5,13 @@
5
5
  # Purpose: Common 'require file' for CLASP.Ruby library
6
6
  #
7
7
  # Created: 14th February 2014
8
- # Updated: 16th April 2016
8
+ # Updated: 11th April 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/CLASP.Ruby
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2014-2016, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2014-2019, Matthew Wilson and Synesis Software
15
15
  # All rights reserved.
16
16
  #
17
17
  # Redistribution and use in source and binary forms, with or without
@@ -46,9 +46,10 @@
46
46
 
47
47
 
48
48
  require 'clasp/arguments'
49
- require 'clasp/aliases'
49
+ require 'clasp/specifications'
50
50
  require 'clasp/cli'
51
51
  require 'clasp/version'
52
52
 
53
53
  # ############################## end of file ############################# #
54
54
 
55
+
data/lib/clasp/cli.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Purpose: Command-line interface
6
6
  #
7
7
  # Created: 27th July 2015
8
- # Updated: 10th April 2019
8
+ # Updated: 11th April 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/CLASP.Ruby
11
11
  #
@@ -64,7 +64,7 @@ module CLI_helpers_
64
64
 
65
65
  module Constants
66
66
 
67
- VALID_ALIAS_TYPES = [ FlagSpecification, OptionSpecification, Specification ]
67
+ VALID_ALIAS_TYPES = [ FlagSpecification, OptionSpecification, AliasSpecification ]
68
68
  VALID_ALIAS_TYPES_STRING = VALID_ALIAS_TYPES[0...-1].join(', ') + ', or ' + VALID_ALIAS_TYPES[-1].to_s
69
69
  end # module Constants
70
70
 
@@ -188,7 +188,7 @@ def self.show_usage specifications, options={}
188
188
 
189
189
  fas = {}
190
190
 
191
- specifications.select { |a| Specification === a }.each do |a|
191
+ specifications.select { |a| AliasSpecification === a }.each do |a|
192
192
 
193
193
  fas[a.name] = [] unless fas.has_key? $1
194
194
  fas[a.name] << a
@@ -208,7 +208,7 @@ def self.show_usage specifications, options={}
208
208
  specifications.each do |a|
209
209
 
210
210
  case a
211
- when Specification
211
+ when AliasSpecification
212
212
 
213
213
  next
214
214
  when FlagSpecification
data/lib/clasp/doc_.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Purpose: Documentation of the CLASP.Ruby modules
6
6
  #
7
7
  # Created: 11th June 2016
8
- # Updated: 14th February 2019
8
+ # Updated: 11th April 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/xqsr3
11
11
  #
@@ -51,7 +51,7 @@
51
51
  #
52
52
  # === Examples
53
53
  #
54
- # ==== Simple command-line, no aliases
54
+ # ==== Simple command-line, no specifications
55
55
  #
56
56
  # argv = %w{ --show-all=true infile -c outfile }
57
57
  #
@@ -82,7 +82,7 @@
82
82
  #
83
83
  # ==== Use of flag short forms
84
84
  #
85
- # aliases = [
85
+ # specifications = [
86
86
  #
87
87
  # CLASP.Flag('--verbose', alias: '-v'),
88
88
  # CLASP.Flag('--trace-output', aliases: [ '-t', '--trace' ]),
@@ -90,7 +90,7 @@
90
90
  #
91
91
  # argv = %w{ -trace -v }
92
92
  #
93
- # args = CLASP::Arguments.new(argv, aliases)
93
+ # args = CLASP::Arguments.new(argv, specifications)
94
94
  #
95
95
  # puts args.flags.size # => 2
96
96
  # puts args.flags[0].name # => "--trace-output"
@@ -100,7 +100,7 @@
100
100
  #
101
101
  # ==== Use of flag single short forms combined
102
102
  #
103
- # aliases = [
103
+ # specifications = [
104
104
  #
105
105
  # CLASP.Flag('--expand', alias: '-x'),
106
106
  # CLASP.Flag('--verbose', alias: '-v'),
@@ -109,7 +109,7 @@
109
109
  #
110
110
  # argv = %w{ -tvx }
111
111
  #
112
- # args = CLASP::Arguments.new(argv, aliases)
112
+ # args = CLASP::Arguments.new(argv, specifications)
113
113
  #
114
114
  # puts args.flags.size # => 3
115
115
  # puts args.options.size # => 0
@@ -117,14 +117,14 @@
117
117
  #
118
118
  # ==== Use of option short form
119
119
  #
120
- # aliases = [
120
+ # specifications = [
121
121
  #
122
122
  # CLASP.Option('--show-all', alias: '-a'),
123
123
  # ]
124
124
  #
125
125
  # argv = %w{ -c -a true infile outfile }
126
126
  #
127
- # args = CLASP::Arguments.new(argv, aliases)
127
+ # args = CLASP::Arguments.new(argv, specifications)
128
128
  #
129
129
  # puts args.flags.size # => 1
130
130
  # puts args.flags[0] # => "#<CLASP::Arguments::FlagArgument:0x007f8593b0ddd8 @arg="-c", @given_index=0, @given_name="-c", @argument_alias=nil, @given_hyphens=1, @given_label="c", @name="-c", @extras={}>"
@@ -1,6 +1,6 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: clasp/aliases.rb
3
+ # File: clasp/specifications.rb
4
4
  #
5
5
  # Purpose: Argument specification classes
6
6
  #
@@ -198,7 +198,7 @@ class OptionSpecification
198
198
  end
199
199
 
200
200
  # A class that represents an explicit alias for a flag or an option
201
- class Specification
201
+ class AliasSpecification
202
202
 
203
203
  def initialize(name, aliases)
204
204
 
@@ -379,13 +379,13 @@ def CLASP.Alias(name, *args)
379
379
  aliases = args
380
380
  end
381
381
 
382
- CLASP::Specification.new name, aliases
382
+ CLASP::AliasSpecification.new name, aliases
383
383
  end
384
384
 
385
385
  # ######################################################################## #
386
386
  # backwards-compatible
387
387
 
388
- Alias = Specification
388
+ Alias = AliasSpecification
389
389
  Flag = FlagSpecification
390
390
  FlagAlias = FlagSpecification
391
391
  Option = OptionSpecification
data/lib/clasp/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Purpose: Version for CLASP.Ruby library
6
6
  #
7
7
  # Created: 16th November 2014
8
- # Updated: 10th April 2019
8
+ # Updated: 11th April 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/CLASP.Ruby
11
11
  #
@@ -51,7 +51,7 @@
51
51
  module CLASP
52
52
 
53
53
  # Current version of the CLASP.Ruby library
54
- VERSION = '0.18.0'
54
+ VERSION = '0.18.1'
55
55
 
56
56
  private
57
57
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -67,3 +67,4 @@ end # module CLASP
67
67
 
68
68
  # ############################## end of file ############################# #
69
69
 
70
+
@@ -8,13 +8,13 @@ Specifications = [
8
8
 
9
9
  CLASP.Flag('--help', help: 'shows this help and quits'),
10
10
  CLASP.Flag('--version', alias: '-v', help: 'shows this version and quits'),
11
- CLASP.Specification('--version', aliases: [ '-ver', '-V' ]),
11
+ CLASP.Alias('--version', aliases: [ '-ver', '-V' ]),
12
12
 
13
13
  CLASP.Option('--directory', alias: '-d', help: 'a directory within which to process'),
14
14
  CLASP.Option('--patterns', alias: '-p', help: "one or more patterns against which the entries will be matched, separated by '|' or the platform-specific separator - ':' UNIX, ';' Windows"),
15
15
 
16
16
  CLASP.Option('--case-sensitive', alias: '-c', help: 'determines whether case sensitive', values_range: %W{ yes no true false }, default_value: false),
17
- CLASP.Specification('--case-sensitive=false', alias: '-I'),
17
+ CLASP.Alias('--case-sensitive=false', alias: '-I'),
18
18
  ]
19
19
 
20
20
  Arguments = CLASP::Arguments.new(ARGV, Specifications)
@@ -10,12 +10,12 @@ puts
10
10
  puts '*' * 40
11
11
  puts 'usage:'
12
12
  puts
13
- CLASP.show_usage(Arguments.aliases)
13
+ CLASP.show_usage(Arguments.specifications)
14
14
  puts '*' * 40
15
15
 
16
16
  puts 'version:'
17
17
  puts
18
- CLASP.show_version Arguments.aliases, version: [ 1, 2, 3 ]
18
+ CLASP.show_version Arguments.specifications, version: [ 1, 2, 3 ]
19
19
  puts '*' * 40
20
20
 
21
21
  __END__
@@ -10,13 +10,13 @@ class Test_Arguments_4 < Test::Unit::TestCase
10
10
 
11
11
  def test_ARGV_rewrite_1
12
12
 
13
- aliases = nil
13
+ specifications = nil
14
14
  argv = [ 'val1', '-f1', 'val2', '--' ]
15
15
 
16
16
  assert_equal 'val1|-f1|val2|--', argv.join('|')
17
17
 
18
18
  argv_c = argv.dup
19
- args = CLASP::Arguments.new argv, aliases
19
+ args = CLASP::Arguments.new argv, specifications
20
20
 
21
21
  assert_equal 'val1|-f1|val2|--', argv.join('|')
22
22
 
@@ -39,10 +39,10 @@ class Test_Arguments_4 < Test::Unit::TestCase
39
39
 
40
40
  def test_ARGV_rewrite_2
41
41
 
42
- aliases = nil
42
+ specifications = nil
43
43
  argv = [ 'val1', '-f1', 'val2', '--' ]
44
44
  argv_c = argv.dup
45
- args = CLASP::Arguments.new argv, aliases, mutate_argv: false
45
+ args = CLASP::Arguments.new argv, specifications, mutate_argv: false
46
46
 
47
47
  assert_equal 1, args.flags.size
48
48
  assert_equal Hash.new, args.flags[0].extras
@@ -293,11 +293,11 @@ class Test_Arguments < Test::Unit::TestCase
293
293
 
294
294
  def test_double_hyphen_3
295
295
 
296
- aliases = [
296
+ specifications = [
297
297
 
298
298
  CLASP.Option('--password', alias: '-p', extras: 'extra'),
299
299
  ]
300
- args = CLASP::Arguments.new [ '-f1', 'value1', '-p', '--', 'value2' ], aliases
300
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-p', '--', 'value2' ], specifications
301
301
 
302
302
  assert_equal 1, args.flags.size
303
303
  assert_equal '-f1', args.flags[0].to_s
@@ -322,11 +322,11 @@ class Test_Arguments < Test::Unit::TestCase
322
322
  assert_equal 'value2', args.values[1]
323
323
  end
324
324
 
325
- def test_flag_aliases_1
325
+ def test_flag_specifications_1
326
326
 
327
- aliases = [
327
+ specifications = [
328
328
  ]
329
- args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete' ], aliases
329
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete' ], specifications
330
330
 
331
331
  assert_equal 3, args.flags.size
332
332
  assert_equal '-f1', args.flags[0].to_s
@@ -357,13 +357,13 @@ class Test_Arguments < Test::Unit::TestCase
357
357
  assert_equal 'value1', args.values[0]
358
358
  end
359
359
 
360
- def test_flag_aliases_2
360
+ def test_flag_specifications_2
361
361
 
362
- aliases = [
362
+ specifications = [
363
363
 
364
364
  CLASP.Flag('--expand', alias: '-x')
365
365
  ]
366
- args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete' ], aliases
366
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete' ], specifications
367
367
 
368
368
  assert_equal 3, args.flags.size
369
369
  assert_equal '-f1', args.flags[0].to_s
@@ -378,7 +378,7 @@ class Test_Arguments < Test::Unit::TestCase
378
378
  assert_equal 'x', args.flags[1].given_label
379
379
  assert_equal '-x', args.flags[1].given_name
380
380
  assert_equal 1, args.flags[1].given_hyphens
381
- assert_equal aliases[0], args.flags[1].argument_alias
381
+ assert_equal specifications[0], args.flags[1].argument_alias
382
382
  assert_equal Hash.new, args.flags[1].extras
383
383
  assert_equal '--delete', args.flags[2].to_s
384
384
  assert_equal '--delete', args.flags[2].name
@@ -394,13 +394,13 @@ class Test_Arguments < Test::Unit::TestCase
394
394
  assert_equal 'value1', args.values[0]
395
395
  end
396
396
 
397
- def test_flag_aliases_3
397
+ def test_flag_specifications_3
398
398
 
399
- aliases = [
399
+ specifications = [
400
400
 
401
401
  CLASP.Flag('--expand', aliases: [ '-x', '--x' ], extras: %w{ e x t r a })
402
402
  ]
403
- args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete', '--x' ], aliases
403
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-x', '--delete', '--x' ], specifications
404
404
 
405
405
  assert_equal 4, args.flags.size
406
406
  assert_equal '-f1', args.flags[0].to_s
@@ -415,7 +415,7 @@ class Test_Arguments < Test::Unit::TestCase
415
415
  assert_equal 'x', args.flags[1].given_label
416
416
  assert_equal '-x', args.flags[1].given_name
417
417
  assert_equal 1, args.flags[1].given_hyphens
418
- assert_equal aliases[0], args.flags[1].argument_alias
418
+ assert_equal specifications[0], args.flags[1].argument_alias
419
419
  assert_equal [ 'e', 'x', 't', 'r', 'a' ], args.flags[1].extras
420
420
  assert_equal '--delete', args.flags[2].to_s
421
421
  assert_equal '--delete', args.flags[2].name
@@ -429,7 +429,7 @@ class Test_Arguments < Test::Unit::TestCase
429
429
  assert_equal 'x', args.flags[3].given_label
430
430
  assert_equal '--x', args.flags[3].given_name
431
431
  assert_equal 2, args.flags[3].given_hyphens
432
- assert_equal aliases[0], args.flags[3].argument_alias
432
+ assert_equal specifications[0], args.flags[3].argument_alias
433
433
  assert_equal [ 'e', 'x', 't', 'r', 'a' ], args.flags[3].extras
434
434
 
435
435
  assert_equal 0, args.options.size
@@ -438,11 +438,11 @@ class Test_Arguments < Test::Unit::TestCase
438
438
  assert_equal 'value1', args.values[0]
439
439
  end
440
440
 
441
- def test_option_aliases_1
441
+ def test_option_specifications_1
442
442
 
443
- aliases = [
443
+ specifications = [
444
444
  ]
445
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o=value' ], aliases
445
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o=value' ], specifications
446
446
 
447
447
  assert_equal 1, args.flags.size
448
448
  assert_equal '-f1', args.flags[0].to_s
@@ -465,13 +465,13 @@ class Test_Arguments < Test::Unit::TestCase
465
465
  assert_equal 'value1', args.values[0]
466
466
  end
467
467
 
468
- def test_option_aliases_2
468
+ def test_option_specifications_2
469
469
 
470
- aliases = [
470
+ specifications = [
471
471
 
472
472
  CLASP.Option('--option', aliases: [ '-o' ])
473
473
  ]
474
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o=value' ], aliases
474
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o=value' ], specifications
475
475
 
476
476
  assert_equal 1, args.flags.size
477
477
  assert_equal '-f1', args.flags[0].to_s
@@ -494,13 +494,13 @@ class Test_Arguments < Test::Unit::TestCase
494
494
  assert_equal 'value1', args.values[0]
495
495
  end
496
496
 
497
- def test_option_aliases_3
497
+ def test_option_specifications_3
498
498
 
499
- aliases = [
499
+ specifications = [
500
500
 
501
501
  CLASP.Option('--option', aliases: [ '-o' ])
502
502
  ]
503
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value' ], aliases
503
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value' ], specifications
504
504
 
505
505
  assert_equal 1, args.flags.size
506
506
  assert_equal '-f1', args.flags[0].to_s
@@ -523,14 +523,14 @@ class Test_Arguments < Test::Unit::TestCase
523
523
  assert_equal 'value1', args.values[0]
524
524
  end
525
525
 
526
- def test_option_default_aliases_1
526
+ def test_option_default_specifications_1
527
527
 
528
- aliases = [
528
+ specifications = [
529
529
 
530
530
  CLASP.Option('--option', aliases: [ '-o' ]),
531
531
  CLASP.Option('--option=special-value', alias: '-s')
532
532
  ]
533
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-s', '-s=explicit-value' ], aliases
533
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-s', '-s=explicit-value' ], specifications
534
534
 
535
535
  assert_equal 1, args.flags.size
536
536
  assert_equal '-f1', args.flags[0].to_s
@@ -567,15 +567,15 @@ class Test_Arguments < Test::Unit::TestCase
567
567
  assert_equal 'value1', args.values[0]
568
568
  end
569
569
 
570
- def test_option_default_aliases_2
570
+ def test_option_default_specifications_2
571
571
 
572
- aliases = [
572
+ specifications = [
573
573
 
574
574
  CLASP.Option('--option', aliases: [ '-o' ]),
575
575
  CLASP.Flag('--option=special-value', alias: '-s'),
576
576
  CLASP.Flag('--verbose', alias: '-v'),
577
577
  ]
578
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-sv', '-s=explicit-value' ], aliases
578
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-sv', '-s=explicit-value' ], specifications
579
579
 
580
580
  assert_equal 2, args.flags.size
581
581
  flag = args.flags[0]
@@ -628,15 +628,15 @@ class Test_Arguments < Test::Unit::TestCase
628
628
  assert_equal 'value1', args.values[0]
629
629
  end
630
630
 
631
- def test_option_default_aliases_3
631
+ def test_option_default_specifications_3
632
632
 
633
- aliases = [
633
+ specifications = [
634
634
 
635
635
  CLASP.Option('--option', aliases: [ '-o' ]),
636
636
  CLASP.Flag('--option=special-value', alias: '-s'),
637
637
  CLASP.Flag('-v'),
638
638
  ]
639
- args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-sv', '-s=explicit-value' ], aliases
639
+ args = CLASP::Arguments.new [ '-f1', 'value1', '-o', 'value', '-sv', '-s=explicit-value' ], specifications
640
640
 
641
641
  assert_equal 2, args.flags.size
642
642
  flag = args.flags[0]
@@ -10,9 +10,9 @@ class Test_Arguments_2 < Test::Unit::TestCase
10
10
 
11
11
  def test_combined_flags_0
12
12
 
13
- aliases = [
13
+ specifications = [
14
14
  ]
15
- args = CLASP::Arguments.new [ '-abc' ], aliases
15
+ args = CLASP::Arguments.new [ '-abc' ], specifications
16
16
 
17
17
  assert_equal 1, args.flags.size
18
18
  assert_equal '-abc', args.flags[0].name
@@ -29,31 +29,31 @@ class Test_Arguments_2 < Test::Unit::TestCase
29
29
 
30
30
  def test_combined_flags_1
31
31
 
32
- aliases = [
32
+ specifications = [
33
33
  CLASP.Flag('--a', alias: '-a'),
34
34
  CLASP.Flag('--b', alias: '-b'),
35
35
  CLASP.Flag('--c', alias: '-c'),
36
36
  ]
37
- args = CLASP::Arguments.new [ '-abc' ], aliases
37
+ args = CLASP::Arguments.new [ '-abc' ], specifications
38
38
 
39
39
  assert_equal 3, args.flags.size
40
40
  assert_equal '--a', args.flags[0].name
41
41
  assert_equal '--a', args.flags[0].to_s
42
42
  assert_equal 'abc', args.flags[0].given_label
43
43
  assert_equal 1, args.flags[0].given_hyphens
44
- assert_equal aliases[0], args.flags[0].argument_alias
44
+ assert_equal specifications[0], args.flags[0].argument_alias
45
45
  assert_equal Hash.new, args.flags[0].extras
46
46
  assert_equal '--b', args.flags[1].name
47
47
  assert_equal '--b', args.flags[1].to_s
48
48
  assert_equal 'abc', args.flags[1].given_label
49
49
  assert_equal 1, args.flags[1].given_hyphens
50
- assert_equal aliases[1], args.flags[1].argument_alias
50
+ assert_equal specifications[1], args.flags[1].argument_alias
51
51
  assert_equal Hash.new, args.flags[1].extras
52
52
  assert_equal '--c', args.flags[2].name
53
53
  assert_equal '--c', args.flags[2].to_s
54
54
  assert_equal 'abc', args.flags[2].given_label
55
55
  assert_equal 1, args.flags[2].given_hyphens
56
- assert_equal aliases[2], args.flags[2].argument_alias
56
+ assert_equal specifications[2], args.flags[2].argument_alias
57
57
  assert_equal Hash.new, args.flags[2].extras
58
58
 
59
59
  assert_equal 0, args.options.size
data/test/unit/tc_cli.rb CHANGED
@@ -14,9 +14,9 @@ class Test_CLI < Test::Unit::TestCase
14
14
 
15
15
  def test_invalid_aliases_types
16
16
 
17
- assert_raise_with_message(::TypeError, /each element in (?:aliases|specifications) array must be one of the types CLASP::FlagSpecification, CLASP::OptionSpecification, or CLASP::Specification/) { CLASP.show_usage([ 'abc', :def ]) }
17
+ assert_raise_with_message(::TypeError, /each element in (?:aliases|specifications) array must be one of the types CLASP::FlagSpecification, CLASP::OptionSpecification, or CLASP::AliasSpecification/) { CLASP.show_usage([ 'abc', :def ]) }
18
18
 
19
- assert_raise_with_message(::TypeError, /each element in (?:aliases|specifications) array must be one of the types CLASP::FlagSpecification, CLASP::OptionSpecification, or CLASP::Specification/) { CLASP.show_version([ 'abc', :def ]) }
19
+ assert_raise_with_message(::TypeError, /each element in (?:aliases|specifications) array must be one of the types CLASP::FlagSpecification, CLASP::OptionSpecification, or CLASP::AliasSpecification/) { CLASP.show_version([ 'abc', :def ]) }
20
20
  end
21
21
  end
22
22
 
@@ -44,7 +44,7 @@ class Test_Examples < Test::Unit::TestCase
44
44
 
45
45
  def test_UseOfFlagShortForms
46
46
 
47
- aliases = [
47
+ specifications = [
48
48
 
49
49
  CLASP.Flag('--verbose', alias: '-v'),
50
50
  CLASP.Flag('--trace-output', aliases: [ '-t', '--trace' ]),
@@ -52,7 +52,7 @@ class Test_Examples < Test::Unit::TestCase
52
52
 
53
53
  argv = %w{ --trace -v }
54
54
 
55
- args = CLASP::Arguments.new(argv, aliases)
55
+ args = CLASP::Arguments.new(argv, specifications)
56
56
 
57
57
  assert_equal 2, args.flags.size
58
58
  flag = args.flags[0]
@@ -67,7 +67,7 @@ class Test_Examples < Test::Unit::TestCase
67
67
 
68
68
  def test_UseOfFlagSingleShortFormsCombined
69
69
 
70
- aliases = [
70
+ specifications = [
71
71
 
72
72
  CLASP.Flag('--expand', alias: '-x'),
73
73
  CLASP.Flag('--verbose', alias: '-v'),
@@ -76,7 +76,7 @@ class Test_Examples < Test::Unit::TestCase
76
76
 
77
77
  argv = %w{ -tvx }
78
78
 
79
- args = CLASP::Arguments.new(argv, aliases)
79
+ args = CLASP::Arguments.new(argv, specifications)
80
80
 
81
81
  assert_equal 3, args.flags.size
82
82
  flag = args.flags[0]
@@ -94,14 +94,14 @@ class Test_Examples < Test::Unit::TestCase
94
94
 
95
95
  def test_UseOfOptionShortForm
96
96
 
97
- aliases = [
97
+ specifications = [
98
98
 
99
99
  CLASP.Option('--show-all', alias: '-a'),
100
100
  ]
101
101
 
102
102
  argv = %w{ -c -a true infile outfile }
103
103
 
104
- args = CLASP::Arguments.new(argv, aliases)
104
+ args = CLASP::Arguments.new(argv, specifications)
105
105
 
106
106
  assert_equal 1, args.flags.size
107
107
  flag = args.flags[0]
@@ -118,7 +118,7 @@ class Test_Examples < Test::Unit::TestCase
118
118
 
119
119
  def test_UseOfFlagsAsSpecificationsForOption
120
120
 
121
- aliases = [
121
+ specifications = [
122
122
 
123
123
  CLASP.Flag('--dump-contents', alias: '-d'),
124
124
  CLASP.Option('--log-level', alias: '-l'),
@@ -127,7 +127,7 @@ class Test_Examples < Test::Unit::TestCase
127
127
 
128
128
  argv = %w{ myfile -dw }
129
129
 
130
- args = CLASP::Arguments.new(argv, aliases)
130
+ args = CLASP::Arguments.new(argv, specifications)
131
131
 
132
132
  assert_equal 1, args.flags.size
133
133
  flag = args.flags[0]
@@ -8,9 +8,9 @@ require 'test/unit'
8
8
 
9
9
  class Test_Specifications_1 < Test::Unit::TestCase
10
10
 
11
- def test_option_with_two_flag_aliases
11
+ def test_option_with_two_flag_specifications
12
12
 
13
- aliases = [
13
+ specifications = [
14
14
 
15
15
  CLASP.Flag('--action=list', alias: '-l'),
16
16
  CLASP.Flag('--action=change', alias: '-c'),
@@ -21,7 +21,7 @@ class Test_Specifications_1 < Test::Unit::TestCase
21
21
  begin
22
22
 
23
23
  argv = []
24
- args = CLASP::Arguments.new argv, aliases
24
+ args = CLASP::Arguments.new argv, specifications
25
25
 
26
26
  assert_equal 0, args.flags.size
27
27
  assert_equal 0, args.options.size
@@ -32,7 +32,7 @@ class Test_Specifications_1 < Test::Unit::TestCase
32
32
  begin
33
33
 
34
34
  argv = %w{ --action=action1 }
35
- args = CLASP::Arguments.new argv, aliases
35
+ args = CLASP::Arguments.new argv, specifications
36
36
 
37
37
  assert_equal 0, args.flags.size
38
38
  assert_equal 1, args.options.size
@@ -46,7 +46,7 @@ class Test_Specifications_1 < Test::Unit::TestCase
46
46
  begin
47
47
 
48
48
  argv = %w{ -a action2 }
49
- args = CLASP::Arguments.new argv, aliases
49
+ args = CLASP::Arguments.new argv, specifications
50
50
 
51
51
  assert_equal 0, args.flags.size
52
52
  assert_equal 1, args.options.size
@@ -60,7 +60,7 @@ class Test_Specifications_1 < Test::Unit::TestCase
60
60
  begin
61
61
 
62
62
  argv = %w{ -c }
63
- args = CLASP::Arguments.new argv, aliases
63
+ args = CLASP::Arguments.new argv, specifications
64
64
 
65
65
  assert_equal 0, args.flags.size
66
66
  assert_equal 1, args.options.size
@@ -12,42 +12,42 @@ class Test_Usage < Test::Unit::TestCase
12
12
 
13
13
  def test_empty_default
14
14
 
15
- aliases = []
15
+ specifications = []
16
16
 
17
17
  stream = StringIO.new
18
18
 
19
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog'
19
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog'
20
20
 
21
21
  assert_equal "USAGE: myprog [ ... flags and options ... ]\n\n", stream.string
22
22
  end
23
23
 
24
24
  def test_empty_all
25
25
 
26
- aliases = []
26
+ specifications = []
27
27
 
28
28
  stream = StringIO.new
29
29
 
30
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog', flags_and_options: ''
30
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: ''
31
31
 
32
32
  assert_equal "USAGE: myprog\n\n", stream.string
33
33
  end
34
34
 
35
35
  def test_empty_all_with_info_line_of_one_string
36
36
 
37
- aliases = []
37
+ specifications = []
38
38
 
39
39
  stream = StringIO.new
40
40
 
41
41
  info = 'myprog version'.freeze
42
42
 
43
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info
43
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info
44
44
 
45
45
  assert_equal "myprog version\nUSAGE: myprog\n\n", stream.string
46
46
  end
47
47
 
48
48
  def test_empty_all_with_info_lines
49
49
 
50
- aliases = []
50
+ specifications = []
51
51
 
52
52
  stream = StringIO.new
53
53
 
@@ -57,14 +57,14 @@ class Test_Usage < Test::Unit::TestCase
57
57
  'version 1',
58
58
  ].freeze
59
59
 
60
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines
60
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines
61
61
 
62
62
  assert_equal "Synesis Software My Program\nversion 1\nUSAGE: myprog\n\n", stream.string
63
63
  end
64
64
 
65
65
  def test_empty_all_with_info_lines_including_version
66
66
 
67
- aliases = []
67
+ specifications = []
68
68
 
69
69
  stream = StringIO.new
70
70
 
@@ -74,35 +74,35 @@ class Test_Usage < Test::Unit::TestCase
74
74
  :version
75
75
  ].freeze
76
76
 
77
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines, version: [ 1, 0, 1], version_prefix: 'v'
77
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: '', info_lines: info_lines, version: [ 1, 0, 1], version_prefix: 'v'
78
78
 
79
79
  assert_equal "Synesis Software My Program\nmyprog v1.0.1\nUSAGE: myprog\n\n", stream.string
80
80
  end
81
81
 
82
82
  def test_one_alias_default
83
83
 
84
- aliases = [
84
+ specifications = [
85
85
 
86
86
  CLASP::Flag.Version
87
87
  ]
88
88
 
89
89
  stream = StringIO.new
90
90
 
91
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog'
91
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog'
92
92
 
93
93
  assert_equal "USAGE: myprog [ ... flags and options ... ]\n\nflags/options:\n\n\t--version\n\t\t#{CLASP::Flag.Version.help}\n\n", stream.string
94
94
  end
95
95
 
96
96
  def test_one_alias_all
97
97
 
98
- aliases = [
98
+ specifications = [
99
99
 
100
100
  CLASP::Flag.Version
101
101
  ]
102
102
 
103
103
  stream = StringIO.new
104
104
 
105
- CLASP.show_usage aliases, stream: stream, program_name: 'myprog', flags_and_options: ''
105
+ CLASP.show_usage specifications, stream: stream, program_name: 'myprog', flags_and_options: ''
106
106
 
107
107
  assert_equal "USAGE: myprog\n\nflags/options:\n\n\t--version\n\t\t#{CLASP::Flag.Version.help}\n\n", stream.string
108
108
  end
metadata CHANGED
@@ -1,93 +1,104 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clasp-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Matt Wilson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
12
+ date: 2019-04-11 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: xqsr3
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0.30'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.30'
27
- description: |
28
- Command-Line Argument Sorting and Parsing library that provides a powerful
29
- abstraction of command-line interpretation facilities. CLASP.Ruby is a Ruby port of the popular CLASP (C/C++) library, and provides declarative specification of command-line flags and options, aliasing, flag combination, UNIX de-facto standard flag processing, and a number of utility functions for expressing usage and version information.
30
+ description: ! 'Command-Line Argument Sorting and Parsing library that provides a
31
+ powerful
32
+
33
+ abstraction of command-line interpretation facilities. CLASP.Ruby is a Ruby port
34
+ of the popular CLASP (C/C++) library, and provides declarative specification of
35
+ command-line flags and options, aliasing, flag combination, UNIX de-facto standard
36
+ flag processing, and a number of utility functions for expressing usage and version
37
+ information.
38
+
39
+ '
30
40
  email: matthew@synesis.com.au
31
41
  executables: []
32
42
  extensions: []
33
43
  extra_rdoc_files: []
34
44
  files:
35
- - LICENSE
36
- - README.md
37
45
  - examples/cr-example.rb
38
- - examples/flag_and_option_aliases.md
39
- - examples/flag_and_option_aliases.rb
46
+ - examples/flag_and_option_specifications.md
47
+ - examples/flag_and_option_specifications.rb
40
48
  - examples/show_usage_and_version.md
41
49
  - examples/show_usage_and_version.rb
42
- - lib/clasp-ruby.rb
43
- - lib/clasp.rb
44
- - lib/clasp/aliases.rb
45
50
  - lib/clasp/arguments.rb
46
51
  - lib/clasp/clasp.rb
47
52
  - lib/clasp/cli.rb
48
53
  - lib/clasp/doc_.rb
49
54
  - lib/clasp/old_module.rb
55
+ - lib/clasp/specifications.rb
50
56
  - lib/clasp/version.rb
51
- - test/scratch/test_aliases.rb
57
+ - lib/clasp-ruby.rb
58
+ - lib/clasp.rb
52
59
  - test/scratch/test_list_command_line.rb
60
+ - test/scratch/test_specifications.rb
53
61
  - test/scratch/test_usage.rb
54
62
  - test/scratch/test_usage_from_DATA.rb
55
- - test/scratch/test_usage_with_duplicate_aliases.rb
56
- - test/unit/tc_ARGV_rewrite.rb
57
- - test/unit/tc_aliases.rb
63
+ - test/scratch/test_usage_with_duplicate_specifications.rb
58
64
  - test/unit/tc_arguments_1.rb
59
65
  - test/unit/tc_arguments_2.rb
60
66
  - test/unit/tc_arguments_3.rb
61
67
  - test/unit/tc_arguments_inspect.rb
68
+ - test/unit/tc_ARGV_rewrite.rb
62
69
  - test/unit/tc_cli.rb
63
70
  - test/unit/tc_defaults_1.rb
64
71
  - test/unit/tc_examples_Arguments.rb
65
72
  - test/unit/tc_extras.rb
66
73
  - test/unit/tc_option_required.rb
74
+ - test/unit/tc_specifications.rb
67
75
  - test/unit/tc_usage.rb
68
76
  - test/unit/ts_all.rb
77
+ - README.md
78
+ - LICENSE
69
79
  homepage: http://github.com/synesissoftware/CLASP.Ruby
70
80
  licenses:
71
81
  - BSD-3-Clause
72
- metadata: {}
73
82
  post_install_message:
74
83
  rdoc_options: []
75
84
  require_paths:
76
85
  - lib
77
86
  required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
78
88
  requirements:
79
- - - ">="
89
+ - - ! '>='
80
90
  - !ruby/object:Gem::Version
81
91
  version: 1.9.3
82
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
83
94
  requirements:
84
- - - ">="
95
+ - - ! '>='
85
96
  - !ruby/object:Gem::Version
86
97
  version: '0'
87
98
  requirements: []
88
99
  rubyforge_project:
89
- rubygems_version: 2.6.11
100
+ rubygems_version: 1.8.23.2
90
101
  signing_key:
91
- specification_version: 4
102
+ specification_version: 3
92
103
  summary: CLASP.Ruby
93
104
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 119fcad10a9c01d575d47bc9f495fda5bb1869d1
4
- data.tar.gz: 3a4c4edbf579ce92c968833ba2f13a857a7f69dd
5
- SHA512:
6
- metadata.gz: e7aa695f6ef62302ac3fb64a815017e8f256130c29abcbf9b81aeb82f378cd4233f8435b0355acc91d2c24c35107809c6fa9fbcfb171f28c50b5ed5aa3018277
7
- data.tar.gz: f0347ac65f0a4ba087c486ba2d5492890fd3f69240e547c1c3b7371d59c5c178417179fa86592a786b9816bc5b296af17bc23a23adba5d3ff85830c473751d66