kharon 0.2.0 → 0.3.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.
@@ -2,11 +2,11 @@ module Kharon
2
2
  module Helpers
3
3
 
4
4
  # Validates the datas passed as parameter with a Phenix::Validator and the given instructions.
5
- # @param [Hash] the parameters to validate with the given instructions.
6
- # @param [Proc] the instructions to apply on the validator.
5
+ # @param [Hash] datas the parameters to validate with the given instructions.
6
+ # @param [Proc] block the instructions to apply on the validator.
7
7
  # @return [Hash] the validated and filtered datas.
8
8
  def validate(datas, &block)
9
- validator = Kharon::Validator.new(datas)
9
+ validator = Kharon::Factory.validator(datas)
10
10
  validator.instance_eval(&block)
11
11
  return validator.filtered
12
12
  end
@@ -1,8 +1,7 @@
1
1
  module Kharon
2
- # The validator uses aquarium as an AOP DSL to provide "before" and "after" joint point to its main methods.
2
+ # The validator is the main class of Kharon, it validates a hash given a structure.
3
3
  # @author Vincent Courtois <vincent.courtois@mycar-innovations.com>
4
4
  class Validator
5
- include Aquarium::DSL
6
5
 
7
6
  # @!attribute [r] datas
8
7
  # @return The datas to filter, they shouldn't be modified to guarantee their integrity.
@@ -14,163 +13,190 @@ module Kharon
14
13
 
15
14
  # Constructor of the classe, receiving the datas to validate and filter.
16
15
  # @param [Hash] datas the datas to validate in the validator.
16
+ # @example create a new instance of validator.
17
+ # @validator = Kharon::Validator.new({key: "value"})
17
18
  def initialize(datas)
18
19
  @datas = datas
19
20
  @filtered = Hash.new
20
21
  end
21
22
 
22
- # @!group Public_interface
23
-
24
23
  # Checks if the given key is an integer or not.
25
24
  # @param [Object] key the key about which verify the type.
26
25
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
26
+ # @example Validates a key so it has to be an integer superior or equal to 2.
27
+ # @validator.integer(:an_integer_key, min: 2)
27
28
  def integer(key, options = {})
28
- match?(key, /\A\d+\Z/) ? store(key, ->(item){item.to_i}, options) : raise_type_error(key, "Integer")
29
+ before_all(key, options)
30
+ match?(key, /\A\d+\Z/) ? store_numeric(key, ->(item){item.to_i}, options) : raise_type_error(key, "Integer")
29
31
  end
30
32
 
31
33
  # Checks if the given key is a numeric or not.
32
34
  # @param [Object] key the key about which verify the type.
33
35
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
36
+ # @example Validates a key so it has to be a numeric, is required and is between 2 and 5.5.
37
+ # @validator.numeric(:a_numeric_key, required: true, between: [2, 5.5])
34
38
  def numeric(key, options = {})
35
- match?(key, /\A([+-]?\d+)([,.](\d+))?\Z/) ? store(key, ->(item){item.to_s.sub(/,/, ".").to_f}, options) : raise_type_error(key, "Numeric")
39
+ before_all(key, options)
40
+ match?(key, /\A([+-]?\d+)([,.](\d+))?\Z/) ? store_decimal(key, ->(item){item.to_s.sub(/,/, ".").to_f}, options) : raise_type_error(key, "Numeric")
36
41
  end
37
42
 
38
43
  # Checks if the given key is a not-empty string or not.
39
44
  # @param [Object] key the key about which verify the type.
40
45
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
46
+ # @example Validates a key so it has to be a string, and seems like and email address (not sure of the regular expression though).
47
+ # @validator.text(:an_email, regex: "[a-zA-Z]+@[a-zA-Z]+\.[a-zA-Z]{2-4}")
41
48
  def text(key, options = {})
42
- is_typed?(key, String) ? store(key, ->(item){item.to_s}, options) : raise_type_error(key, "String")
49
+ before_all(key, options)
50
+ is_typed?(key, String) ? store_text(key, ->(item){item.to_s}, options) : raise_type_error(key, "String")
43
51
  end
44
52
 
45
53
  # Doesn't check the type of the key and let it pass without modification.
