schema 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/schema.rb +1 -0
- data/lib/schema/boolean.rb +12 -0
- data/lib/schema/version.rb +1 -1
- data/schema.gemspec +3 -2
- data/spec/schema_spec.rb +4 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -16,6 +16,10 @@ A Schema is either a type that implements `#from` or a hash of schemas or an arr
|
|
16
16
|
{ :string => String } # is a schema
|
17
17
|
{ :foo => [{ :bar => DateTime }]} # is a schema
|
18
18
|
|
19
|
+
Ruby has no Boolean class, therefore we define it, so we have
|
20
|
+
|
21
|
+
Boolean # is a schema
|
22
|
+
|
19
23
|
In Hash-schemas keys may be optional indicated by a trailing question mark.
|
20
24
|
|
21
25
|
{ :optional => '42' }.transform({ :optional? => Float }) == { :optional => 42.0 }
|
data/lib/schema.rb
CHANGED
data/lib/schema/version.rb
CHANGED
data/schema.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{schema}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Kirsch"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-07}
|
13
13
|
s.description = %q{Deep type conversion through schemas for hashes}
|
14
14
|
s.email = %q{danishkirel@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"autotest/discover.rb",
|
25
25
|
"lib/schema.rb",
|
26
|
+
"lib/schema/boolean.rb",
|
26
27
|
"lib/schema/core_ext.rb",
|
27
28
|
"lib/schema/include.rb",
|
28
29
|
"lib/schema/schema.rb",
|
data/spec/schema_spec.rb
CHANGED
@@ -11,6 +11,10 @@ describe "Schema" do
|
|
11
11
|
'42'.transform(Float).should be_kind_of(Float)
|
12
12
|
'42'.transform(Integer).should == 42
|
13
13
|
'42'.transform(Integer).should be_kind_of(Integer)
|
14
|
+
'true'.transform(Boolean).should == true
|
15
|
+
'true'.transform(Boolean).should be_kind_of(TrueClass)
|
16
|
+
'false'.transform(Boolean).should == false
|
17
|
+
'false'.transform(Boolean).should be_kind_of(FalseClass)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should cast dates" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Kirsch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-07 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- Rakefile
|
61
61
|
- autotest/discover.rb
|
62
62
|
- lib/schema.rb
|
63
|
+
- lib/schema/boolean.rb
|
63
64
|
- lib/schema/core_ext.rb
|
64
65
|
- lib/schema/include.rb
|
65
66
|
- lib/schema/schema.rb
|