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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fdb93a6563908c0714373acc4eb3bb028de7266
4
- data.tar.gz: de125590f391106cdb7385da4f0515c50ea38cab
3
+ metadata.gz: af024fd81950e9609f908a85ca7ad419332855ed
4
+ data.tar.gz: db136f2456ce259600cffad66a80be65a6704ecf
5
5
  SHA512:
6
- metadata.gz: 1f087130190f9791497ef9a1cb41d73f1373d5ecfc80abd447231226eaf93ee69b0fe99d1cbfa8d106ad984880120872296250ecc72132381f94919a02e679a3
7
- data.tar.gz: 0c3084fa2ad9a61955c09a8ed43fe2ded2a25471019b275eaf091700ab488dcb4534039aa762d48da647fd4d52fa6b08acabb4619b254ca66f90043d252808e9
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mio-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jspc