opto 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d5546d31ee73e05adce64402dca900e55ef7159fcb277327fedf8bee0db2d00
4
- data.tar.gz: 8dcaaf5040b306b4997f01124f2597a500c230f0a32d2ca5071c9d80e2bb536c
3
+ metadata.gz: a64054a280e97bf680cda42784fe3711caeab601e8e9a84fa75ef23f0b7d3f8d
4
+ data.tar.gz: 95098c398edc70eb404074a6cba9991bd352aabfd4f457f813929342e0ce8ce8
5
5
  SHA512:
6
- metadata.gz: 683dd71495e9ea808933e58416d81fb8ebc815ec0b34834bf14e4d4a7595ce478417287369184928033b6b309ff89797a39a4da0418f5f324a314b09308e7fe0
7
- data.tar.gz: b4012a61a1a01b1a0ba7ef545956435939d329cd60400f37966b700a4ccc7e0f10c7223b19dd1a985a6383f5ce1b2d399c9914a411cdeb2d15b22597e4a383c9
6
+ metadata.gz: dbf5d705f3ac8e27c1bdb42ba7be5f60d63bb32389542ed3bbeea96516fb0eb3fcbb349e275d7b8381aa2765a9fc1277a1a89d4b6ece3b6c99751cc85ed11cd3
7
+ data.tar.gz: 5bd30b91d1684a57970ca7a6fb6d11f19c0cf840b58a799ae5cead141f05e8d1237adecd7e68debd36e0c307ef7eec727a4ec1ce2b3ab016a577e37628aa5fc1
@@ -77,15 +77,15 @@ module Opto
77
77
 
78
78
  # Convert Group to an Array of Hashes (by calling .to_h on each member)
79
79
  # @return [Array<Hash>]
80
- def to_a(with_errors: false, with_value: false)
81
- options.map {|opt| opt.to_h(with_errors: with_errors, with_value: with_value) }
80
+ def to_a(with_errors: false, with_values: false)
81
+ options.map {|opt| opt.to_h(with_errors: with_errors, with_value: with_values) }
82
82
  end
83
83
 
84
84
  # Convert a Group to a hash that has { option_name => option_value }
85
85
  # @return [Hash]
86
86
  def to_h(values_only: false, with_values: false, with_errors: false)
87
87
  if values_only
88
- Hash[*options.flat_map {|opt| [opt.name, opt.value]}]
88
+ Hash[*options.flat_map {|opt| [opt.name, opt.type == 'group' ? opt.value.to_h(values_only: true) : opt.value]}]
89
89
  else
90
90
  Hash[*options.flat_map {|opt| [opt.name, opt.to_h(with_value: with_values, with_errors: with_errors).reject {|k,_| k==:name}]}]
91
91
  end
@@ -138,7 +138,13 @@ module Opto
138
138
  hash[:skip_if] = skip_if if skip_if
139
139
  hash[:only_if] = only_if if only_if
140
140
  hash[:errors] = errors if with_errors
141
- hash[:value] = value if with_value
141
+ if with_value
142
+ if type == 'group'
143
+ hash[:value] = value.to_h(with_values: true, with_errors: with_errors)
144
+ else
145
+ hash[:value] = value
146
+ end
147
+ end
142
148
  hash
143
149
  end
144
150
 
@@ -1,3 +1,3 @@
1
1
  module Opto
2
- VERSION = "1.9.0"
2
+ VERSION = "1.9.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kimmo Lehto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler