simple_scripting 0.11.1 → 0.12.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: bd6f01ad9ea507d97ac4024fa8e78feb1093e67f75b16d4ac5c5db79354caf18
4
- data.tar.gz: a0a1ad4b67822086544890b54590af03a2877a7210f3198109d605a6fa772d57
3
+ metadata.gz: 6dec0612c673d96b8e5f8299faff45642f8da72a615b2bb424f1b509361da3b3
4
+ data.tar.gz: a8111721013e564624ee4fdd72e063c7eb9ee33d0a6154781509131afa3c77c5
5
5
  SHA512:
6
- metadata.gz: 2ee276b4af46f3746523f9ed11d7b11b4097f65c7139709506363708f1e6303ec1ead4d48c182f480918597272f2c1af92af6620920dad296967540c5b14105c
7
- data.tar.gz: 9059bae5453cc7e64eeea88c8279167020bd7cae0c1b67337c4bf83acb055a0ab04b75c746e7c0ea6d2a9184a8b1df5af0754dcfff55a8ad8e9e2b2409c8fe59
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
- key = param_definition[1].split(' ')[0][2 .. -1].tr('-', '_').to_sym
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
@@ -1,5 +1,5 @@
1
1
  module SimpleScripting
2
2
 
3
- VERSION = "0.11.1"
3
+ VERSION = "0.12.0"
4
4
 
5
5
  end
@@ -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-03-31"
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: true,
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.11.1
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-03-31 00:00:00.000000000 Z
11
+ date: 2019-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parseconfig