despecable 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/despecable/spectacles.rb +18 -2
- data/lib/despecable/spectator.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4a7ccf6f71926d7b730060c7a75bf7631115e6
|
4
|
+
data.tar.gz: 674547978b66be016c57dba26ffa03ef048c5e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75ea855b04f42288d85ab46861979c0ee3031db1a88541a39419bac29abbe6c5689a7a0b0e272125efa3521c976e4f7808d858da5e1de199a86dcf5603495a92
|
7
|
+
data.tar.gz: 15899dbf346f56ad6668562cbe69c31b249acc0a2716bc682d8c137701632d8acdddde240776984c74db5d2286de473c1ad05436e37048df65b328be43dbccfc
|
@@ -32,7 +32,14 @@ module Despecable
|
|
32
32
|
Integer(value)
|
33
33
|
rescue ArgumentError
|
34
34
|
raise unless /^invalid value for Integer/ =~ $!.message
|
35
|
-
raise Despecable::InvalidParameterError, "Required type: integer
|
35
|
+
raise Despecable::InvalidParameterError, "Required type: integer"
|
36
|
+
end
|
37
|
+
|
38
|
+
def float
|
39
|
+
Float(value)
|
40
|
+
rescue ArgumentError
|
41
|
+
raise unless /^invalid value for Float/ =~ $!.message
|
42
|
+
raise Despecable::InvalidParameterError, "Required type: float"
|
36
43
|
end
|
37
44
|
|
38
45
|
def string(value)
|
@@ -44,7 +51,7 @@ module Despecable
|
|
44
51
|
case value.to_s
|
45
52
|
when "true", "1" then true
|
46
53
|
when "false", "0", nil then false
|
47
|
-
else raise Despecable::InvalidParameterError, "
|
54
|
+
else raise Despecable::InvalidParameterError, "Required type: boolean (1/0 or true/false)"
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
@@ -61,5 +68,14 @@ module Despecable
|
|
61
68
|
raise unless $!.message == "invalid date"
|
62
69
|
raise Despecable::InvalidParameterError, "Required type: rfc3339 datetime (e.g. '2009-06-19T00:00:00-04:00')."
|
63
70
|
end
|
71
|
+
|
72
|
+
def file(value)
|
73
|
+
raise Despecable::InvalidParameterError, "Required type: file upload" if !(value.respond_to?(:original_filename) && value.original_filename.present?)
|
74
|
+
return value
|
75
|
+
end
|
76
|
+
|
77
|
+
def any(value)
|
78
|
+
value
|
79
|
+
end
|
64
80
|
end
|
65
81
|
end
|
data/lib/despecable/spectator.rb
CHANGED
@@ -28,6 +28,18 @@ module Despecable
|
|
28
28
|
_spec(name, :datetime, options)
|
29
29
|
end
|
30
30
|
|
31
|
+
def float(name, options = {})
|
32
|
+
_spec(name, :float, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def file(name, options = {})
|
36
|
+
_spec(name, :file, options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def any(name, options = {})
|
40
|
+
_spec(name, :any, options)
|
41
|
+
end
|
42
|
+
|
31
43
|
private
|
32
44
|
|
33
45
|
def _spec(name, type, options = {})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: despecable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Schwartz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write self-documenting parameter validation and type-casting in your
|
14
14
|
API actions. Docs and development at https://github.com/ozydingo/despecable.
|