libclimate-ruby 0.15.2 → 0.16.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a80c08e442469251d0436faea56241a72bb4b3c072d915a8d2ca3272430ee44
4
- data.tar.gz: 80d05c56fd08159bababfb73e0c277e1cfa610f95fcffe75994199f0e9050918
3
+ metadata.gz: c1e94d5cc4ba07147cf90cdd5a0429d30bef55324228eac1c27246020f35b267
4
+ data.tar.gz: 0fbd451ec141cdaeb5e6f2d4f720d970d0287bbc24140a9c90957a1fbd247d8a
5
5
  SHA512:
6
- metadata.gz: f88618dd50e250ccc2b15c9500ff97db1fe922394997a1ba9c4ceee38fa73f6830ea17432ea8666647a593befa0cdcfac0df95b78dcfbb85c15114bbcde384ec
7
- data.tar.gz: ec7c28f7b08747f6e07f6e5c89e7707a8c3837f8b78b5e57693f72b55bc4dd36ee1ef26dcfc75c384b4bccd425927bdb46b568facf605a3db8cf3e02fed55b17
6
+ metadata.gz: e56af8baca9f1278d41f9efa9acc8a4cd7fed0736592f875415874078a341bfbbf9c1563daa0f7bc7c2b8eeb1c4f683ad19b1c74ac27903ec6c4af73344bbddb
7
+ data.tar.gz: 8ac03e855c3f425857aa9fee828c637a7368cff1af1ce82ef167d3b111f74d37dc3b0d3a42d279c517a51a3ccac7dbcdf7ad7bc41d626d3eb8cd08172644707b
@@ -7,7 +7,7 @@ Example illustrating various kinds of *flag* and *option* specifications, includ
7
7
  ## Source
8
8
 
9
9
  ```ruby
10
- #!/usr/bin/env ruby
10
+ #! /usr/bin/env ruby
11
11
 
12
12
  # examples/flag_and_option_specifications.from_DATA.rb
13
13
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
3
  # examples/flag_and_option_specifications.from_DATA.rb
4
4
 
@@ -7,7 +7,7 @@ Example illustrating various kinds of *flag* and *option* specifications, includ
7
7
  ## Source
8
8
 
9
9
  ```ruby
10
- #!/usr/bin/env ruby
10
+ #! /usr/bin/env ruby
11
11
 
12
12
  # examples/flag_and_option_specifications.rb
13
13
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
3
  # examples/flag_and_option_specifications.rb
4
4
 
@@ -7,7 +7,7 @@ Simple example supporting ```--help``` and ```--version```.
7
7
  ## Source
8
8
 
