clasp-ruby 0.22.1 → 0.23.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cdf702af24b59501e6bbe93ba1985416e7793a7dd3dd2a3cfedae7847156a2a
4
- data.tar.gz: 6efa37c0a5f2914498de32916f6d6be2fbe79ab87d0af3a32f10dc5163595309
3
+ metadata.gz: 1e021c90f3ea92340418a827f98a4fcb3c3f1369b023b0374f90e224acb8f01c
4
+ data.tar.gz: 62ed469712505ebbf289e7b642e48525f37f21dc1223cf8f13dca107f3b1a1f4
5
5
  SHA512:
6
- metadata.gz: 5660b7d456acadbbaeacbfb04f83cfb2dfe94b5918cb731a7194fe0da0efba198e1be3196870fb1ea338cf489e528b703d406e8cee949065e234764181ac2a47
7
- data.tar.gz: 83c5cbbb81fd29695e7c00f600bcfc5812854534c5dae6d61812e9ee1d9c68e058aa21c493adced37c3121e54cf724f048b7cf7bd700cff8f91ffbb1440499de
6
+ metadata.gz: 462eca92c73b9eefd0846cb64567d1b2071570789c0beb6cc0802e443e1e6a3c762ec39f57e438781d0b53e8d31310dc765a8e108d77ff989795d24bae7c1239
7
+ data.tar.gz: e7b1b47f51ea4e724412e2ffa634a1e8e47118f00f32b133735656c98f0e9b18c3286b1b77ba7e409545340e248b50c187c1939e6275a34ee36025ad17eb7b81
@@ -6,12 +6,13 @@
6
6
  # CLASP.Ruby
7
7
  #
8
8
  # Created: 14th February 2014
9
- # Updated: 20th April 2019
9
+ # Updated: 24th July 2022
10
10
  #
11
11
  # Home: http://github.com/synesissoftware/CLASP.Ruby
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
+ # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
15
16
  # Copyright (c) 2014-2019, Matthew Wilson and Synesis Software
16
17
  # All rights reserved.
17
18
  #
@@ -418,7 +419,7 @@ class Arguments
418
419
 
419
420
  specifications = nil if specifications and specifications.empty?
420
421
 
421
- flags, options, values = Arguments.parse_(argv, specifications)
422
+ flags, options, values, double_slash_index = Arguments.parse_(argv, specifications)
422
423
 
423
424
  [ flags, options, values ].each do |ar|
424
425
 
@@ -455,6 +456,8 @@ class Arguments
455
456
  @options = options.freeze
456
457
  @values = values.freeze
457
458
 
459
+ @double_slash_index = double_slash_index
460
+
458
461
  # do argv-mutation, if required
459
462
  if init_opts[:mutate_argv]
460
463
 
@@ -484,6 +487,8 @@ class Arguments
484
487
  options = []
485
488
  values = []
486
489
 
490
+ double_slash_index = nil
491
+
487
492
  forced_value = false
488
493
  pending_option = nil
489
494
 
@@ -495,6 +500,9 @@ class Arguments
495
500
 
496
501
  # all subsequent arguments are values
497
502
  forced_value = true
503
+
504
+ double_slash_index = index if double_slash_index.nil?
505
+
498
506
  next
499
507
  end
500
508
 
@@ -575,7 +583,7 @@ class Arguments
575
583
  # convert to argv and invoke
576
584
  flags_argv = flag_aliases.map { |s| s.name }
577
585
 
578
- grp_flags, grp_options, grp_value = Arguments.parse_(flags_argv, specifications)
586
+ grp_flags, grp_options, grp_value, grp_double_slash_index = Arguments.parse_(flags_argv, specifications)
579
587
 
580
588
  grp_flags.map! { |f| FlagArgument.new(arg, index, given_name, f.name, f.argument_specification, hyphens.size, given_label, argument_spec ? argument_spec.extras : nil) }
581
589
  grp_options.map! { |o| OptionArgument.new(arg, index, given_name, o.name, o.argument_specification, hyphens.size, given_label, o.value, argument_spec ? argument_spec.extras : nil) }
@@ -640,7 +648,7 @@ class Arguments
640
648
 
641
649
  end
642
650
 
643
- return flags, options, values
651
+ return flags, options, values, double_slash_index
644
652
  end
645
653
 
646
654
  # ######################
@@ -662,6 +670,9 @@ class Arguments
662
670
  # (Array) a frozen array of values
663
671
  attr_reader :values
664
672
 
