despecable 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/despecable/errors/incorrect_parameter_error.rb +1 -5
- data/lib/despecable/errors/invalid_parameter_error.rb +1 -5
- data/lib/despecable/errors/missing_parameter_error.rb +1 -5
- data/lib/despecable/errors/unrecognized_parameter_error.rb +1 -5
- data/lib/despecable/spectacles.rb +8 -8
- 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: 8bd312e2dbfeb02c7d6f895e360225eee7b6f9ab
|
4
|
+
data.tar.gz: 3d2d7fa1ef7c0690ae947dd03afbe874f1818718
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6525433243bf037bd0fbced8ee13f01832a016c0942a741dfbf27dbe47a914e3f56aff1dfa0406b13051a2c5d41e97914586ebde487871c7958929d02eebee
|
7
|
+
data.tar.gz: f3abcf704a9d4226e20ec91d7abc924c4cabd552d0d9341c25e8f56a137a3627ffcd5b98d71c2ac39949275335404ec3c269d5132b98d288abfa4dbedfb84703
|
@@ -21,25 +21,25 @@ module Despecable
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def validate_param_presence(name, value)
|
24
|
-
raise Despecable::MissingParameterError.new("Missing required parameter: #{name}", parameters: name) if value.nil?
|
24
|
+
raise Despecable::MissingParameterError.new("Missing required parameter: '#{name}'", parameters: name) if value.nil?
|
25
25
|
end
|
26
26
|
|
27
27
|
def validate_param_value(name, value, allowed_values)
|
28
|
-
raise Despecable::IncorrectParameterError.new("Unacceptable value for parameter: #{name}", parameters: name) if !allowed_values.include?(value)
|
28
|
+
raise Despecable::IncorrectParameterError.new("Unacceptable value for parameter: '#{name}'", parameters: name) if !allowed_values.include?(value)
|
29
29
|
end
|
30
30
|
|
31
31
|
def integer(name, value)
|
32
32
|
Integer(value)
|
33
33
|
rescue ArgumentError
|
34
34
|
raise unless /^invalid value for Integer/ =~ $!.message
|
35
|
-
raise Despecable::InvalidParameterError.new("Integer type required for parameter: #{name}", parameters: name)
|
35
|
+
raise Despecable::InvalidParameterError.new("Integer type required for parameter: '#{name}'", parameters: name)
|
36
36
|
end
|
37
37
|
|
38
38
|
def float(name, value)
|
39
39
|
Float(value)
|
40
40
|
rescue ArgumentError
|
41
41
|
raise unless /^invalid value for Float/ =~ $!.message
|
42
|
-
raise Despecable::InvalidParameterError.new("Float type required for parameter: #{name}", parameters: name)
|
42
|
+
raise Despecable::InvalidParameterError.new("Float type required for parameter: '#{name}'", parameters: name)
|
43
43
|
end
|
44
44
|
|
45
45
|
def string(name, value)
|
@@ -51,7 +51,7 @@ module Despecable
|
|
51
51
|
case value.to_s
|
52
52
|
when "true", "1" then true
|
53
53
|
when "false", "0", nil then false
|
54
|
-
else raise Despecable::InvalidParameterError.new("Boolean type (1/0 or true/false) required for parameter: #{name}", parameters: name)
|
54
|
+
else raise Despecable::InvalidParameterError.new("Boolean type (1/0 or true/false) required for parameter: '#{name}'", parameters: name)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -59,18 +59,18 @@ module Despecable
|
|
59
59
|
Date.rfc3339(value + "T00:00:00+00:00")
|
60
60
|
rescue ArgumentError
|
61
61
|
raise unless $!.message == "invalid date"
|
62
|
-
raise Despecable::InvalidParameterError.new("Date type (e.g. '2012-12-31') required for parameter: #{name}", parameters: name)
|
62
|
+
raise Despecable::InvalidParameterError.new("Date type (e.g. '2012-12-31') required for parameter: '#{name}'", parameters: name)
|
63
63
|
end
|
64
64
|
|
65
65
|
def datetime(name, value)
|
66
66
|
DateTime.rfc3339(value)
|
67
67
|
rescue ArgumentError
|
68
68
|
raise unless $!.message == "invalid date"
|
69
|
-
raise Despecable::InvalidParameterError.new("Rfc3339 datetime type (e.g. '2009-06-19T00:00:00-04:00') required for parameter: #{name}", parameters: name)
|
69
|
+
raise Despecable::InvalidParameterError.new("Rfc3339 datetime type (e.g. '2009-06-19T00:00:00-04:00') required for parameter: '#{name}'", parameters: name)
|
70
70
|
end
|
71
71
|
|
72
72
|
def file(name, value)
|
73
|
-
raise Despecable::InvalidParameterError.new("File upload type required for parameter: #{name}" , parameters: name) if !(value.respond_to?(:original_filename) && value.original_filename.present?)
|
73
|
+
raise Despecable::InvalidParameterError.new("File upload type required for parameter: '#{name}'" , parameters: name) if !(value.respond_to?(:original_filename) && value.original_filename.present?)
|
74
74
|
return value
|
75
75
|
end
|
76
76
|
|