9
9
  ```ruby
10
- #!/usr/bin/env ruby
10
+ #! /usr/bin/env ruby
11
11
 
12
12
  # examples/show_usage_and_version.rb
13
13
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
3
  # examples/show_usage_and_version.rb
4
4
 
@@ -5,12 +5,13 @@
5
5
  # Purpose: Definition of the ::LibCLImate::Climate class
6
6
  #
7
7
  # Created: 13th July 2015
8
- # Updated: 29th April 2019
8
+ # Updated: 24th July 2022
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2022, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -183,6 +184,7 @@ class Climate
183
184
  @flags = arguments.flags
184
185
  @options = arguments.options
185
186
  @values = arguments.values
187
+ @double_slash_index = arguments.double_slash_index
186
188
  end
187
189
 
188
190
  # (Climate) The +Climate+ instance from which this instance was obtained
@@ -209,6 +211,8 @@ class Climate
209
211
  # (String) A (frozen) array of values
210
212
  attr_reader :values
211
213
 
214
+ attr_reader :double_slash_index
215
+
212
216
  # Verifies the initiating command-line against the specifications,
213
217
  # raising an exception if any missing, unused, or unrecognised flags,
214
218
  # options, or values are found
@@ -970,8 +974,8 @@ class Climate
970
974
  #
971
975
  # === Returns
972
976
  # an instance of a type derived from +::Hash+ with the additional
973
- # attributes +flags+, +options+, +values+, and +argv+.
974
- #
977
+ # attributes +flags+, +options+, +values+, +double_slash_index+ and
978
+ # +argv+.
975
979
  def run(argv = ARGV) # :yields: customised +::Hash+
976
980
 
977
981
  raise ArgumentError, "argv may not be nil" if argv.nil?
@@ -988,6 +992,8 @@ class Climate
988
992
  options = arguments.options
989
993
  values = arguments.values.to_a
990
994
 
995
+ double_slash_index = arguments.double_slash_index
996
+
991
997
  results = {
992
998
 
993
999
  flags: {
@@ -1138,6 +1144,11 @@ class Climate
1138
1144
  self[:values]
1139
1145
  end
1140
1146
 
1147
+ results.define_singleton_method(:double_slash_index) do
1148
+
1149
+ double_slash_index
1150
+ end
1151
+
1141
1152
  results.define_singleton_method(:argv) do
1142
1153
 
1143
1154
  argv
@@ -4,11 +4,12 @@
4
4
  # Purpose: Version for libclimate.Ruby library
5
5
  #
6
6
  # Created: 13th July 2015
7
- # Updated: 26th June 2022
7
+ # Updated: 1st December 2023
8
8
  #
9
9
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
10
  #
11
- # Copyright (c) 2015-2022, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
12
+ # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
12
13
  # All rights reserved.
13
14
  #
14
15
  # Redistribution and use in source and binary forms, with or without
@@ -43,7 +44,7 @@
43
44
  module LibCLImate
44
45
 
45
46
  # Current version of the libCLImate.Ruby library
46
- VERSION = '0.15.2'
47
+ VERSION = '0.16.0.1'
47
48
 
48
49
  private
49
50
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
3
  #############################################################################
4
4
  # File: test/scratch/specifications.rb
@@ -6,7 +6,7 @@
6
6
  # Purpose: Demonstrates use of specifications in options and flags
7
7
  #
8
8
  # Created: 7th February 2018
9
- # Updated: 7th February 2018
9
+ # Updated: 22nd July 2022
10
10
  #
11
11
  # Author: Matthew Wilson
12
12
  #
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test abort
4
4
 
@@ -0,0 +1,91 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # test attribute `LibCLImate::Climate#double_slash_index`
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
+
7
+
8
+ require 'libclimate'
9
+
10
+ require 'xqsr3/extensions/test/unit'
11
+
12
+ require 'test/unit'
13
+
14
+ require 'stringio'
15
+
16
+ class Test_Climate_double_slash_index < Test::Unit::TestCase
17
+
18
+ def test_some_arguments_without_DSI
19
+
20
+ climate = LibCLImate::Climate.new do |cl|
21
+
22
+ cl.add_flag('--abc')
23
+
24
+ cl.add_flag('-d')
25
+ cl.add_flag('-e')
26
+ cl.add_flag('-f')
27
+ end
28
+
29
+ argv = %w{ --abc -d -e -f }
30
+
31
+ r = climate.run argv
32
+
33
+ assert_not_nil r
34
+ assert_kind_of ::Hash, r
35
+ assert 3 <= r.size
36
+ assert_not_nil r[:flags]
37
+ assert_not_nil r[:options]
38
+ assert_not_nil r[:values]
39
+ assert_equal 4, r[:flags].size
40
+ assert_equal 4, r.flags.size
41
+ assert_equal 4, r[:flags][:given].size
42
+ assert_equal 0, r[:flags][:handled].size
43
+ assert_equal 4, r[:flags][:unhandled].size
44
+ assert_equal 0, r[:flags][:unknown].size
45
+ assert_equal 4, r[:options].size
46
+ assert_equal 0, r[:options][:given].size
47
+ assert_equal 0, r[:options][:handled].size
48
+ assert_equal 0, r[:options][:unhandled].size
49
+ assert_equal 0, r[:options][:unknown].size
50
+ assert_equal 0, r[:values].size
51
+ assert_nil r.double_slash_index
52
+ end
53
+
54
+ def test_some_arguments_with_DSI
55
+
56
+ climate = LibCLImate::Climate.new do |cl|
57
+
58
+ cl.add_flag('--abc')
59
+
60
+ cl.add_flag('-d')
61
+ cl.add_flag('-e')
62
+ cl.add_flag('-f')
63
+ end
64
+
65
+ argv = %w{ --abc -d -- -e -f }
66
+
67
+ r = climate.run argv
68
+
69
+ assert_not_nil r
70
+ assert_kind_of ::Hash, r
71
+ assert 3 <= r.size
72
+ assert_not_nil r[:flags]
73
+ assert_not_nil r[:options]
74
+ assert_not_nil r[:values]
75
+ assert_equal 4, r[:flags].size
76
+ assert_equal 4, r.flags.size
77
+ assert_equal 2, r[:flags][:given].size
78
+ assert_equal 0, r[:flags][:handled].size
79
+ assert_equal 2, r[:flags][:unhandled].size
80
+ assert_equal 0, r[:flags][:unknown].size
81
+ assert_equal 4, r[:options].size
82
+ assert_equal 0, r[:options][:given].size
83
+ assert_equal 0, r[:options][:handled].size
84
+ assert_equal 0, r[:options][:unhandled].size
85
+ assert_equal 0, r[:options][:unknown].size
86
+ assert_equal 2, r[:values].size
87
+ assert_equal '-e', r[:values][0]
88
+ assert_equal '-f', r[:values][1]
89
+ assert_equal 2, r.double_slash_index
90
+ end
91
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test version inference
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test simple scenarios
4
4
 
