opto 1.9.0 → 1.9.1
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/opto/group.rb +3 -3
- data/lib/opto/option.rb +7 -1
- data/lib/opto/version.rb +1 -1
- 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: a64054a280e97bf680cda42784fe3711caeab601e8e9a84fa75ef23f0b7d3f8d
|
4
|
+
data.tar.gz: 95098c398edc70eb404074a6cba9991bd352aabfd4f457f813929342e0ce8ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbf5d705f3ac8e27c1bdb42ba7be5f60d63bb32389542ed3bbeea96516fb0eb3fcbb349e275d7b8381aa2765a9fc1277a1a89d4b6ece3b6c99751cc85ed11cd3
|
7
|
+
data.tar.gz: 5bd30b91d1684a57970ca7a6fb6d11f19c0cf840b58a799ae5cead141f05e8d1237adecd7e68debd36e0c307ef7eec727a4ec1ce2b3ab016a577e37628aa5fc1
|
data/lib/opto/group.rb
CHANGED
@@ -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,
|
81
|
-
options.map {|opt| opt.to_h(with_errors: with_errors, 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
|
data/lib/opto/option.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/opto/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|