libclimate-ruby 0.15.2 → 0.17.0

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: 93f46385f402db50a58439b942019ed126dd63473b62a26e838891bc0df15fb1
4
+ data.tar.gz: b38cc0a266ca7aea7ff3bef2e5532c99b92cf4fe5a6cacd2ddd48d98f61451ae
5
5
  SHA512:
6
- metadata.gz: f88618dd50e250ccc2b15c9500ff97db1fe922394997a1ba9c4ceee38fa73f6830ea17432ea8666647a593befa0cdcfac0df95b78dcfbb85c15114bbcde384ec
7
- data.tar.gz: ec7c28f7b08747f6e07f6e5c89e7707a8c3837f8b78b5e57693f72b55bc4dd36ee1ef26dcfc75c384b4bccd425927bdb46b568facf605a3db8cf3e02fed55b17
6
+ metadata.gz: 8676f6ed6c9ad75d9fa713139e825a3f3fb3e757a8b5d416995b8989b160a32e2c16f2ecb1b3b79d32f12bcc325073be42bfeb867bdb47f314c53f1444e22bae
7
+ data.tar.gz: 1cc2874f4963d361c6e756a314508787baf7fafc0a5175c9174a6b4efc5dcd89e469f1f89c855d302e6d4e14cc36e2f954aea6c9c74e491e34d7a2985b4860ce
@@ -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
 
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: lib/libclimate/climate.rb
3
+ # File: lib/libclimate/climate.rb
4
4
  #
5
- # Purpose: Definition of the ::LibCLImate::Climate class
5
+ # Purpose: Definition of the ::LibCLImate::Climate class
6
6
  #
7
- # Created: 13th July 2015
8
- # Updated: 29th April 2019
7
+ # Created: 13th July 2015
8
+ # Updated: 10th August 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
+ # Home: http://github.com/synesissoftware/libCLImate.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -143,7 +144,7 @@ module LibCLImate
143
144
  #
144
145
  # program_options = {}
145
146
  #
146
- # climate = LibCLImate::Climate.new do |cl|
147
+ # climate = LibCLImate::Climate.new(value_attributes: true) do |cl|
147
148
  #
148
149
  # cl.add_flag('--verbose', alias: '-v', help: 'Makes program output verbose') { program_options[:verbose] = true }
149
150
  #
@@ -152,8 +153,9 @@ module LibCLImate
152
153
  # program_options[:flavour] = check_flavour(o.value) or cl.abort "Invalid flavour '#{o.value}'; use --help for usage"
153
154
  # end
154
155
  #
155
- # cl.usage_values = '<value-1> [ ... <value-N> ]'
156
- # cl.constrain_values = 1..100000
156
+ # cl.usage_values = '<source-path> [ <destination-path> ]'
157
+ # cl.constrain_values = 1..2
158
+ # cl.value_names = %w{ source-path destination-path }
157
159
  #
158
160
  # cl.info_lines = [
159
161
  #
@@ -163,6 +165,10 @@ module LibCLImate
163
165
  # ]
164
166
  # end
165
167
  #
168
+ # r = climate.run ARGV
169
+ #
170
+ # puts "copying from '#{r.source_path}' to '#{r.destination_path || '.'}'"
171
+ #
166
172
  class Climate
167
173
 
168
174
  include ::Xqsr3::Quality::ParameterChecking
@@ -183,6 +189,7 @@ class Climate
183
189
  @flags = arguments.flags
184
190
  @options = arguments.options
185
191
  @values = arguments.values
192
+ @double_slash_index = arguments.double_slash_index
186
193
  end
187
194
 
188
195
  # (Climate) The +Climate+ instance from which this instance was obtained
@@ -209,6 +216,8 @@ class Climate
209
216
  # (String) A (frozen) array of values
210
217
  attr_reader :values
211
218
 
219
+ attr_reader :double_slash_index
220
+
212
221
  # Verifies the initiating command-line against the specifications,
213
222
  # raising an exception if any missing, unused, or unrecognised flags,
214
223
  # options, or values are found
@@ -785,6 +794,7 @@ class Climate
785
794
  # - +:no_help_flag+ (boolean) Prevents the use of the +CLASP::Flag.Help+ flag-specification
786
795
  # - +:no_version_flag+ (boolean) Prevents the use of the +CLASP::Flag.Version+ flag-specification
787
796
  # - +:program_name+ (::String) An explicit program-name, which is inferred from +$0+ if this is +nil+
797
+ # - +:value_attributes+ (boolean) Causes any possible value-names, as described in `#value_names`, to be applied as attributes with the given values, if any, on the command-line
788
798
  # - +:version+ (String, [Integer], [String]) A version specification. If not specified, this is inferred
