ethos 0.2.0.beta9 → 0.2.0.beta10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ethos/type.rb +6 -0
- data/lib/ethos/types/boolean.rb +6 -0
- data/lib/ethos/version.rb +1 -1
- data/spec/ethos/type.rb +26 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ef51a80ed7e8e3fb2045448dc275aaa4ea5681
|
4
|
+
data.tar.gz: 646c11a4562490daf0e42c7bba3955b652b59aff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33752ccbcfd4ffebec355244b0705cff6151077066dfb2f40bc2206d74c21cd70b4430f55b65983487b52de57bbcb8ae6790878da7d2fffe1c655b98b2aadf48
|
7
|
+
data.tar.gz: 55cbd2c752db32f19830105c09cb5bef80cf2b308069ca43b933afd6a21740ef095db38628ad35a1f641a0fb08c8ba7e6ac2f0883530436773b615362550f787
|
data/lib/ethos/type.rb
CHANGED
@@ -2,6 +2,8 @@ require 'date'
|
|
2
2
|
require 'time'
|
3
3
|
require 'bigdecimal'
|
4
4
|
|
5
|
+
require 'ethos/types/boolean'
|
6
|
+
|
5
7
|
module Ethos
|
6
8
|
module Type
|
7
9
|
CASTS = {}
|
@@ -24,6 +26,10 @@ module Ethos
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
Ethos::Type.define Ethos::Types::Boolean do |value|
|
30
|
+
value ? true : false
|
31
|
+
end
|
32
|
+
|
27
33
|
Ethos::Type.define Symbol do |value|
|
28
34
|
value.to_sym
|
29
35
|
end
|
data/lib/ethos/version.rb
CHANGED
data/spec/ethos/type.rb
CHANGED
@@ -2,6 +2,32 @@ require 'ethos/type'
|
|
2
2
|
require 'ethos/entity'
|
3
3
|
|
4
4
|
scope '.cast' do
|
5
|
+
scope 'casts a value to a Ethos::Types::Boolean' do
|
6
|
+
spec do
|
7
|
+
result = Ethos::Type.cast true, Ethos::Types::Boolean
|
8
|
+
|
9
|
+
asserts(result).truthy?
|
10
|
+
end
|
11
|
+
|
12
|
+
spec do
|
13
|
+
result = Ethos::Type.cast 1, Ethos::Types::Boolean
|
14
|
+
|
15
|
+
asserts(result).truthy?
|
16
|
+
end
|
17
|
+
|
18
|
+
spec do
|
19
|
+
result = Ethos::Type.cast false, Ethos::Types::Boolean
|
20
|
+
|
21
|
+
asserts(result).falsey?
|
22
|
+
end
|
23
|
+
|
24
|
+
spec do
|
25
|
+
result = Ethos::Type.cast nil, Ethos::Types::Boolean
|
26
|
+
|
27
|
+
asserts(result).falsey?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
5
31
|
spec 'casts a value to a Symbol' do
|
6
32
|
expected = :Symbol
|
7
33
|
result = Ethos::Type.cast 'Symbol', Symbol
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.beta10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erol Fornoles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/ethos/entity.rb
|
87
87
|
- lib/ethos/schema.rb
|
88
88
|
- lib/ethos/type.rb
|
89
|
+
- lib/ethos/types/boolean.rb
|
89
90
|
- lib/ethos/version.rb
|
90
91
|
- spec/.gitkeep
|
91
92
|
- spec/ethos/attributes.rb
|