46
54
  # @param [Object] key the key about which verify the type.
47
55
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
56
+ # @example Just checks if the key is in the hash.
57
+ # @validator.any(:a_key, required: true)
48
58
  def any(key, options = {})
59
+ before_all(key, options)
49
60
  store(key, ->(item){item}, options)
50
61
  end
51
62
 
52
63
  # Checks if the given key is a datetime or not.
53
64
  # @param [Object] key the key about which verify the type.
54
65
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
66
+ # @example Validates a key so it has to be a datetime, and depends on two other keys.
67
+ # @validator.datetime(:a_datetime, dependencies: [:another_key, :a_third_key])
55
68
  def datetime(key, options = {})
69
+ before_all(key, options)
56
70
  begin; store(key, ->(item){DateTime.parse(item.to_s)} , options); rescue; raise_type_error(key, "DateTime"); end
57
71
  end
58
72
 
59
73
  # Checks if the given key is a date or not.
60
74
  # @param [Object] key the key about which verify the type.
61
75
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
76
+ # @example Validates a key so it has to be a date, and depends on another key.
77
+ # @validator.date(:a_date, dependency: :another_key)
62
78
  def date(key, options = {})
79
+ before_all(key, options)
63
80
  begin; store(key, ->(item){Date.parse(item.to_s)}, options); rescue; raise_type_error(key, "Date"); end
64
81
  end
65
82
 
66
83
  # Checks if the given key is an array or not.
67
84
  # @param [Object] key the key about which verify the type.
68
85
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
86
+ # @example Validates a key so it has to be an array, and checks if it has some values in it.
87
+ # @validator.date(:an_array, contains?: ["first", "second"])
69
88
  def array(key, options = {})
70
- is_typed?(key, Array) ? store(key, ->(item){item.to_a}, options) : raise_type_error(key, "Array")
89
+ before_all(key, options)
90
+ is_typed?(key, Array) ? store_array(key, ->(item){item.to_a}, options) : raise_type_error(key, "Array")
71
91
  end
72
92
 
73
93
  # Checks if the given key is a hash or not.
74
94
  # @param [Object] key the key about which verify the type.
75
95
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
96
+ # @example Validates a key so it has to be a hash, and checks if it has some keys.
97
+ # @validator.date(:a_hash, has_keys: [:first, :second])
76
98
  def hash(key, options = {})
77
- is_typed?(key, Hash) ? store(key, ->(item){Hash.try_convert(item)}, options) : raise_type_error(key, "Hash")
99
+ before_all(key, options)
100
+ is_typed?(key, Hash) ? store_hash(key, ->(item){Hash.try_convert(item)}, options) : raise_type_error(key, "Hash")
78
101
  end
79
102
 
80
103
  # Checks if the given key is a boolean or not.
81
104
  # @param [Object] key the key about which verify the type.
82
105
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
106
+ # @example Validates a key so it has to be a boolean.
107
+ # @validator.boolean(:a_boolean)
83
108
  def boolean(key, options = {})
109
+ before_all(key, options)
84
110
  match?(key, /(true)|(false)/) ? store(key, ->(item){to_boolean(item)}, options) : raise_type_error(key, "Numeric")
85
111
  end
86
112
 
87
113
  # Checks if the given key is a SSID for a MongoDB object or not.
88
114
  # @param [Object] key the key about which verify the type.
89
115
  # @param [Hash] options a hash of options passed to this method (see documentation to know which options pass).
116
+ # @example Validates a key so it has to be a MongoDB SSID.
117
+ # @validator.ssid(:a_ssid)
90
118
  def ssid(key, options = {})
119
+ before_all(key, options)
91
120
  match?(key, /^[0-9a-fA-F]{24}$/) ? store(key, ->(item){BSON::ObjectId.from_string(item.to_s)}, options) : raise_type_error(key, "Moped::BSON::ObjectId")
92
121
  end
93
122
 
