mio-config 2.11.0 → 2.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 +4 -4
- data/lib/mio/model/metadatadefinition/definition.rb +41 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af024fd81950e9609f908a85ca7ad419332855ed
|
4
|
+
data.tar.gz: db136f2456ce259600cffad66a80be65a6704ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a073e4ba2b0c4bd41196e92d0433df0a408a2a4c38f9fce5caea1ac0fbf53573828d7937afeb576a6caacd322222d26108ea1977674b3bceb0809c8480e1cd
|
7
|
+
data.tar.gz: 1dce2eb3d9f416012c3683a7e2747fb4096c024dad2f1463e75338731d76ddea8b1217356e5f634840dd61498d385aa335b809b33ca9ff2b03982a4a0e91a7a9
|
@@ -85,6 +85,47 @@ class Mio
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def multiple_identical_options key
|
89
|
+
hash_count = @args.options.each_with_object(Hash.new(0)) { |option, count| count[option[key.to_sym]] += 1 }
|
90
|
+
error_msg = ''
|
91
|
+
hash_count.each do |key, count|
|
92
|
+
if count > 1
|
93
|
+
error_msg += error_msg == '' ? "#{key} occurs #{count} times" : ", #{key} occurs #{count} times"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
unless error_msg == ''
|
97
|
+
raise Mio::Model::DataValueError, "Multiple identical options not allowed [" + error_msg + "]"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def boolean_option_check
|
102
|
+
if @args.type == 'boolean'
|
103
|
+
@args.options.each do |option|
|
104
|
+
unless option[:name] =~ /^(true|false)$/
|
105
|
+
raise Mio::Model::DataValueError, "Boolean option name must be true|false"
|
106
|
+
end
|
107
|
+
unless option[:value] =~ /^(true|false)$/
|
108
|
+
raise Mio::Model::DataValueError, "Boolean option value must be true|false"
|
109
|
+
end
|
110
|
+
if option[:name] == 'true' && option[:value] != 'true'
|
111
|
+
raise Mio::Model::DataValueError, "true option name must have true option value"
|
112
|
+
end
|
113
|
+
if option[:name] == 'false' && option[:value] != 'false'
|
114
|
+
raise Mio::Model::DataValueError, "false option name must have false option value"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def validate
|
121
|
+
super
|
122
|
+
multiple_identical_options 'name'
|
123
|
+
multiple_identical_options 'value'
|
124
|
+
boolean_option_check
|
125
|
+
true
|
126
|
+
end
|
127
|
+
alias_method :valid?, :validate
|
128
|
+
|
88
129
|
end
|
89
130
|
end
|
90
131
|
end
|