789
799
  # - +:version_context+ Object or class that defines a context for searching the version. Ignored if +:version+ is specified
790
800
  #
@@ -826,6 +836,8 @@ class Climate
826
836
  version_context = options[:version_context]
827
837
  @version = options[:version] || infer_version_(version_context)
828
838
 
839
+ @value_attributes = options[:value_attributes]
840
+
829
841
  unless options[:no_help_flag]
830
842
 
831
843
  f = CLASP::Flag.Help()
@@ -925,7 +937,7 @@ class Climate
925
937
  #
926
938
  # === Returns
927
939
  # (ParseResults) Results
928
- def parse(argv = ARGV) # :yields: ParseResults
940
+ def parse(argv = ARGV, **options) # :yields: ParseResults
929
941
 
930
942
  raise ArgumentError, "argv may not be nil" if argv.nil?
931
943
 
@@ -953,7 +965,7 @@ class Climate
953
965
  # (ParseResults) Results
954
966
  def parse_and_verify(argv = ARGV, **options) # :yields: ParseResults
955
967
 
956
- r = parse argv
968
+ r = parse argv, **options
957
969
 
958
970
  r.verify(**options)
959
971
 
@@ -970,24 +982,26 @@ class Climate
970
982
  #
971
983
  # === Returns
972
984
  # an instance of a type derived from +::Hash+ with the additional
973
- # attributes +flags+, +options+, +values+, and +argv+.
974
- #
975
- def run(argv = ARGV) # :yields: customised +::Hash+
985
+ # attributes +flags+, +options+, +values+, +double_slash_index+ and
986
+ # +argv+.
987
+ def run(argv = ARGV, **options) # :yields: customised +::Hash+
976
988
 
977
989
  raise ArgumentError, "argv may not be nil" if argv.nil?
978
990
 
979
991
  arguments = CLASP::Arguments.new argv, specifications
980
992
 
981
- run_ argv, arguments
993
+ run_ argv, arguments, **options
982
994
  end
983
995
 
984
996
  private
985
- def run_(argv, arguments) # :nodoc:
997
+ def run_(argv, arguments, **opts) # :nodoc:
986
998
 
987
999
  flags = arguments.flags
988
1000
  options = arguments.options
989
1001
  values = arguments.values.to_a
990
1002
 