94
- # @!endgroup Public_interface
95
-
96
- # @!group Advices
97
-
98
- # Before advice checking for "required", "dependency", and "dependencies" options.
99
- before calls_to: self.instance_methods(false), exclude_methods: [:initialize, :new, :required, :dependency, :dependencies] do |joint_point, validator, *args|
100
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
101
- validator.required(args[0]) if (args[1].has_key?(:required) and args[1][:required] == true)
102
- if args[1].has_key?(:dependencies)
103
- validator.dependencies(args[0], args[1][:dependencies])
104
- elsif args[1].has_key?(:dependency)
105
- validator.dependency(args[0], args[1][:dependency])
106
- end
107
- end
108
- end
123
+ private
109
124
 
110
- # After advice checking in numerics if limits are given, and if there are, if they are respected.
111
- before calls_to: [:integer, :numeric] do |joint_point, validator, *args|
112
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
113
- if(args[1].has_key?(:between))
114
- validator.check_min_value(args[0], args[1][:between][0])
115
- validator.check_max_value(args[0], args[1][:between][1])
116
- else
117
- validator.check_min_value(args[0], args[1][:min]) if(args[1].has_key?(:min))
118
- validator.check_max_value(args[0], args[1][:max]) if(args[1].has_key?(:max))
119
- end
125
+ # This method is executed before any call to a public method.
126
+ # @param [Object] key the key associated with the value currently filteres in the filtered datas.
127
+ # @param [Hash] options the options applied to the initial value.
128
+ def before_all(key, options)
129
+ required(key) if (options.has_key?(:required) and options[:required] == true)
130
+ if options.has_key?(:dependencies)
131
+ dependencies(key, options[:dependencies])
132
+ elsif options.has_key?(:dependency)
133
+ dependency(key, options[:dependency])
120
134
  end
121
135
  end
122
136
 
123
- after calls_to: [:numeric] do |joint_point, validator, *args|
124
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
125
- if(args[1].has_key?(:round) and args[1][:round].kind_of?(Integer))
126
- validator.filtered[args[0]] = validator.filtered[args[0]].round(args[1][:round]) if validator.filtered.has_key?(args[0])
127
- elsif(args[1].has_key?(:floor) and args[1][:floor] == true)
128
- validator.filtered[args[0]] = validator.filtered[args[0]].floor if validator.filtered.has_key?(args[0])
129
- elsif(args[1].has_key?(:ceil) and args[1][:ceil] == true)
130
- validator.filtered[args[0]] = validator.filtered[args[0]].ceil if validator.filtered.has_key?(args[0])
131
- end
137
+ # Stores a numeric number after checking its limits if given.
138
+ # @param [Object] key the key associated with the value to store in the filtered datas.
139
+ # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
140
+ # @param [Hash] options the options applied to the initial value.
141
+ def store_numeric(key, process, options)
142
+ if(options.has_key?(:between))
143
+ check_min_value(key, options[:between][0])
144
+ check_max_value(key, options[:between][1])
145
+ else
146
+ check_min_value(key, options[:min]) if(options.has_key?(:min))
147
+ check_max_value(key, options[:max]) if(options.has_key?(:max))
132
148
  end
149
+ store(key, process, options)
133
150
  end
134
151
 
135
- # After advcie for all methods, checking the "in" and "equals" options.
136
- after calls_to: self.instance_methods(false), exclude_methods: [:initialize, :new, :required, :dependency, :dependencies] do |joint_point, validator, *args|
137
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
138
- if(args[1].has_key?(:in))
139
- validator.in_array?(args[0], args[1][:in])
140
- elsif(args[1].has_key?(:equals))
141
- validator.equals_to?(args[0], args[1][:equals])
142
- end
152
+ # Stores a decimal number, then apply the eventually passed round, ceil, or floor options.
153
+ # @param [Object] key the key associated with the value to store in the filtered datas.
154
+ # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
155
+ # @param [Hash] options the options applied to the initial value.
156
+ def store_decimal(key, process, options)
157
+ store_numeric(key, process, options)
158
+ if(options.has_key?(:round) and options[:round].kind_of?(Integer))
159
+ filtered[key] = filtered[key].round(options[:round]) if filtered.has_key?(key)
160
+ elsif(options.has_key?(:floor) and options[:floor] == true)
161
+ filtered[key] = filtered[key].floor if filtered.has_key?(key)
162
+ elsif(options.has_key?(:ceil) and options[:ceil] == true)
163
+ filtered[key] = filtered[key].ceil if filtered.has_key?(key)
143
164
  end
