libclimate-ruby 0.7.2 → 0.7.4

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
  SHA1:
3
- metadata.gz: 508db783549ec969fcfaca95ac11cebcbc29a340
4
- data.tar.gz: 4cb1d7eb161c1992e94500daded0068a6b018f41
3
+ metadata.gz: c60a586c2e532a081cd93992f608aca85b9b1503
4
+ data.tar.gz: a68a322bfaa05bc443c5da8fea1eea5416cb74ca
5
5
  SHA512:
6
- metadata.gz: beffffe172884c20114e2cb3d705e504f555980393f33ddc246eed5966714b645d0bed9e6a08d6cba6b592782ab215865cfd6178a9a332bfe08364e4d1334df8
7
- data.tar.gz: e4a0c48f13a41c88ea2feb1a0b213e31e23dfdb69a503715820eea8d6b835f1352cf0a1aa5909daf632985487f509145940b64201ce9a2601a38c63f54fc63ea
6
+ metadata.gz: 1471d9e52219711737f689bfbca38bf5591326856d69de60c900f62b71ebd2a99f8fb5db4e192d8b4c76137a09d6bb2eeb55cd4d0e3cd3a9b0cfd741c35615a4
7
+ data.tar.gz: 2f26a31ae8663e370fc29d4a340b92549f44c9592b4e7fa7c065827792d11fd15c90720b7c77945efc098d2bfa17d574fee2639236c8e4e6d21baf37f3dfdf80
@@ -5,7 +5,7 @@
5
5
  # Purpose: Definition of the ::LibCLImate::Climate class
6
6
  #
7
7
  # Created: 13th July 2015
8
- # Updated: 1st January 2018
8
+ # Updated: 4th February 2018
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
11
11
  #
@@ -260,20 +260,26 @@ class Climate
260
260
  # * *Options*:
261
261
  # - +:no_help_flag+:: Prevents the use of the CLASP::Flag.Help flag-alias
262
262
  # - +:no_version_flag+:: Prevents the use of the CLASP::Version.Help flag-alias
263
+ # - +:program_name+:: [ ::String ] An explicit program-name, which is
264
+ # inferred from +$0+ if this is +nil+
263
265
  # - +:version+:: A version specification. If not specified, this is
264
266
  # inferred
265
267
  #
266
268
  # * *Block*:: An optional block which receives the constructing instance, allowing the user to modify the attributes.
267
269
  def initialize(options={}) # :yields: climate
268
270
 
271
+ check_parameter options, 'options', allow_nil: true, type: ::Hash
272
+
269
273
  options ||= {}
270
274
 
271
- program_name = File.basename($0)
272
- program_name = (program_name =~ /\.rb$/) ? "#$`(#$&)" : program_name
275
+ check_option options, :program_name, type: ::String, allow_nil: true
273
276
 
274
- if defined? Colcon
277
+ pr_name = options[:program_name]
278
+
279
+ unless pr_name
275
280
 
276
- program_name = "#{::Colcon::Decorations::Bold}#{program_name}#{::Colcon::Decorations::Unbold}"
281
+ pr_name = File.basename($0)
282
+ pr_name = (pr_name =~ /\.rb$/) ? "#$`(#$&)" : pr_name
277
283
  end
278
284
 
279
285
  @aliases = []
@@ -281,7 +287,7 @@ class Climate
281
287
  @exit_on_missing = true
282
288
  @exit_on_usage = true
283
289
  @info_lines = nil
284
- @program_name = program_name
290
+ set_program_name pr_name
285
291
  @stdout = $stdout
286
292
  @stderr = $stderr
287
293
  @usage_values = usage_values
@@ -294,6 +300,16 @@ class Climate
294
300
  yield self if block_given?
295
301
  end
296
302
 
303
+ def set_program_name name
304
+
305
+ if defined? Colcon
306
+
307
+ name = "#{::Colcon::Decorations::Bold}#{name}#{::Colcon::Decorations::Unbold}"
308
+ end
309
+
310
+ @program_name = name
311
+ end
312
+
297
313
  # An array of aliases attached to the climate instance, whose contents should be modified by adding (or removing) CLASP aliases