673
+ # (Integer, +nil+) index of the first '--', if present; +nil+ otherwise
674
+ attr_reader :double_slash_index
675
+
665
676
  # (Array) the (possibly mutated) array of arguments instance passed to new
666
677
  attr_reader :argv
667
678
 
data/lib/clasp/version.rb CHANGED
@@ -5,13 +5,13 @@
5
5
  # Purpose: Version for CLASP.Ruby library
6
6
  #
7
7
  # Created: 16th November 2014
8
- # Updated: 26th June 2022
8
+ # Updated: 1st December 2023
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/CLASP.Ruby
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2014-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -52,7 +52,7 @@
52
52
  module CLASP
53
53
 
54
54
  # Current version of the CLASP.Ruby library
55
- VERSION = '0.22.1'
55
+ VERSION = '0.23.0.1'
56
56
 
57
57
  private
58
58
  # @!visibility private
@@ -17,6 +17,8 @@ class Test_Arguments < Test::Unit::TestCase
17
17
  assert_equal 0, args.options.size
18
18
 
19
19
  assert_equal 0, args.values.size
20
+
21
+ assert_nil args.double_slash_index
20
22
  end
21
23
 
22
24
  def test_one_value
@@ -29,6 +31,8 @@ class Test_Arguments < Test::Unit::TestCase
29
31
 
30
32
  assert_equal 1, args.values.size
31
33
  assert_equal 'value1', args.values[0]
34
+
35
+ assert_nil args.double_slash_index
32
36
  end
33
37
 
34
38
  def test_two_values
@@ -42,6 +46,8 @@ class Test_Arguments < Test::Unit::TestCase
42
46
  assert_equal 2, args.values.size
43
47
  assert_equal 'value1', args.values[0]
44
48
  assert_equal 'val2', args.values[1]
49
+
50
+ assert_nil args.double_slash_index
45
51
  end
46
52
 
47
53
  def test_ten_values
@@ -58,6 +64,8 @@ class Test_Arguments < Test::Unit::TestCase
58
64
  (0 ... argv.size).each do |n|
59
65
  assert_equal argv[n], args.values[n]
60
66
  end
67
+
68
+ assert_nil args.double_slash_index
61
69
  end
62
70
 
63
71
  def test_one_flag
@@ -77,6 +85,8 @@ class Test_Arguments < Test::Unit::TestCase
77
85
  assert_equal 0, args.options.size
78
86
 
79
87
  assert_equal 0, args.values.size
88
+
89
+ assert_nil args.double_slash_index
80
90
  end
81
91
 
82
92
  def test_two_flags
@@ -104,6 +114,8 @@ class Test_Arguments < Test::Unit::TestCase
104
114
  assert_equal 0, args.options.size
105
115
 
106
116
  assert_equal 0, args.values.size
117
+
118
+ assert_nil args.double_slash_index
107
119
  end
108
120
 
109
121
  def test_three_flags
@@ -139,6 +151,8 @@ class Test_Arguments < Test::Unit::TestCase
139
151
  assert_equal 0, args.options.size
140
152
 
141
153
  assert_equal 0, args.values.size
154
+
155
+ assert_nil args.double_slash_index
142
156
  end
143
157
 
144
158
  def test_one_option
@@ -159,6 +173,8 @@ class Test_Arguments < Test::Unit::TestCase
159
173
  assert_equal Hash.new, args.options[0].extras
160
174
 
161
175
  assert_equal 0, args.values.size
176
+
177
+ assert_nil args.double_slash_index
162
178
  end
163
179
 
164
180
  def test_two_options
@@ -186,6 +202,8 @@ class Test_Arguments < Test::Unit::TestCase
186
202
  assert_equal Hash.new, args.options[1].extras
187
203
 
188
204
  assert_equal 0, args.values.size
205
+
206
+ assert_nil args.double_slash_index
189
207
  end
190
208
 
191
209
  def test_three_options
@@ -221,6 +239,8 @@ class Test_Arguments < Test::Unit::TestCase
221
239
  assert_equal Hash.new, args.options[2].extras
222
240
 
223
241
  assert_equal 0, args.values.size
242
+
243
+ assert_nil args.double_slash_index
224
244
  end
225
245
 
226
246
  def test_one_flag_and_one_option_and_one_value
@@ -247,6 +267,8 @@ class Test_Arguments < Test::Unit::TestCase
247
267
 
248
268
  assert_equal 1, args.values.size
249
269
  assert_equal 'value1', args.values[0]
270
+
271
+ assert_nil args.double_slash_index
250
272
  end
251
273
 
252
274
  def test_double_hyphen_1