144
165
  end
145
166
 
146
- # After advice for hashes, checking the "has_keys" and "contains" options.
147
- after calls_to: [:hash] do |joint_point, validator, *args|
148
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
149
- validator.has_keys?(args[0], args[1][:has_keys]) if(args[1].has_key?(:has_keys))
150
- validator.contains?(args[0], validator.datas[args[0]].values, args[1][:contains]) if(args[1].has_key?(:contains))
151
- end
167
+ # Stores a hash after checking for the contains? and has_keys options.
168
+ # @param [Object] key the key associated with the value to store in the filtered datas.
169
+ # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
170
+ # @param [Hash] options the options applied to the initial value.
171
+ def store_hash(key, process, options)
172
+ has_keys?(key, options[:has_keys]) if(options.has_key?(:has_keys))
173
+ contains?(filtered, datas[key].values, options[:contains]) if(options.has_key?(:contains))
174
+ store(key, process, options)
152
175
  end
153
176
 
154
- # After advice for arrays, checking the "contains" option.
155
- after calls_to: [:array] do |joint_point, validator, *args|
156
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
157
- validator.contains?(args[0], validator.datas[args[0]], args[1][:contains]) if(args[1].has_key?(:contains))
158
- end
177
+ # Stores an array after verifying that it contains the values given in the contains? option.
178
+ # @param [Object] key the key associated with the value to store in the filtered datas.
179
+ # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
180
+ # @param [Hash] options the options applied to the initial value.
181
+ def store_array(key, process, options)
182
+ contains?(key, datas[key], options[:contains]) if(options.has_key?(:contains))
183
+ store(key, process, options)
159
184
  end
160
185
 
161
- after calls_to: [:text] do |joint_point, validator, *args|
162
- unless !defined?(args[1]) or args[1].nil? or args[1].empty?
163
- validator.match_regex?(args[0], validator.datas[args[0]], args[1][:regex]) if(args[1].has_key?(:regex))
164
- end
186
+ # Stores a string after verifying that it respects a regular expression given in parameter.
187
+ # @param [Object] key the key associated with the value to store in the filtered datas.
188
+ # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
189
+ # @param [Hash] options the options applied to the initial value.
190
+ def store_text(key, process, options)
191
+ match_regex?(key, datas[key], options[:regex]) if(options.has_key?(:regex))
192
+ store(key, process, options)
165
193
  end
166
194
 
167
- # @!endgroup Advices
168
-
169
195
  # Checks if a required key is present in provided datas.
170
196
  # @param [Object] key the key of which check the presence.
171
197
  # @raise [ArgumentError] if the key is not present.
172
198
  def required(key)
173
- raise ArgumentError.new("The key #{key} is required and not provided.") unless @datas.has_key?(key)
199
+ raise_error("The key #{key} is required and not provided.") unless @datas.has_key?(key)
174
200
  end
175
201
 
176
202
  # Syntaxic sugar used to chack several dependencies at once.
@@ -187,7 +213,7 @@ module Kharon
187
213
  # @param [Object] dependency the key needed by another key for it to properly work.
188
214
  # @raise [ArgumentError] if the required dependency is not present.
189
215
  def dependency(key, dependency)
190
- raise ArgumentError.new("The key #{key} needs the key #{dependency} but it was not provided.") unless @datas.has_key?(dependency)
216
+ raise_error("The key #{key} needs the key #{dependency} but it was not provided.") unless @datas.has_key?(dependency)
191
217
  end
192
218
 
193
219
  # Checks if the value associated with the given key is greater than the given minimum value.
@@ -195,7 +221,7 @@ module Kharon
195
221
  # @param [Numeric] min_value the required minimum value.
196
222
  # @raise [ArgumentError] if the initial value is strictly lesser than the minimum value.
197
223
  def check_min_value(key, min_value)
198
- raise ArgumentError.new("The key #{key} was supposed to be greater or equal than #{min_value}, the value was #{datas[key]}") unless datas[key].to_i >= min_value.to_i
224
+ raise_error("The key #{key} was supposed to be greater or equal than #{min_value}, the value was #{datas[key]}") unless datas[key].to_i >= min_value.to_i
199
225
  end