298
314
  # @return [Array] The aliases
299
315
  attr_reader :aliases
@@ -659,7 +675,7 @@ class Climate
659
675
  check_parameter name, 'name', allow_nil: false, types: [ ::String, ::Symbol ]
660
676
  raise ArgumentError, "must supply at least one alias" if aliases.empty?
661
677
 
662
- self.aliases << CLASP.Option(name, aliases: aliases)
678
+ self.aliases << CLASP.Alias(name, aliases: aliases)
663
679
  end
664
680
  end # class Climate
665
681
 
@@ -4,7 +4,7 @@
4
4
  # Purpose: Version for libclimate.Ruby library
5
5
  #
6
6
  # Created: 13th July 2015
7
- # Updated: 3rd January 2018
7
+ # Updated: 7th February 2018
8
8
  #
9
9
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
10
  #
@@ -43,7 +43,7 @@
43
43
  module LibCLImate
44
44
 
45
45
  # Current version of the libCLImate.Ruby library
46
- VERSION = '0.7.2'
46
+ VERSION = '0.7.4'
47
47
 
48
48
  private
49
49
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #############################################################################
4
+ # File: test/scratch/aliases.rb
5
+ #
6
+ # Purpose: Demonstrates use of aliases in options and flags
7
+ #
8
+ # Created: 7th February 2018
9
+ # Updated: 7th February 2018
10
+ #
11
+ # Author: Matthew Wilson
12
+ #
13
+ # Copyright: <<TBD>>
14
+ #
15
+ #############################################################################
16
+
17
+ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
18
+
19
+
20
+ require 'libclimate'
21
+
22
+ # ##########################################################
23
+ # constants
24
+
25
+ PROGRAM_VER_MAJOR = 0
26
+ PROGRAM_VER_MINOR = 1
27
+ PROGRAM_VER_REVISION = 1
28
+ PROGRAM_VER_BUILD = 1
29
+
30
+ # ##########################################################
31
+ # command-line parsing
32
+
33
+ options = {}
34
+
35
+ r = LibCLImate::Climate.new do |cl|
36
+
37
+ cl.add_flag('--verbose', alias: '-v', help: 'specifies verbosity') { options[:verbose] = true }
38
+ cl.add_alias('--verbose', '--V')
39
+
40
+ cl.add_option('--logging-threshold', alias: '-l', help: 'specifies the logging threshold') { |o, a| options[:logging_threshold] = o.value }
41
+ cl.add_alias('--logging-threshold=informational', '--I')
42
+
43
+ cl.info_lines = [
44
+
45
+ :version,
46
+ 'demonstrates use of aliases',
47
+ ]
48
+ end.run
49
+
50
+
51
+ # ##########################################################
52
+ # main
53
+
54
+ puts "logging-threshold: #{options[:logging_threshold]}"
55
+ puts "verbose: #{options[:verbose]}"
56
+
57
+ # ############################## end of file ############################# #
58
+
59
+
@@ -6,7 +6,7 @@
6
6
  # Purpose: This filter program converts 0 values in a TSV into blanks
7
7
  #
8
8
  # Created: 14th May 2016
9
- # Updated: 1st January 2018
9
+ # Updated: 5th February 2018
10
10
  #
11
11
  # Author: Matthew Wilson
12
12
  #
@@ -49,3 +49,4 @@ end
49
49
 
50
50
  # ############################## end of file ############################# #
51
51
 
52
+
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.7.2
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-03 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clasp-ruby
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.12.1
19
+ version: 0.13.1
20
20
  - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: '1.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.12.1
29
+ version: 0.13.1
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: '1.0'
@@ -63,6 +63,7 @@ files:
63
63
  - lib/libclimate/climate.rb
64
64
  - lib/libclimate/libclimate.rb
65
65
  - lib/libclimate/version.rb
66
+ - test/scratch/aliases.rb
66
67
  - test/scratch/blankzeroes.rb
67
68
  - test/unit/tc_abort.rb
68
69
  - test/unit/tc_infer_version.rb