@@ -267,6 +289,8 @@ class Test_Arguments < Test::Unit::TestCase
267
289
  assert_equal 2, args.values.size
268
290
  assert_equal 'value1', args.values[0]
269
291
  assert_equal '-f2', args.values[1]
292
+
293
+ assert_equal 2, args.double_slash_index
270
294
  end
271
295
 
272
296
  def test_double_hyphen_2
@@ -289,6 +313,8 @@ class Test_Arguments < Test::Unit::TestCase
289
313
  assert_equal '-f2', args.values[1]
290
314
  assert_equal '--', args.values[2]
291
315
  assert_equal '--option1=v1', args.values[3]
316
+
317
+ assert_equal 2, args.double_slash_index
292
318
  end
293
319
 
294
320
  def test_double_hyphen_3
@@ -320,6 +346,8 @@ class Test_Arguments < Test::Unit::TestCase
320
346
  assert_equal 2, args.values.size
321
347
  assert_equal 'value1', args.values[0]
322
348
  assert_equal 'value2', args.values[1]
349
+
350
+ assert_equal 3, args.double_slash_index
323
351
  end
324
352
 
325
353
  def test_flag_specifications_1
@@ -355,6 +383,8 @@ class Test_Arguments < Test::Unit::TestCase
355
383
 
356
384
  assert_equal 1, args.values.size
357
385
  assert_equal 'value1', args.values[0]
386
+
387
+ assert_nil args.double_slash_index
358
388
  end
359
389
 
360
390
  def test_flag_specifications_2
@@ -392,6 +422,8 @@ class Test_Arguments < Test::Unit::TestCase
392
422
 
393
423
  assert_equal 1, args.values.size
394
424
  assert_equal 'value1', args.values[0]
425
+
426
+ assert_nil args.double_slash_index
395
427
  end
396
428
 
397
429
  def test_flag_specifications_3
@@ -436,6 +468,8 @@ class Test_Arguments < Test::Unit::TestCase
436
468
 
437
469
  assert_equal 1, args.values.size
438
470
  assert_equal 'value1', args.values[0]
471
+
472
+ assert_nil args.double_slash_index
439
473
  end
440
474
 
441
475
  def test_option_specifications_1
@@ -463,6 +497,8 @@ class Test_Arguments < Test::Unit::TestCase
463
497
 
464
498
  assert_equal 1, args.values.size
465
499
  assert_equal 'value1', args.values[0]
500
+
501
+ assert_nil args.double_slash_index
466
502
  end
467
503
 
468
504
  def test_option_specifications_2
@@ -492,6 +528,8 @@ class Test_Arguments < Test::Unit::TestCase
492
528
 
493
529
  assert_equal 1, args.values.size
494
530
  assert_equal 'value1', args.values[0]
531
+
532
+ assert_nil args.double_slash_index
495
533
  end
496
534
 
497
535
  def test_option_specifications_3
@@ -522,6 +560,8 @@ class Test_Arguments < Test::Unit::TestCase
522
560
 
523
561
  assert_equal 1, args.values.size
524
562
  assert_equal 'value1', args.values[0]
563
+
564
+ assert_nil args.double_slash_index
525
565
  end
526
566
 
527
567
  def test_option_default_specifications_1
@@ -572,6 +612,8 @@ class Test_Arguments < Test::Unit::TestCase
572
612
 
573
613
  assert_equal 1, args.values.size
574
614
  assert_equal 'value1', args.values[0]
615
+
616
+ assert_nil args.double_slash_index
575
617
  end
576
618
 
577
619
  def test_option_default_specifications_2
@@ -633,6 +675,8 @@ class Test_Arguments < Test::Unit::TestCase
633
675
 
634
676
  assert_equal 1, args.values.size
635
677
  assert_equal 'value1', args.values[0]
678
+
679
+ assert_nil args.double_slash_index
636
680
  end
637
681
 
638
682
  def test_option_default_specifications_3
@@ -694,6 +738,8 @@ class Test_Arguments < Test::Unit::TestCase
694
738
 
695
739
  assert_equal 1, args.values.size
696
740
  assert_equal 'value1', args.values[0]
741
+
742
+ assert_nil args.double_slash_index
697
743
  end
698
744
  end
699
745
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clasp-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.23.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-26 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xqsr3
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.37'
19
+ version: '0.38'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.37'
26
+ version: '0.38'
27
27
  description: |
28
28
  Command-Line Argument Sorting and Parsing library that provides a powerful
29
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.
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.2.3
98
+ rubygems_version: 3.3.7
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: CLASP.Ruby