200
226
 
201
227
  # Checks if the value associated with the given key is lesser than the given maximum value.
@@ -203,7 +229,7 @@ module Kharon
203
229
  # @param [Numeric] max_value the required maximum value.
204
230
  # @raise [ArgumentError] if the initial value is strictly greater than the minimum value.
205
231
  def check_max_value(key, max_value)
206
- raise ArgumentError.new("The key #{key} was supposed to be lesser or equal than #{max_value}, the value was #{datas[key]}") unless datas[key].to_i <= max_value.to_i
232
+ raise_error("The key #{key} was supposed to be lesser or equal than #{max_value}, the value was #{datas[key]}") unless datas[key].to_i <= max_value.to_i
207
233
  end
208
234
 
209
235
  # Checks if the value associated with the given key is included in the given array of values.
@@ -211,7 +237,7 @@ module Kharon
211
237
  # @param [Array] values the values in which the initial value should be contained.
212
238
  # @raise [ArgumentError] if the initial value is not included in the given possible values.
213
239
  def in_array?(key, values)
214
- raise ArgumentError.new("The key #{key} was supposed to be in [#{values.join(", ")}], the value was #{datas[key]}") unless (values.empty? or values.include?(datas[key]))
240
+ raise_error("The key #{key} was supposed to be in [#{values.join(", ")}], the value was #{datas[key]}") unless (values.empty? or values.include?(datas[key]))
215
241
  end
216
242
 
217
243
  # Checks if the value associated with the given key is equal to the given value.
@@ -219,7 +245,7 @@ module Kharon
219
245
  # @param [Object] value the values with which the initial value should be compared.
220
246
  # @raise [ArgumentError] if the initial value is not equal to the given value.
221
247
  def equals_to?(key, value)
222
- raise ArgumentError.new("The key #{key} was supposed to equal than #{value}, the value was #{datas[key]}") unless datas[key] == value
248
+ raise_error("The key #{key} was supposed to equal than #{value}, the value was #{datas[key]}") unless datas[key] == value
223
249
  end
224
250
 
225
251
  # Checks if the value associated with the given key has the given required keys.
@@ -227,7 +253,7 @@ module Kharon
227
253
  # @param [Array] required_keys the keys that the initial Hash typed value should contain.
228
254
  # @raise [ArgumentError] if the initial value has not each and every one of the given keys.
229
255
  def has_keys?(key, required_keys)
230
- raise ArgumentError.new("The key #{key} was supposed to contains keys [#{required_keys.join(", ")}]") if (datas[key].keys & required_keys) != required_keys
256
+ raise_error("The key #{key} was supposed to contains keys [#{required_keys.join(", ")}]") if (datas[key].keys & required_keys) != required_keys
231
257
  end
232
258
 
233
259
  # Checks if the value associated with the given key has the given required values.
@@ -235,16 +261,14 @@ module Kharon
235
261
  # @param [Array] required_keys the values that the initial Enumerable typed value should contain.
236
262
  # @raise [ArgumentError] if the initial value has not each and every one of the given values.
237
263
  def contains?(key, values, required_values)
238
- raise ArgumentError.new("The key #{key} was supposed to contains values [#{required_values.join(", ")}]") if (values & required_values) != required_values
264
+ raise_error("The key #{key} was supposed to contains values [#{required_values.join(", ")}]") if (values & required_values) != required_values
239
265
  end
240
266
 
241
267
  def match_regex?(key, value, regex)
242
268
  regex = Regexp.new(regex) if regex.kind_of?(String)
243
- raise ArgumentError.new("The key #{key} was supposed to match the regex #{regex} but its value was #{value}") unless regex.match(value)
269
+ raise_error("The key #{key} was supposed to match the regex #{regex} but its value was #{value}") unless regex.match(value)
244
270
  end
245
271
 
246
- private
247
-
248
272
  # Check if the value associated with the given key matches the given regular expression.
249
273
  # @param [Object] key the key of the value to compare with the given regexp.
250
274
  # @param [Regexp] regex the regex with which match the initial value.
