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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 290a992d2845a837ff7ce19c2fab3dccb6777fcd
4
- data.tar.gz: 4e6bda047e215fc133e20ad56c02ebc417719798
3
+ metadata.gz: 8bd312e2dbfeb02c7d6f895e360225eee7b6f9ab
4
+ data.tar.gz: 3d2d7fa1ef7c0690ae947dd03afbe874f1818718
5
5
  SHA512:
6
- metadata.gz: c59f54e988d690ce171d1cfada645fa3790d4e3435cab086e16d3d8988aee03ca315446b87b82d02cd4763e1b3702e6ecd6db134de645d35963134d2352957fc
7
- data.tar.gz: cc348e49a9cea4d797f788e0d9e1b5abbeb7ff3c778e552622a3cc9508b6a93862d3d3fe23805d8845d2e6ab9913aabc5c90871b37e5aa902d07a388b1d485b4
6
+ metadata.gz: fd6525433243bf037bd0fbced8ee13f01832a016c0942a741dfbf27dbe47a914e3f56aff1dfa0406b13051a2c5d41e97914586ebde487871c7958929d02eebee
7
+ data.tar.gz: f3abcf704a9d4226e20ec91d7abc924c4cabd552d0d9341c25e8f56a137a3627ffcd5b98d71c2ac39949275335404ec3c269d5132b98d288abfa4dbedfb84703
@@ -1,5 +1 @@
1
- class Despecable::IncorrectParameterError < Despecable::DespecableError
2
- def introduction(name)
3
- "Incorrect value for parameter '#{name}'."
4
- end
5
- end
1
+ Despecable::IncorrectParameterError = Class.new(Despecable::DespecableError)
@@ -1,5 +1 @@
1
- class Despecable::InvalidParameterError < Despecable::DespecableError
2
- def introduction(name)
3
- "Invalid value for parameter '#{name}'."
4
- end
5
- end
1
+ Despecable::InvalidParameterError = Class.new(Despecable::DespecableError)
@@ -1,5 +1 @@
1
- class Despecable::MissingParameterError < Despecable::DespecableError
2
- def introduction(name)
3
- "Missing required parameter '#{name}'."
4
- end
5
- end
1
+ Despecable::MissingParameterError = Class.new(Despecable::DespecableError)
@@ -1,5 +1 @@
1
- class Despecable::UnrecognizedParameterError < Despecable::DespecableError
2
- def introduction(name)
3
- "Unrecognized parameter '#{name}'"
4
- end
5
- end
1
+ Despecable::UnrecognizedParameterError = Class.new(Despecable::DespecableError)
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: despecable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Schwartz