simple_scripting 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_scripting/argv.rb +11 -1
- data/lib/simple_scripting/version.rb +1 -1
- data/simple_scripting.gemspec +1 -1
- data/spec/simple_scripting/argv_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dec0612c673d96b8e5f8299faff45642f8da72a615b2bb424f1b509361da3b3
|
4
|
+
data.tar.gz: a8111721013e564624ee4fdd72e063c7eb9ee33d0a6154781509131afa3c77c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c6995cdce8e0f495c0ae1028972a507ba4b88c5102d9da421f0afbcb1e113e03757474227e775a4b8676b00eccd8b3e3b56ab91fefa3a858dd65e7127b504a
|
7
|
+
data.tar.gz: a05c83cdce85612d6b488604eec6bbb182f3d06dd9a2bb2bd90a8fcce0dade13482cf442cf2eca548d708e7e8c28ecd48dfd26cc4eaaaa1947e67ce914a934c9
|
@@ -210,8 +210,18 @@ module SimpleScripting
|
|
210
210
|
# DEFINITIONS PROCESSING ###############################
|
211
211
|
|
212
212
|
def process_option_definition!(param_definition, parser_opts, result)
|
213
|
+
# Work on a copy; in at least one case (data type definition), we perform destructive
|
214
|
+
# operations.
|
215
|
+
#
|
216
|
+
param_definition = param_definition.dup
|
217
|
+
|
213
218
|
if param_definition[1] && param_definition[1].start_with?('--')
|
214
|
-
|
219
|
+
raw_key, key_argument = param_definition[1].split(' ')
|
220
|
+
key = raw_key[2 .. -1].tr('-', '_').to_sym
|
221
|
+
|
222
|
+
if key_argument&.include?(',')
|
223
|
+
param_definition.insert(2, Array)
|
224
|
+
end
|
215
225
|
else
|
216
226
|
key = param_definition[0][1 .. -1].to_sym
|
217
227
|
end
|
data/simple_scripting.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.required_ruby_version = '>= 2.3.0'
|
12
12
|
s.authors = ["Saverio Miroddi"]
|
13
|
-
s.date = "2019-
|
13
|
+
s.date = "2019-08-18"
|
14
14
|
s.email = ["saverio.pub2@gmail.com"]
|
15
15
|
s.homepage = "https://github.com/saveriomiroddi/simple_scripting"
|
16
16
|
s.summary = "Library for simplifying some typical scripting functionalities."
|
@@ -13,7 +13,7 @@ describe SimpleScripting::Argv do
|
|
13
13
|
let(:decoder_params) {[
|
14
14
|
['-a' ],
|
15
15
|
['-b', '"-b" description'],
|
16
|
-
['-c', '--c-switch'
|
16
|
+
['-c', '--c-switch VAL1,VAL2' ],
|
17
17
|
['-d', '--d-switch', '"-d" description'],
|
18
18
|
['-e', '--e-switch VALUE' ],
|
19
19
|
['-f', '--f-switch VALUE', '"-f" description'],
|
@@ -34,7 +34,7 @@ describe SimpleScripting::Argv do
|
|
34
34
|
Usage: rspec [options] <mandatory> [<optional>]
|
35
35
|
-a
|
36
36
|
-b "-b" description
|
37
|
-
-c, --c-switch
|
37
|
+
-c, --c-switch VAL1,VAL2
|
38
38
|
-d, --d-switch "-d" description
|
39
39
|
-e, --e-switch VALUE
|
40
40
|
-f, --f-switch VALUE "-f" description
|
@@ -78,15 +78,15 @@ describe SimpleScripting::Argv do
|
|
78
78
|
|
79
79
|
end # context 'help'
|
80
80
|
|
81
|
-
it "should implement basic switches and arguments (all set)" do
|
82
|
-
decoder_params.last[:arguments] = ['-a', '-b', '-c', '-d', '-ev_swt', '-fv_swt', 'm_arg', 'o_arg']
|
81
|
+
it "should implement basic switches, with conversion, and arguments (all set)" do
|
82
|
+
decoder_params.last[:arguments] = ['-a', '-b', '-c', 'a,b,c', '-d', '-ev_swt', '-fv_swt', 'm_arg', 'o_arg']
|
83
83
|
|
84
84
|
actual_result = described_class.decode(*decoder_params)
|
85
85
|
|
86
86
|
expected_result = {
|
87
87
|
a: true,
|
88
88
|
b: true,
|
89
|
-
c_switch:
|
89
|
+
c_switch: %w(a b c),
|
90
90
|
d_switch: true,
|
91
91
|
e_switch: 'v_swt',
|
92
92
|
f_switch: 'v_swt',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parseconfig
|