@@ -261,14 +285,26 @@ module Kharon
261
285
  return (!datas.has_key?(key) or datas[key].kind_of?(type))
262
286
  end
263
287
 
288
+ # Transforms a given value in a boolean.
289
+ # @param [Object] value the value to transform into a boolean.
290
+ # @return [Boolean] true if the value was true, 1 or yes, false if not.
291
+ def to_boolean(value)
292
+ ["true", "1", "yes"].include?(value.to_s) ? true : false
293
+ end
294
+
264
295
  # Tries to store the associated key in the filtered key, transforming it with the given process.
265
296
  # @param [Object] key the key associated with the value to store in the filtered datas.
266
297
  # @param [Proc] process a process (lambda) to execute on the initial value. Must contain strictly one argument.
267
- # @param [Hash] options the options applied to the initial value. Only the option "rename" is checked and executed here.
298
+ # @param [Hash] options the options applied to the initial value.
268
299
  def store(key, process, options = {})
269
300
  unless (options.has_key?(:extract) and options[:extract] == false)
270
301
  if datas.has_key?(key)
271
302
  value = ((options.has_key?(:cast) and options[:cast] == false) ? datas[key] : process.call(datas[key]))
303
+ if(options.has_key?(:in))
304
+ in_array?(key, options[:in])
305
+ elsif(options.has_key?(:equals))
306
+ equals_to?(key, options[:equals])
307
+ end
272
308
  options.has_key?(:rename) ? (@filtered[options[:rename]] = value) : (@filtered[key] = value)
273
309
  end
274
310
  end
@@ -279,14 +315,13 @@ module Kharon
279
315
  # @param [Class] type the expected type, not respected by the initial value.
280
316
  # @raise [ArgumentError] the chosen type error.
281
317
  def raise_type_error(key, type)
282
- raise ArgumentError.new("The key {key} was supposed to be an instance of #{type}, #{key.class} found.")
318
+ raise_error("The key {key} was supposed to be an instance of #{type}, #{key.class} found.")
283
319
  end
284
320
 
285
- # Transforms a given value in a boolean.
286
- # @param [Object] value the value to transform into a boolean.
287
- # @return [Boolean] true if the value was true, 1 or yes, false if not.
288
- def to_boolean(value)
289
- ["true", "1", "yes"].include?(value.to_s) ? true : false
321
+ protected
322
+
323
+ def raise_error(message)
324
+ raise ArgumentError.new(message)
290
325
  end
291
326
 
292
327
  end
@@ -1,4 +1,5 @@
1
- require 'spec_helper'
1
+ require 'rack/test'
2
+ require 'moped'
2
3
  require './lib/validator.rb'
3
4
 
4
5
  shared_examples "options" do |process|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kharon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,23 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2014-04-02 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: aquarium
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - '='
20
- - !ruby/object:Gem::Version
21
- version: 0.5.1
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 0.5.1
13
+ dependencies: []
30
14
  description: Kharon is a ruby hash validator that helps you fix the structure of a
31
15
  hash (type of the keys, dependencies, ...).
32
16
  email: vincent.courtois@mycar-innovations.com
@@ -36,7 +20,6 @@ extra_rdoc_files: []
36
20
  files:
37
21
  - lib/validator.rb
38
22
  - lib/validate.rb
39
- - spec/spec_helper.rb
40
23
  - spec/lib/validator_spec.rb
41
24
  homepage: https://rubygems.org/gems/kharon
42
25
  licenses:
@@ -64,5 +47,4 @@ signing_key:
64
47
  specification_version: 3
65
48
  summary: Ruby Hash validator
66
49
  test_files:
67
- - spec/spec_helper.rb
68
50
  - spec/lib/validator_spec.rb
@@ -1,14 +0,0 @@
1
- # Sets the environment variable to test before loading all the files.
2
- ENV['RACK_ENV'] = 'test'
3
-
4
- require 'rack/test'
5
- require 'mocha/api'
6
- require 'aquarium'
7
- require 'moped'
8
-
9
- module RSpec
10
- configure do |configuration|
11
- # Configuration rspec to use mocha as mocking API.
12
- configuration.mock_with :mocha
13
- end
14
- end