@@ -71,6 +71,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
71
71
  assert_equal 0, r[:options][:unhandled].size
72
72
  assert_equal 0, r[:options][:unknown].size
73
73
  assert_equal 0, r[:values].size
74
+ assert_nil r.double_slash_index
74
75
 
75
76
  lines = str.string.split(/\n/)
76
77
  lines = lines.reject { |line| line.chomp.strip.empty? }
@@ -119,6 +120,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
119
120
  assert_equal 0, r[:options][:unhandled].size
120
121
  assert_equal 0, r[:options][:unknown].size
121
122
  assert_equal 0, r[:values].size
123
+ assert_nil r.double_slash_index
122
124
 
123
125
  lines = str.string.split(/\n/)
124
126
  lines = lines.reject { |line| line.chomp.strip.empty? }
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test simple scenarios (with CLASP)
4
4
 
@@ -71,6 +71,7 @@ class Test_Climate_minimal_CLASP < Test::Unit::TestCase
71
71
  assert_equal 0, r[:options][:unhandled].size
72
72
  assert_equal 0, r[:options][:unknown].size
73
73
  assert_equal 0, r[:values].size
74
+ assert_nil r.double_slash_index
74
75
 
75
76
  lines = str.string.split(/\n/)
76
77
  lines = lines.reject { |line| line.chomp.strip.empty? }
@@ -119,6 +120,7 @@ class Test_Climate_minimal_CLASP < Test::Unit::TestCase
119
120
  assert_equal 0, r[:options][:unhandled].size
120
121
  assert_equal 0, r[:options][:unknown].size
121
122
  assert_equal 0, r[:values].size
123
+ assert_nil r.double_slash_index
122
124
 
123
125
  lines = str.string.split(/\n/)
124
126
  lines = lines.reject { |line| line.chomp.strip.empty? }
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test version inference
4
4
 
@@ -44,6 +44,7 @@ class Test_Climate_parse < Test::Unit::TestCase
44
44
  assert_equal 0, r.flags.size
45
45
  assert_equal 0, r.options.size
46
46
  assert_equal 0, r.values.size
47
+ assert_nil r.double_slash_index
47
48
 
48
49
  r.verify()
49
50
  end
@@ -69,6 +70,7 @@ class Test_Climate_parse < Test::Unit::TestCase
69
70
  argv = [
70
71
 
71
72
  '-d',
73
+ '--',
72
74
  ]
73
75
 
74
76
  r = climate.parse argv
@@ -79,6 +81,7 @@ class Test_Climate_parse < Test::Unit::TestCase
79
81
  assert_equal 1, r.flags.size
80
82
  assert_equal 0, r.options.size
81
83
  assert_equal 0, r.values.size
84
+ assert_equal 1, r.double_slash_index
82
85
 
83
86
  flag0 = r.flags[0]
84
87
 
@@ -125,6 +128,7 @@ class Test_Climate_parse < Test::Unit::TestCase
125
128
  assert_equal 0, r.flags.size
126
129
  assert_equal 1, r.options.size
127
130
  assert_equal 0, r.values.size
131
+ assert_nil r.double_slash_index
128
132
 
129
133
  option0 = r.options[0]
130
134
 
@@ -156,6 +160,7 @@ class Test_Climate_parse < Test::Unit::TestCase
156
160
  assert $stderr.equal? climate.stderr