1003
+ double_slash_index = arguments.double_slash_index
1004
+
991
1005
  results = {
992
1006
 
993
1007
  flags: {
@@ -1138,11 +1152,41 @@ class Climate
1138
1152
  self[:values]
1139
1153
  end
1140
1154
 
1155
+ results.define_singleton_method(:double_slash_index) do
1156
+
1157
+ double_slash_index
1158
+ end
1159
+
1141
1160
  results.define_singleton_method(:argv) do
1142
1161
 
1143
1162
  argv
1144
1163
  end
1145
1164
 
1165
+
1166
+ if opts[:value_attributes] || @value_attributes
1167
+
1168
+ (value_names || []).each_with_index do |name, index|
1169
+
1170
+ name = name.gsub(/-/, '_').to_sym
1171
+
1172
+ if results.respond_to? name
1173
+
1174
+ warn "cannot create attribute `#{name}` on instance of `#{results.class}` because that name is already used"
1175
+ else
1176
+
1177
+ value = results.values[index]
1178
+
1179
+ results.define_singleton_method(name) do
1180
+
1181
+ value
1182
+ end
1183
+ end
1184
+ end
1185
+ end
1186
+
1187
+
1188
+ results.freeze
1189
+
1146
1190
  results
1147
1191
  end
1148
1192
  public
@@ -1385,6 +1429,7 @@ class Climate
1385
1429
  end # class Climate
1386
1430
  end # module LibCLImate
1387
1431
 
1432
+
1388
1433
  # ############################## end of file ############################# #
1389
1434
 
1390
1435
 
@@ -1,14 +1,14 @@
1
1
  # ######################################################################## #
2
- # File: libclimate/libclimate.rb
2
+ # File: libclimate/libclimate.rb
3
3
  #
4
- # Purpose: Main file for libclimate.Ruby library
4
+ # Purpose: Main file for libclimate.Ruby library
5
5
  #
6
- # Created: 13th July 2015
7
- # Updated: 13th April 2019
6
+ # Created: 13th July 2015
7
+ # Updated: 10th August 2024
8
8
  #
9
- # Home: http://github.com/synesissoftware/libCLImate.Ruby
9
+ # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
10
  #
11
- # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2015-2024, Matthew Wilson and Synesis Software
12
12
  # All rights reserved.
13
13
  #
14
14
  # Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,7 @@ require 'libclimate/version'
50
50
  module LibCLImate
51
51
  end # module LibCLImate
52
52
 
53
+
53
54
  # ############################## end of file ############################# #
54
55
 
55
56
 
@@ -1,14 +1,15 @@
1
1
  # ######################################################################## #
2
- # File: libclimate/version.rb
2
+ # File: libclimate/version.rb
3
3
  #
4
- # Purpose: Version for libclimate.Ruby library
4
+ # Purpose: Version for libclimate.Ruby library
5
5
  #
6
- # Created: 13th July 2015
7
- # Updated: 26th June 2022
6
+ # Created: 13th July 2015
7
+ # Updated: 10th August 2024
8
8
  #
9
- # Home: http://github.com/synesissoftware/libCLImate.Ruby
9
+ # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
10
  #
11
- # Copyright (c) 2015-2022, Matthew Wilson and Synesis Software
11
+ # Copyright (c) 2019-2024, 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.17.0'
47
48
 
48
49
  private
49
50
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -54,9 +55,9 @@ module LibCLImate
54
55
  VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
55
56
  # # Revision version of the libCLImate.Ruby library
56
57
  VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
57
-
58
58
  end # module LibCLImate
59
59
 
60
+
60
61
  # ############################## end of file ############################# #
61
62
 
62
63
 
@@ -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
 
@@ -92,7 +92,7 @@ class Test_Climate_values_constraints < Test::Unit::TestCase
92
92
  stdout = StringIO.new
93
93
  stderr = StringIO.new
94
94
 
95
- climate = LibCLImate::Climate.new do |cl|
95
+ climate = LibCLImate::Climate.new(value_attributes: true) do |cl|
96
96
 
97
97
  cl.exit_on_missing = false
98
98
 
@@ -129,6 +129,67 @@ class Test_Climate_values_constraints < Test::Unit::TestCase
129
129
  assert_equal 2, r.values.size
130
130
  assert_empty stdout.string
131
131
  assert_empty stderr.string
132
+ assert r.respond_to? :input_path
133
+ assert r.respond_to? :output_path
134
+
135
+ stdout.string = ''
136
+ stderr.string = ''
137
+ r = climate.run [ 'value-1', 'value-2', 'value-3' ]
138
+ assert_equal 3, r.values.size
139
+ assert_empty stdout.string
140
+ assert_not_empty stderr.string
141
+ assert_match /wrong number of values.*3 given.*2 required.*/, stderr.string
142
+ end
143
+
144
+ def test_constrain_with_integer_and_names_2
145
+
146
+ stdout = StringIO.new
147
+ stderr = StringIO.new
148
+
149
+ climate = LibCLImate::Climate.new(value_attributes: true) do |cl|
150
+
151
+ cl.exit_on_missing = false
152
+
153
+ cl.stdout = stdout
154
+ cl.stderr = stderr
155
+
156
+ cl.constrain_values = 1..2
157
+ cl.value_names = [
158
+
159
+ 'input-path',
160
+ 'output-path',
161
+ ]
162
+ end
163
+
164
+ stdout.string = ''
165
+ stderr.string = ''
166
+ r = climate.run [ ]
167
+ assert_equal 0, r.values.size
168
+ assert_empty stdout.string
169
+ assert_not_empty stderr.string
170
+ assert_match /input-path not specified.*#{climate.usage_help_suffix}/, stderr.string
171
+
172
+ stdout.string = ''
173
+ stderr.string = ''
174
+ r = climate.run [ 'value-1' ]
175
+ assert_equal 1, r.values.size
176
+ assert_empty stdout.string
177
+ assert_empty stderr.string
178
+ assert r.respond_to? :input_path
179
+ assert r.respond_to? :output_path
180
+ assert_equal 'value-1', r.input_path
181
+ assert_nil r.output_path
182
+
183
+ stdout.string = ''
184
+ stderr.string = ''
185
+ r = climate.run [ 'value-1', 'value-2' ]
186
+ assert_equal 2, r.values.size
187
+ assert_empty stdout.string
188
+ assert_empty stderr.string
189
+ assert r.respond_to? :input_path
190
+ assert r.respond_to? :output_path
191
+ assert_equal 'value-1', r.input_path
192
+ assert_equal 'value-2', r.output_path
132
193
 
133
194
  stdout.string = ''
134
195
  stderr.string = ''
@@ -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.17.0
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: 2024-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clasp-ruby
@@ -16,40 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.22'
19
+ version: '0.23'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.22.1
22
+ version: 0.23.0.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
- version: '0.22'
29
+ version: '0.23'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.22.1
32
+ version: 0.23.0.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: xqsr3
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.37'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.37.2
39
+ version: '0.39'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
44
  - - "~>"
48
45
  - !ruby/object:Gem::Version
49
- version: '0.37'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.37.2
46
+ version: '0.39'
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: []