typero 0.4.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/adapters/sequel.rb +69 -0
- data/lib/typero.rb +12 -170
- data/lib/typero/exporter.rb +93 -0
- data/lib/typero/params.rb +99 -0
- data/lib/typero/schema.rb +132 -0
- data/lib/typero/type/type.rb +110 -0
- data/lib/typero/type/types/boolean_type.rb +26 -0
- data/lib/typero/type/types/currency_type.rb +21 -0
- data/lib/typero/type/types/date_type.rb +32 -0
- data/lib/typero/type/types/datetime_type.rb +14 -0
- data/lib/typero/type/types/email_type.rb +20 -0
- data/lib/typero/type/types/float_type.rb +24 -0
- data/lib/typero/type/types/hash_type.rb +25 -0
- data/lib/typero/type/types/image_type.rb +22 -0
- data/lib/typero/type/types/integer_type.rb +16 -0
- data/lib/typero/type/types/label_type.rb +20 -0
- data/lib/typero/type/types/model_type.rb +21 -0
- data/lib/typero/type/{oib.rb → types/oib_type.rb} +16 -11
- data/lib/typero/type/types/point_type.rb +25 -0
- data/lib/typero/type/types/string_type.rb +20 -0
- data/lib/typero/type/types/text_type.rb +10 -0
- data/lib/typero/type/types/url_type.rb +13 -0
- data/lib/typero/typero.rb +90 -0
- metadata +29 -19
- data/lib/typero/type.rb +0 -39
- data/lib/typero/type/array.rb +0 -44
- data/lib/typero/type/boolean.rb +0 -10
- data/lib/typero/type/email.rb +0 -21
- data/lib/typero/type/float.rb +0 -21
- data/lib/typero/type/hash.rb +0 -14
- data/lib/typero/type/integer.rb +0 -19
- data/lib/typero/type/label.rb +0 -13
- data/lib/typero/type/string.rb +0 -22
- data/lib/typero/type/url.rb +0 -14
data/lib/typero/type/float.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Typero::FloatType < Typero::Type
|
2
|
-
|
3
|
-
def set
|
4
|
-
@value = @value.to_f
|
5
|
-
end
|
6
|
-
|
7
|
-
def validate
|
8
|
-
raise TypeError, error_for(:min_length_error) % @opts[:min] if @opts[:min] && value < @opts[:min]
|
9
|
-
raise TypeError, error_for(:max_length_error) % @opts[:max] if @opts[:max] && value > @opts[:max]
|
10
|
-
end
|
11
|
-
|
12
|
-
def min_length_error
|
13
|
-
"min lenght is %s"
|
14
|
-
end
|
15
|
-
|
16
|
-
def max_length_error
|
17
|
-
"max lenght is %s"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
data/lib/typero/type/hash.rb
DELETED
data/lib/typero/type/integer.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class Typero::IntegerType < Typero::Type
|
2
|
-
def set
|
3
|
-
@value = @value.to_i
|
4
|
-
end
|
5
|
-
|
6
|
-
def validate
|
7
|
-
raise TypeError, error_for(:min_value_error) % [@opts[:min], @value] if @opts[:min] && @value < @opts[:min]
|
8
|
-
raise TypeError, error_for(:max_value_error) % [@opts[:max], @value] if @opts[:max] && @value > @opts[:max]
|
9
|
-
end
|
10
|
-
|
11
|
-
def min_value_error
|
12
|
-
'min is %s, got %s'
|
13
|
-
end
|
14
|
-
|
15
|
-
def max_value_error
|
16
|
-
'max is %s, got %s'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
data/lib/typero/type/label.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class Typero::LabelType < Typero::Type
|
2
|
-
def set
|
3
|
-
@value = @value.to_s.gsub(/\s+/,'-').gsub(/[^\w\-]/,'').gsub(/\-+/, '-')[0,30].downcase
|
4
|
-
end
|
5
|
-
|
6
|
-
def validate
|
7
|
-
raise TypeError, error_for(:unallowed_characters_error) unless @value =~ /^[\w\-]+$/
|
8
|
-
end
|
9
|
-
|
10
|
-
def unallowed_characters_error
|
11
|
-
'label is having unallowed characters'
|
12
|
-
end
|
13
|
-
end
|
data/lib/typero/type/string.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class Typero::StringType < Typero::Type
|
2
|
-
def set
|
3
|
-
@value = @value.to_s unless @value.is_a?(String)
|
4
|
-
@value = @value.downcase if @opts[:downcase]
|
5
|
-
end
|
6
|
-
|
7
|
-
def validate
|
8
|
-
raise TypeError, error_for(:min_length_error) % [@opts[:min], @value.length] if @opts[:min] && @value.length < @opts[:min]
|
9
|
-
raise TypeError, error_for(:max_length_error) % [@opts[:max], @value.length] if @opts[:max] && @value.length > @opts[:max]
|
10
|
-
end
|
11
|
-
|
12
|
-
# ready for localization
|
13
|
-
|
14
|
-
def min_length_error
|
15
|
-
'min lenght is %s, you have %s'
|
16
|
-
end
|
17
|
-
|
18
|
-
def max_length_error
|
19
|
-
'max lenght is %s, you have %s'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
data/lib/typero/type/url.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
class Typero::UrlType < Typero::Type
|
2
|
-
def set
|
3
|
-
@value = 'http://%s' % @value unless @value.include?('://')
|
4
|
-
end
|
5
|
-
|
6
|
-
def validate
|
7
|
-
raise TypeError, error_for(:not_starting_error) unless @value =~ /^https?:\/\/./
|
8
|
-
end
|
9
|
-
|
10
|
-
def not_starting_error
|
11
|
-
'URL is not starting with http'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|