hash_params 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hash_params-2.0.6.gem +0 -0
- data/lib/hash_params.rb +1 -1
- data/lib/hash_params/validator.rb +9 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a746bc3b0080ee8e7d2eb5bcd8cd48a19e99a49b
|
4
|
+
data.tar.gz: 5c3824b1a408b87ea3a1c953cfb7477b472352dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ab2d4d4389cc22ea7cf2e953f57c4c323c7f73095385fb499a5fe6a9326c3317494b8cbf14da9e643dff3504ca3900b5b90594a2770642ac87e993605a4b6e6
|
7
|
+
data.tar.gz: b6380ae8d1ac01cbff5ec913feb89d311e716cad8d349ae49cb71f9f927372f1d0aacddb8210513a631bf38bca3fea93e44478ddbb5d1b52cb0db24a4acfbb56
|
Binary file
|
data/lib/hash_params.rb
CHANGED
@@ -8,7 +8,7 @@ require_relative 'hash_params/binding_validator'
|
|
8
8
|
|
9
9
|
module HashParams
|
10
10
|
ENVIRONMENT = ENV['HASH_PARAMS_ENV'] || (defined?(Rails) && Rails.env) || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['APP_ENV'] || 'development'
|
11
|
-
VERSION = '2.0.
|
11
|
+
VERSION = '2.0.7'
|
12
12
|
extend HashParams::Validator
|
13
13
|
end
|
14
14
|
|
@@ -50,7 +50,7 @@ module HashParams
|
|
50
50
|
if validations[:required] && param.nil?
|
51
51
|
raise ValidationError.new('Required Parameter missing and has no default specified')
|
52
52
|
end
|
53
|
-
|
53
|
+
errors = []
|
54
54
|
error = nil
|
55
55
|
validations.each do |key, value|
|
56
56
|
error = case key
|
@@ -74,9 +74,14 @@ module HashParams
|
|
74
74
|
else
|
75
75
|
nil
|
76
76
|
end
|
77
|
+
if error
|
78
|
+
error = validations[:errmsg] || error
|
79
|
+
errors << error
|
80
|
+
end
|
81
|
+
|
77
82
|
end
|
78
|
-
|
79
|
-
raise ValidationError.new(
|
83
|
+
|
84
|
+
raise ValidationError.new(errors.join("\n")) unless errors.empty?
|
80
85
|
param
|
81
86
|
end
|
82
87
|
|
@@ -117,7 +122,7 @@ module HashParams
|
|
117
122
|
return Time.parse(val) if type == Time
|
118
123
|
return DateTime.parse(val) if type == DateTime
|
119
124
|
return Array(val.split(opts[:delimiter] || ',')) if type == Array
|
120
|
-
return Hash[val.gsub(/[{}]/, '').gsub('}', '').split(opts[:delimiter] || ',').map {
|
125
|
+
return Hash[val.gsub(/[{}]/, '').gsub('}', '').split(opts[:delimiter] || ',').map {|c| c.split(opts[:separator] ||':').map {|i| i.strip}}] if type == Hash
|
121
126
|
|
122
127
|
raise CoercionError("Unable to coerce #{val} to #{type}")
|
123
128
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Uckun
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- "./coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png"
|
120
120
|
- "./coverage/index.html"
|
121
121
|
- "./hash_params-2.0.5.gem"
|
122
|
+
- "./hash_params-2.0.6.gem"
|
122
123
|
- "./hash_params.gemspec"
|
123
124
|
- "./lib/hash_params.rb"
|
124
125
|
- "./lib/hash_params/binding_validator.rb"
|