157
161
 
158
162
  argv = [
163
+ '--',
159
164
  ]
160
165
 
161
166
  r = climate.parse argv
@@ -164,6 +169,7 @@ class Test_Climate_parse < Test::Unit::TestCase
164
169
  assert_equal 0, r.flags.size
165
170
  assert_equal 0, r.options.size
166
171
  assert_equal 0, r.values.size
172
+ assert_equal 0, r.double_slash_index
167
173
 
168
174
  assert_raise_with_message(MissingRequiredException, /.*verbosity.*not specified/) { r.verify(raise_on_required: MissingRequiredException) }
169
175
  end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test version inference
4
4
 
@@ -44,6 +44,7 @@ class Test_Climate_parse_and_verify < Test::Unit::TestCase
44
44
  assert_equal 0, r.flags.size
45
45
  assert_equal 0, r.options.size
46
46
  assert_equal 0, r.values.size
47
+ assert_nil r.double_slash_index
47
48
  end
48
49
 
49
50
  def test_one_flag_with_block
@@ -77,6 +78,7 @@ class Test_Climate_parse_and_verify < Test::Unit::TestCase
77
78
  assert_equal 1, r.flags.size
78
79
  assert_equal 0, r.options.size
79
80
  assert_equal 0, r.values.size
81
+ assert_nil r.double_slash_index
80
82
 
81
83
  flag0 = r.flags[0]
82
84
 
@@ -119,6 +121,7 @@ class Test_Climate_parse_and_verify < Test::Unit::TestCase
119
121
  assert_equal 0, r.flags.size
120
122
  assert_equal 1, r.options.size
121
123
  assert_equal 0, r.values.size
124
+ assert_nil r.double_slash_index
122
125
 
123
126
  option0 = r.options[0]
124
127
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test specifications
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test blocks
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # test blocks (with CLASP)
4
4
 
data/test/unit/ts_all.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  #
3
3
  # executes all other tests
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libclimate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
- autorequire:
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: clasp-ruby
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.22'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.22.1
19
+ version: '0.23'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.22'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.22.1
26
+ version: '0.23'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: xqsr3
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +33,7 @@ dependencies:
39
33
  version: '0.37'
40
34
  - - ">="
41
35
  - !ruby/object:Gem::Version
42
- version: 0.37.2
36
+ version: 0.37.3
43
37
  type: :runtime
44
38
  prerelease: false
45
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +43,7 @@ dependencies:
49
43
  version: '0.37'
50
44
  - - ">="
51
45
  - !ruby/object:Gem::Version
52
- version: 0.37.2
46
+ version: 0.37.3
53
47
  description: |
54
48
  libCLImate is a portable, lightweight mini-framework that encapsulates the common aspects of Command-Line Interface boilerplate, including:
55
49
 
@@ -79,6 +73,7 @@ files:
79
73
  - test/scratch/blankzeroes.rb
80
74
  - test/scratch/specifications.rb
81
75
  - test/unit/tc_abort.rb
76
+ - test/unit/tc_double_slash_index.rb
82
77
  - test/unit/tc_infer_version.rb
83
78
  - test/unit/tc_minimal.rb
84
79
  - test/unit/tc_minimal_CLASP.rb
@@ -93,23 +88,26 @@ homepage: https://github.com/synesissoftware/libCLImate.Ruby
93
88
  licenses:
94
89
  - BSD-3-Clause
95
90
  metadata: {}
96
- post_install_message:
91
+ post_install_message:
97
92
  rdoc_options: []
98
93
  require_paths:
99
94
  - lib
100
95
  required_ruby_version: !ruby/object:Gem::Requirement
101
96
  requirements:
102
- - - "~>"
97
+ - - ">="
103
98
  - !ruby/object:Gem::Version
104
99
  version: '2.0'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '4'
105
103
  required_rubygems_version: !ruby/object:Gem::Requirement
106
104
  requirements:
107
105
  - - ">="
108
106
  - !ruby/object:Gem::Version
109
107
  version: '0'
110
108
  requirements: []
111
- rubygems_version: 3.2.3
112
- signing_key:
109
+ rubygems_version: 3.1.6
110
+ signing_key:
113
111
  specification_version: 4
114
112
  summary: libCLImate.Ruby
115
113
  test_files: []