typero 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/typero/type.rb +7 -1
- data/lib/typero/type/array.rb +5 -1
- data/lib/typero/type/boolean.rb +1 -2
- data/lib/typero/type/email.rb +2 -3
- data/lib/typero/version.rb +1 -1
- 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: 6b60246c3690ede7ca8f5e449abff10f446d76a6
|
4
|
+
data.tar.gz: fade8fc6679cc675269bb47ff03f3f0b1f965ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 024ec4893a7173adef65b29d2c14eaff0ff7d8ce658a44584aaf4ee11c5ed64c8883a6914eeb737bea6dfbf92b58bc9e2e21ce9d9f59f31cf5d066ab48a232f6
|
7
|
+
data.tar.gz: bfc7263f3991580a455ddb6f819be4337569e5d3da8203a716f5d4f813cf921b41b59b24e5cd947da995b8019d57877664c25227483c42efa2cbeccce9411ad5
|
data/lib/typero/type.rb
CHANGED
@@ -15,6 +15,12 @@ module Typero
|
|
15
15
|
value
|
16
16
|
end
|
17
17
|
|
18
|
+
# sometimes we want to coarce values on get
|
19
|
+
# by default just copy
|
20
|
+
def get(list)
|
21
|
+
list
|
22
|
+
end
|
23
|
+
|
18
24
|
# if value is blank?, trigger default
|
19
25
|
# for example set it to false for boolean type and [] for array type
|
20
26
|
def default
|
@@ -51,7 +57,7 @@ module Typero
|
|
51
57
|
return default
|
52
58
|
end
|
53
59
|
else
|
54
|
-
value
|
60
|
+
get(value)
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
data/lib/typero/type/array.rb
CHANGED
@@ -4,13 +4,17 @@ module Typero
|
|
4
4
|
[]
|
5
5
|
end
|
6
6
|
|
7
|
+
def get(list)
|
8
|
+
list.to_a
|
9
|
+
end
|
10
|
+
|
7
11
|
def set(value)
|
8
12
|
value = value.to_s.split(/\s*,\s*/) unless value.class.to_s.index('Array')
|
9
13
|
if type = @opts[:array_type]
|
10
14
|
check_type(type)
|
11
15
|
value.each { |el| Typero.validate!(el, type) }
|
12
16
|
end
|
13
|
-
value
|
17
|
+
value.to_a
|
14
18
|
end
|
15
19
|
|
16
20
|
def validate(list)
|
data/lib/typero/type/boolean.rb
CHANGED
data/lib/typero/type/email.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
module Typero
|
2
2
|
class EmailType < Typero::Type
|
3
3
|
def set(value)
|
4
|
-
value.downcase
|
4
|
+
value.downcase.gsub(/\s+/,'+')
|
5
5
|
end
|
6
6
|
|
7
7
|
def validate(value)
|
8
8
|
raise TypeError, 'is not having at least 8 characters' unless value.to_s.length > 7
|
9
9
|
raise TypeError, 'is missing @' unless value.include?('@')
|
10
|
-
raise TypeError, 'is in wrong
|
11
|
-
raise TypeError, 'is in wrong format' unless value =~ /^[\w\-\.]+\@[\w\-\.]+$/i
|
10
|
+
raise TypeError, 'is in wrong format' unless value =~ /^[\+\w\-\.]+\@[\w\-\.]+$/i
|
12
11
|
true
|
13
12
|
end
|
14
13
|
end
|
data/lib/typero/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_blank
|