libclimate-ruby 0.12.0 → 0.12.2
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 +5 -5
- data/lib/libclimate/climate.rb +88 -102
- data/lib/libclimate/libclimate.rb +5 -4
- data/lib/libclimate/version.rb +2 -2
- data/test/scratch/blankzeroes.rb +5 -7
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b097608f416fda5a16bf34588903e669cd37abc259c8e971c65087de88dbd1e
|
4
|
+
data.tar.gz: 3dd3938b2ea4fc8f8b2d632787b048d8c8a75fd575a1df4262c60007fea989fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23fa6d636ea3bc4bae684ab3adaae3abb12ea3c6dc634c48fd69098016f7fad816b87e07c50291a136e0ea4e9bb4ec41d816f7a155428ae6a213db184cd45705
|
7
|
+
data.tar.gz: 17ae81db2053520808553a12cabf97c96369ffbf027039bc53c689ea05c1933ec4aff888b957f262432209cd980f6da3c28557c24874cb759d29c31a5a8a3c8d
|
data/lib/libclimate/climate.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Definition of the ::LibCLImate::Climate class
|
6
6
|
#
|
7
7
|
# Created: 13th July 2015
|
8
|
-
# Updated:
|
8
|
+
# Updated: 13th April 2019
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/libCLImate.Ruby
|
11
11
|
#
|
@@ -47,7 +47,9 @@ require 'xqsr3/quality/parameter_checking'
|
|
47
47
|
=begin
|
48
48
|
=end
|
49
49
|
|
50
|
-
|
50
|
+
#:stopdoc:
|
51
|
+
|
52
|
+
if !defined? Colcon # :nodoc:
|
51
53
|
|
52
54
|
begin
|
53
55
|
|
@@ -58,17 +60,16 @@ if !defined? Colcon
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
#:stopdoc:
|
62
|
-
|
63
63
|
# We monkey-patch CLASP module's Flag and Option generator methods by
|
64
|
-
# added in
|
64
|
+
# added in an +action+ attribute (but only if it does not exist)
|
65
65
|
# and attaching the given block
|
66
66
|
|
67
67
|
class << CLASP
|
68
68
|
|
69
|
-
alias_method :Flag_old, :Flag
|
70
|
-
alias_method :Option_old, :Option
|
69
|
+
alias_method :Flag_old, :Flag # :nodoc:
|
70
|
+
alias_method :Option_old, :Option # :nodoc:
|
71
71
|
|
72
|
+
# Defines a flag, attaching the given block
|
72
73
|
def Flag(name, options={}, &blk)
|
73
74
|
|
74
75
|
f = self.Flag_old(name, options)
|
@@ -96,6 +97,7 @@ class << CLASP
|
|
96
97
|
f
|
97
98
|
end
|
98
99
|
|
100
|
+
# Defines an option, attaching the given block
|
99
101
|
def Option(name, options={}, &blk)
|
100
102
|
|
101
103
|
o = self.Option_old(name, options)
|
@@ -147,6 +149,7 @@ module LibCLImate
|
|
147
149
|
# end
|
148
150
|
#
|
149
151
|
# cl.usage_values = '<value-1> [ ... <value-N> ]'
|
152
|
+
# cl.constrain_values = 1..100000
|
150
153
|
#
|
151
154
|
# cl.info_lines = [
|
152
155
|
#
|
@@ -267,22 +270,17 @@ class Climate
|
|
267
270
|
#
|
268
271
|
# === Signature
|
269
272
|
#
|
270
|
-
# * *Parameters
|
271
|
-
# - +options
|
272
|
-
#
|
273
|
-
# * *Options
|
274
|
-
# - +:no_help_flag
|
275
|
-
#
|
276
|
-
# - +:
|
277
|
-
#
|
278
|
-
# - +:
|
279
|
-
#
|
280
|
-
#
|
281
|
-
# inferred
|
282
|
-
# - +:version_context+:: Object or class that defines a context for
|
283
|
-
# searching the version. Ignored if +:version+ is specified
|
284
|
-
#
|
285
|
-
# * *Block*:: An optional block which receives the constructing instance, allowing the user to modify the attributes.
|
273
|
+
# * *Parameters:*
|
274
|
+
# - +options:+ (Hash) An options hash, containing any of the following options.
|
275
|
+
#
|
276
|
+
# * *Options:*
|
277
|
+
# - +:no_help_flag+ (boolean) Prevents the use of the +CLASP::Flag.Help+ flag-specification
|
278
|
+
# - +:no_version_flag+ (boolean) Prevents the use of the +CLASP::Flag.Version+ flag-specification
|
279
|
+
# - +:program_name+ (::String) An explicit program-name, which is inferred from +$0+ if this is +nil+
|
280
|
+
# - +:version+ (String, [Integer], [String]) A version specification. If not specified, this is inferred
|
281
|
+
# - +:version_context+ Object or class that defines a context for searching the version. Ignored if +:version+ is specified
|
282
|
+
#
|
283
|
+
# * *Block* An optional block which receives the constructing instance, allowing the user to modify the attributes.
|
286
284
|
def initialize(options={}) # :yields: climate
|
287
285
|
|
288
286
|
check_parameter options, 'options', allow_nil: true, type: ::Hash
|
@@ -323,39 +321,27 @@ class Climate
|
|
323
321
|
yield self if block_given?
|
324
322
|
end
|
325
323
|
|
326
|
-
# [DEPRECATED] This method is now deprecated. Instead use
|
327
|
-
# +program_name=+
|
328
|
-
#
|
329
|
-
# @deprecated
|
324
|
+
# [DEPRECATED] This method is now deprecated. Instead use +program_name=+
|
330
325
|
def set_program_name name
|
331
326
|
|
332
327
|
@program_name = name
|
333
328
|
end
|
334
329
|
|
335
|
-
# An array of specifications attached to the climate instance, whose contents should be modified by adding (or removing) CLASP specifications
|
336
|
-
# @return (::Array) The specifications
|
330
|
+
# ([CLASP::Specification]) An array of specifications attached to the climate instance, whose contents should be modified by adding (or removing) CLASP specifications
|
337
331
|
attr_reader :specifications
|
338
332
|
# [DEPRECATED] Instead, use +specifications+
|
339
333
|
def aliases; specifications; end
|
340
|
-
# Indicates whether exit will be called (with non-zero exit code) when a
|
341
|
-
# required command-line option is missing
|
342
|
-
# @return (boolean)
|
343
|
-
# @return *true* exit(1) will be called
|
344
|
-
# @return *false* exit will not be called
|
334
|
+
# (boolean) Indicates whether exit will be called (with non-zero exit code) when a required command-line option is missing. Defaults to +true+
|
345
335
|
attr_accessor :exit_on_missing
|
346
|
-
# Indicates whether unknown flags or options will be ignored. This
|
347
|
-
# overrides +:exit_on_unknown+
|
336
|
+
# (boolean) Indicates whether unknown flags or options will be ignored. This overrides +:exit_on_unknown+. Defaults to +false+
|
348
337
|
attr_accessor :ignore_unknown
|
349
|
-
# Indicates whether exit will be called (with non-zero exit code) when an unknown command-line flag or option is encountered
|
350
|
-
# @return (boolean)
|
351
|
-
# @return *true* exit(1) will be called
|
352
|
-
# @return *false* exit will not be called
|
338
|
+
# (boolean) Indicates whether exit will be called (with non-zero exit code) when an unknown command-line flag or option is encountered. Defaults to +true+
|
353
339
|
attr_accessor :exit_on_unknown
|
354
|
-
#
|
340
|
+
# (boolean) Indicates whether exit will be called (with zero exit code) when usage/version is requested on the command-line. Defaults to +true+
|
355
341
|
attr_accessor :exit_on_usage
|
356
|
-
#
|
342
|
+
# ([String]) Optional array of string of program-information that will be written before the rest of the usage block when usage is requested on the command-line
|
357
343
|
attr_accessor :info_lines
|
358
|
-
#
|
344
|
+
# (String) A program name; defaults to the name of the executing script
|
359
345
|
def program_name
|
360
346
|
|
361
347
|
name = @program_name
|
@@ -367,38 +353,35 @@ class Climate
|
|
367
353
|
|
368
354
|
name
|
369
355
|
end
|
356
|
+
# Sets the +program_name+ attribute
|
370
357
|
attr_writer :program_name
|
371
358
|
# @return (::IO) The output stream for normative output; defaults to $stdout
|
372
359
|
attr_accessor :stdout
|
373
360
|
# @return (::IO) The output stream for contingent output; defaults to $stderr
|
374
361
|
attr_accessor :stderr
|
375
|
-
#
|
376
|
-
# must be provided to the program
|
362
|
+
# (Integer, Range) Optional constraint on the values that must be provided to the program
|
377
363
|
attr_accessor :constrain_values
|
378
|
-
#
|
379
|
-
# section
|
364
|
+
# (String) Optional string to describe the flags and options section. Defaults to "[ +...+ +flags+ +and+ +options+ +...+ ]"
|
380
365
|
attr_accessor :flags_and_options
|
381
366
|
# @return (::String) Optional string to describe the program values, eg \<xyz "[ { <<directory> | <file> } ]"
|
382
367
|
attr_accessor :usage_values
|
383
|
-
#
|
384
|
-
# that value is not present (according to the +:constrain_values+
|
385
|
-
# attribute)
|
368
|
+
# ([String]) Zero-based array of names for values to be used when that value is not present (according to the +:constrain_values+ attribute)
|
386
369
|
attr_accessor :value_names
|
387
|
-
#
|
370
|
+
# (String, [String], [Integer]) A version string or an array of integers/strings representing the version component(s)
|
388
371
|
attr_accessor :version
|
389
372
|
|
390
373
|
# Executes the prepared Climate instance
|
391
374
|
#
|
392
|
-
#
|
375
|
+
# === Signature
|
393
376
|
#
|
394
|
-
# * *Parameters
|
395
|
-
# - +argv
|
377
|
+
# * *Parameters:*
|
378
|
+
# - +argv+ ([String]) The array of arguments; defaults to <tt>ARGV</tt>
|
396
379
|
#
|
397
|
-
#
|
398
|
-
#
|
399
|
-
#
|
380
|
+
# === Returns
|
381
|
+
# an instance of a type derived from +::Hash+ with the additional
|
382
|
+
# attributes +flags+, +options+, +values+, and +argv+.
|
400
383
|
#
|
401
|
-
def run argv = ARGV
|
384
|
+
def run argv = ARGV # :yields: customised +::Hash+
|
402
385
|
|
403
386
|
raise ArgumentError, "argv may not be nil" if argv.nil?
|
404
387
|
|
@@ -683,17 +666,17 @@ class Climate
|
|
683
666
|
#
|
684
667
|
# === Signature
|
685
668
|
#
|
686
|
-
# * *Parameters
|
687
|
-
# - +message
|
688
|
-
# - +options
|
669
|
+
# * *Parameters:*
|
670
|
+
# - +message+ (String) The message string
|
671
|
+
# - +options+ (Hash) An option hash, containing any of the following options
|
689
672
|
#
|
690
|
-
# * *Options
|
691
|
-
# - +:stream
|
692
|
-
# - +:program_name
|
693
|
-
# - +:exit
|
673
|
+
# * *Options:*
|
674
|
+
# - +:stream+ {optional} The output stream to use. Defaults to the value of the attribute +stderr+
|
675
|
+
# - +:program_name+ (String) {optional} Uses the given value rather than the +program_name+ attribute; does not prefix if the empty string
|
676
|
+
# - +:exit+ {optional} The exit code. Defaults to 1. Does not exit if +nil+ specified explicitly
|
694
677
|
#
|
695
|
-
#
|
696
|
-
#
|
678
|
+
# === Returns
|
679
|
+
# The combined message string, if <tt>exit()</tt> not called.
|
697
680
|
def abort message, options={}
|
698
681
|
|
699
682
|
prog_name = options[:program_name]
|
@@ -726,15 +709,20 @@ class Climate
|
|
726
709
|
#
|
727
710
|
# === Signature
|
728
711
|
#
|
729
|
-
# * *Parameters
|
730
|
-
# - +name_or_flag
|
731
|
-
# - +options
|
712
|
+
# * *Parameters:*
|
713
|
+
# - +name_or_flag+ (String, ::CLASP::FlagSpecification) The flag name or instance of CLASP::FlagSpecification
|
714
|
+
# - +options+ (Hash) An options hash, containing any of the following options
|
715
|
+
#
|
716
|
+
# * *Options:*
|
717
|
+
# - +:alias+ (String) A single alias
|
718
|
+
# - +:aliases+ ([String]) An array of aliases
|
719
|
+
# - +:help+ (String) Description string used when writing response to "+--help+" flag
|
720
|
+
# - +:required+ (boolean) Indicates whether the flag is required, causing #run to fail with appropriate message if the flag is not specified in the command-line arguments
|
721
|
+
#
|
722
|
+
# === Examples
|
723
|
+
#
|
724
|
+
# ==== Specification(s) of a flag (single statement)
|
732
725
|
#
|
733
|
-
# * *Options*
|
734
|
-
# - +:help+::
|
735
|
-
# - +:alias+::
|
736
|
-
# - +:specifications+::
|
737
|
-
# - +:extras+::
|
738
726
|
def add_flag(name_or_flag, options={}, &block)
|
739
727
|
|
740
728
|
check_parameter name_or_flag, 'name_or_flag', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Flag ]
|
@@ -752,17 +740,16 @@ class Climate
|
|
752
740
|
#
|
753
741
|
# === Signature
|
754
742
|
#
|
755
|
-
# * *Parameters
|
756
|
-
# - +name_or_option
|
757
|
-
# - +options
|
758
|
-
#
|
759
|
-
# * *Options
|
760
|
-
# - +:alias
|
761
|
-
# - +:
|
762
|
-
# - +:help
|
763
|
-
# - +:values_range
|
764
|
-
# - +:default_value
|
765
|
-
# - +:extras+::
|
743
|
+
# * *Parameters:*
|
744
|
+
# - +name_or_option+ (String, CLASP::OptionSpecification) The option name or instance of CLASP::OptionSpecification
|
745
|
+
# - +options+ (Hash) An options hash, containing any of the following options
|
746
|
+
#
|
747
|
+
# * *Options:*
|
748
|
+
# - +:alias+ (String) A single alias
|
749
|
+
# - +:aliases+ ([String]) An array of aliases
|
750
|
+
# - +:help+ (String) Description string used when writing response to "+--help+" flag
|
751
|
+
# - +:values_range+ ([String]) An array of strings representing the valid/expected values used when writing response to "+--help+" flag. NOTE: the current version does not validate against these values, but a future version may do so
|
752
|
+
# - +:default_value+ (String) The default version used when, say, for the option +--my-opt+ the command-line contain the argument "+--my-opt=+"
|
766
753
|
def add_option(name_or_option, options={}, &block)
|
767
754
|
|
768
755
|
check_parameter name_or_option, 'name_or_option', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Option ]
|
@@ -780,40 +767,40 @@ class Climate
|
|
780
767
|
#
|
781
768
|
# === Signature
|
782
769
|
#
|
783
|
-
# * *Parameters
|
784
|
-
# - +name_or_specification
|
785
|
-
# - +aliases
|
770
|
+
# * *Parameters:*
|
771
|
+
# - +name_or_specification+ (String) The flag/option name or the valued option
|
772
|
+
# - +aliases+ (*[String]) One or more aliases
|
786
773
|
#
|
787
774
|
# === Examples
|
788
775
|
#
|
789
776
|
# ==== Specification(s) of a flag (single statement)
|
790
777
|
#
|
791
|
-
#
|
778
|
+
# climate.add_flag('--mark-missing', alias: '-x')
|
792
779
|
#
|
793
|
-
#
|
780
|
+
# climate.add_flag('--absolute-path', aliases: [ '-abs', '-p' ])
|
794
781
|
#
|
795
782
|
# ==== Specification(s) of a flag (multiple statements)
|
796
783
|
#
|
797
|
-
#
|
798
|
-
#
|
784
|
+
# climate.add_flag('--mark-missing')
|
785
|
+
# climate.add_alias('--mark-missing', '-x')
|
799
786
|
#
|
800
|
-
#
|
801
|
-
#
|
787
|
+
# climate.add_flag('--absolute-path')
|
788
|
+
# climate.add_alias('--absolute-path', '-abs', '-p')
|
802
789
|
#
|
803
790
|
# ==== Specification(s) of an option (single statement)
|
804
791
|
#
|
805
|
-
#
|
792
|
+
# climate.add_option('--add-patterns', alias: '-p')
|
806
793
|
#
|
807
794
|
# ==== Specification(s) of an option (multiple statements)
|
808
795
|
#
|
809
|
-
#
|
810
|
-
#
|
796
|
+
# climate.add_option('--add-patterns')
|
797
|
+
# climate.add_alias('--add-patterns', '-p')
|
811
798
|
#
|
812
799
|
# ==== Specification of a valued option (which has to be multiple statements)
|
813
800
|
#
|
814
|
-
#
|
815
|
-
#
|
816
|
-
#
|
801
|
+
# climate.add_option('--verbosity', values: [ 'succinct', 'verbose' ])
|
802
|
+
# climate.add_alias('--verbosity=succinct', '-s')
|
803
|
+
# climate.add_alias('--verbosity=verbose', '-v')
|
817
804
|
def add_alias(name_or_specification, *aliases)
|
818
805
|
|
819
806
|
check_parameter name_or_specification, 'name_or_specification', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Flag, ::CLASP::Option ]
|
@@ -832,7 +819,6 @@ class Climate
|
|
832
819
|
end
|
833
820
|
end
|
834
821
|
end # class Climate
|
835
|
-
|
836
822
|
end # module LibCLImate
|
837
823
|
|
838
824
|
# ############################## end of file ############################# #
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# Purpose: Main file for libclimate.Ruby library
|
5
5
|
#
|
6
6
|
# Created: 13th July 2015
|
7
|
-
# Updated:
|
7
|
+
# Updated: 13th April 2019
|
8
8
|
#
|
9
9
|
# Home: http://github.com/synesissoftware/libCLImate.Ruby
|
10
10
|
#
|
11
|
-
# Copyright (c) 2015-
|
11
|
+
# Copyright (c) 2015-2019, 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
|
@@ -44,9 +44,10 @@ require 'libclimate/version'
|
|
44
44
|
=end
|
45
45
|
|
46
46
|
# Main module for libCLImate.Ruby library
|
47
|
+
#
|
48
|
+
# === Components of Interest
|
49
|
+
# * ::LibCLImate::Climate
|
47
50
|
module LibCLImate
|
48
|
-
|
49
|
-
|
50
51
|
end # module LibCLImate
|
51
52
|
|
52
53
|
# ############################## end of file ############################# #
|
data/lib/libclimate/version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Version for libclimate.Ruby library
|
5
5
|
#
|
6
6
|
# Created: 13th July 2015
|
7
|
-
# Updated:
|
7
|
+
# Updated: 13th April 2019
|
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.12.
|
46
|
+
VERSION = '0.12.2'
|
47
47
|
|
48
48
|
private
|
49
49
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
data/test/scratch/blankzeroes.rb
CHANGED
@@ -6,12 +6,10 @@
|
|
6
6
|
# Purpose: This filter program converts 0 values in a TSV into blanks
|
7
7
|
#
|
8
8
|
# Created: 14th May 2016
|
9
|
-
# Updated:
|
9
|
+
# Updated: 13th April 2019
|
10
10
|
#
|
11
11
|
# Author: Matthew Wilson
|
12
12
|
#
|
13
|
-
# Copyright: <<TBD>>
|
14
|
-
#
|
15
13
|
#############################################################################
|
16
14
|
|
17
15
|
$:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
@@ -22,10 +20,10 @@ require 'libclimate'
|
|
22
20
|
# ##########################################################
|
23
21
|
# constants
|
24
22
|
|
25
|
-
PROGRAM_VER_MAJOR
|
26
|
-
PROGRAM_VER_MINOR
|
27
|
-
|
28
|
-
PROGRAM_VER_BUILD
|
23
|
+
PROGRAM_VER_MAJOR = 0
|
24
|
+
PROGRAM_VER_MINOR = 1
|
25
|
+
PROGRAM_VER_PATCH = 4
|
26
|
+
PROGRAM_VER_BUILD = 6
|
29
27
|
|
30
28
|
# ##########################################################
|
31
29
|
# command-line parsing
|
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.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clasp-ruby
|
@@ -38,8 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.31'
|
41
|
-
description:
|
42
|
-
|
41
|
+
description: "\n"
|
43
42
|
email: matthew@synesis.com.au
|
44
43
|
executables: []
|
45
44
|
extensions: []
|
@@ -86,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
85
|
version: '0'
|
87
86
|
requirements: []
|
88
87
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.7.6
|
90
89
|
signing_key:
|
91
90
|
specification_version: 4
|
92
91
|
summary: libCLImate.Ruby
|