clasp-ruby 0.13.2 → 0.13.3
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 +4 -4
- data/lib/clasp/cli.rb +11 -3
- data/lib/clasp/version.rb +2 -2
- data/test/unit/tc_cli.rb +22 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c07b382022138ca0b59651dd4c3caed38fede09841da24233f80af67e346f5f8
|
4
|
+
data.tar.gz: 6dfacd4e8c76f6f8f9b0ff589e718dcac35b66d8db9c0d1f8c0fe50938c0bef3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58c5e616aee6376b8021d603b99e0e0d11c6e6f4a2b8f819756407d8af2757e2db672ff5b710aa830ec043e2df973f84c273e8faefd677c792bc2243c8d02840
|
7
|
+
data.tar.gz: 40ec8642a2a1f516b6864473912182993b9a8b442c8839db0edd92638d66e860bf05c4800f6e8de2447c10c82457a46d7435b99afd343cf91c927645131cb152
|
data/lib/clasp/cli.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Command-line interface
|
6
6
|
#
|
7
7
|
# Created: 27th July 2015
|
8
|
-
# Updated:
|
8
|
+
# Updated: 1st March 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/CLASP.Ruby
|
11
11
|
#
|
@@ -62,6 +62,12 @@ module CLASP
|
|
62
62
|
# :stopdoc:
|
63
63
|
module CLI_helpers_
|
64
64
|
|
65
|
+
module Constants
|
66
|
+
|
67
|
+
VALID_ALIAS_TYPES = [ Flag, Option, Alias ]
|
68
|
+
VALID_ALIAS_TYPES_STRING = VALID_ALIAS_TYPES[0...-1].join(', ') + ', or ' + VALID_ALIAS_TYPES[-1].to_s
|
69
|
+
end # module Constants
|
70
|
+
|
65
71
|
# :nodoc:
|
66
72
|
def self.generate_version_string_ options
|
67
73
|
|
@@ -126,7 +132,8 @@ def self.show_usage aliases, options={}
|
|
126
132
|
raise ArgumentError, "aliases may not be nil" if aliases.nil?
|
127
133
|
raise TypeError, "aliases must be an array or must respond to each, reject and select" unless ::Array === aliases || (aliases.respond_to?(:each) && aliases.respond_to?(:reject) && aliases.respond_to?(:select))
|
128
134
|
|
129
|
-
|
135
|
+
constants = CLI_helpers_::Constants
|
136
|
+
aliases.each { |a| raise ::TypeError, "each element in aliases array must be one of the types #{constants::VALID_ALIAS_TYPES_STRING}" unless constants::VALID_ALIAS_TYPES.any? { |c| c === a } }
|
130
137
|
|
131
138
|
alias_dups = {}
|
132
139
|
aliases.each { |a| a.aliases.each { |aa| warn "WARNING: alias '#{aa}' is already used for alias '#{a}'" if alias_dups.has_key? aa; alias_dups[aa] = a; } }
|
@@ -262,7 +269,8 @@ def self.show_version aliases, options = {}
|
|
262
269
|
raise ArgumentError, "aliases may not be nil" if aliases.nil?
|
263
270
|
raise TypeError, "aliases must be an array or must respond to each, reject and select" unless ::Array === aliases || (aliases.respond_to?(:each) && aliases.respond_to?(:reject) && aliases.respond_to?(:select))
|
264
271
|
|
265
|
-
|
272
|
+
constants = CLI_helpers_::Constants
|
273
|
+
aliases.each { |a| raise ::TypeError, "each element in aliases array must be one of the types #{constants::VALID_ALIAS_TYPES_STRING}" unless constants::VALID_ALIAS_TYPES.any? { |c| c === a } }
|
266
274
|
|
267
275
|
stream = options[:stream] || $stdout
|
268
276
|
|
data/lib/clasp/version.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Version for CLASP.Ruby library
|
6
6
|
#
|
7
7
|
# Created: 16th November 2014
|
8
|
-
# Updated:
|
8
|
+
# Updated: 2nd March 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/CLASP.Ruby
|
11
11
|
#
|
@@ -51,7 +51,7 @@
|
|
51
51
|
module CLASP
|
52
52
|
|
53
53
|
# Current version of the CLASP.Ruby library
|
54
|
-
VERSION = '0.13.
|
54
|
+
VERSION = '0.13.3'
|
55
55
|
|
56
56
|
private
|
57
57
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
data/test/unit/tc_cli.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
4
|
+
|
5
|
+
require 'clasp'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
require 'xqsr3/extensions/test/unit'
|
10
|
+
|
11
|
+
require 'stringio'
|
12
|
+
|
13
|
+
class Test_CLI < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_invalid_aliases_types
|
16
|
+
|
17
|
+
assert_raise_with_message(::TypeError, 'each element in aliases array must be one of the types CLASP::Flag, CLASP::Option, or CLASP::Alias') { CLASP.show_usage([ 'abc', :def ]) }
|
18
|
+
|
19
|
+
assert_raise_with_message(::TypeError, 'each element in aliases array must be one of the types CLASP::Flag, CLASP::Option, or CLASP::Alias') { CLASP.show_version([ 'abc', :def ]) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clasp-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.3
|
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-02
|
12
|
-
dependencies:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xqsr3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.22'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.22'
|
13
27
|
description: |
|
14
28
|
Command-Line Argument Sorting and Parsing library that provides a powerful
|
15
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.
|
@@ -40,6 +54,7 @@ files:
|
|
40
54
|
- test/unit/tc_arguments_1.rb
|
41
55
|
- test/unit/tc_arguments_2.rb
|
42
56
|
- test/unit/tc_arguments_3.rb
|
57
|
+
- test/unit/tc_cli.rb
|
43
58
|
- test/unit/tc_defaults_1.rb
|
44
59
|
- test/unit/tc_examples_Arguments.rb
|
45
60
|
- test/unit/tc_extras.rb
|
@@ -58,12 +73,12 @@ require_paths:
|
|
58
73
|
- lib
|
59
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
75
|
requirements:
|
61
|
-
- -
|
76
|
+
- - ">="
|
62
77
|
- !ruby/object:Gem::Version
|
63
78
|
version: '0'
|
64
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
80
|
requirements:
|
66
|
-
- -
|
81
|
+
- - ">="
|
67
82
|
- !ruby/object:Gem::Version
|
68
83
|
version: '0'
|
69
84
|
requirements: []
|