dry-data 0.2.0 → 0.2.1
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/CHANGELOG.md +16 -0
- data/README.md +42 -15
- data/lib/dry/data/compiler.rb +6 -2
- data/lib/dry/data/types/form.rb +1 -1
- data/lib/dry/data/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: 51e010763886f9dde2222d1c7846875136242d2a
|
4
|
+
data.tar.gz: fcdcfcc354e6d9ffa962a03f9d7994e9f4ae4cf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c10d34579e5a5fd825a36eba44ebc4d8b5637d9e7c4387f026188b2e17a2b148c03c27c914ce2ee40bd027a2b7b7fba731b24e88a20c8e9c89679ac0827259
|
7
|
+
data.tar.gz: 288618ca2bfa6b61c8e73681b1151391e388739c24fd3662607b56a18e80a5f22ad3f2544c20865fa77051bc2f494416824e0c6702bdac7d1267dfab0f556256
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# v0.2.1 2015-11-30
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
* Type compiler supports nested hashes now (solnic)
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
* `form.bool` sum is using correct right-side `form.false` type (solnic)
|
10
|
+
|
11
|
+
## Changed
|
12
|
+
|
13
|
+
* Improved structure of the ast (solnic)
|
14
|
+
|
15
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dryrb/dry-data/compare/v0.2.0...v0.2.1)
|
16
|
+
|
1
17
|
# v0.2.0 2015-11-29
|
2
18
|
|
3
19
|
## Added
|
data/README.md
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
|
1
|
+
[gem]: https://rubygems.org/gems/dry-data
|
2
|
+
[travis]: https://travis-ci.org/dryrb/dry-data
|
3
|
+
[gemnasium]: https://gemnasium.com/dryrb/dry-data
|
4
|
+
[codeclimate]: https://codeclimate.com/github/dryrb/dry-data
|
5
|
+
[coveralls]: https://coveralls.io/r/dryrb/dry-data
|
6
|
+
[inchpages]: http://inch-ci.org/github/dryrb/dry-data
|
2
7
|
|
3
|
-
|
4
|
-
<a href="https://travis-ci.org/dryrb/dry-data" target="_blank"></a>
|
5
|
-
<a href="https://gemnasium.com/dryrb/dry-data" target="_blank"></a>
|
6
|
-
<a href="https://codeclimate.com/github/dryrb/dry-data" target="_blank"></a>
|
7
|
-
<a href="http://inch-ci.org/github/dryrb/dry-data" target="_blank"></a>
|
8
|
+
# dry-data [](https://gitter.im/dryrb/chat)
|
8
9
|
|
9
|
-
|
10
|
+
[][gem]
|
11
|
+
[][travis]
|
12
|
+
[][gemnasium]
|
13
|
+
[][codeclimate]
|
14
|
+
[][codeclimate]
|
15
|
+
[][inchpages]
|
16
|
+
|
17
|
+
A simple type system for Ruby with support for coercions.
|
10
18
|
|
11
19
|
## Installation
|
12
20
|
|
@@ -40,6 +48,15 @@ Built-in types are grouped under 5 categories:
|
|
40
48
|
|
41
49
|
### Built-in Type Categories
|
42
50
|
|
51
|
+
Non-coercible:
|
52
|
+
|
53
|
+
- `nil`
|
54
|
+
- `true`
|
55
|
+
- `false`
|
56
|
+
- `date`
|
57
|
+
- `date_time`
|
58
|
+
- `time`
|
59
|
+
|
43
60
|
Coercible types using kernel coercion methods:
|
44
61
|
|
45
62
|
- `coercible.string`
|
@@ -49,17 +66,27 @@ Coercible types using kernel coercion methods:
|
|
49
66
|
- `coercible.array`
|
50
67
|
- `coercible.hash`
|
51
68
|
|
52
|
-
|
69
|
+
Optional strict types:
|
53
70
|
|
54
|
-
- `
|
55
|
-
- `
|
56
|
-
- `
|
57
|
-
- `
|
58
|
-
- `
|
59
|
-
- `
|
71
|
+
- `maybe.strict.string`
|
72
|
+
- `maybe.strict.int`
|
73
|
+
- `maybe.strict.float`
|
74
|
+
- `maybe.strict.decimal`
|
75
|
+
- `maybe.strict.array`
|
76
|
+
- `maybe.strict.hash`
|
77
|
+
|
78
|
+
Optional coercible types:
|
79
|
+
|
80
|
+
- `maybe.coercible.string`
|
81
|
+
- `maybe.coercible.int`
|
82
|
+
- `maybe.coercible.float`
|
83
|
+
- `maybe.coercible.decimal`
|
84
|
+
- `maybe.coercible.array`
|
85
|
+
- `maybe.coercible.hash`
|
60
86
|
|
61
|
-
|
87
|
+
Coercible types suitable for form param processing:
|
62
88
|
|
89
|
+
- `form.nil`
|
63
90
|
- `form.date`
|
64
91
|
- `form.date_time`
|
65
92
|
- `form.time`
|
data/lib/dry/data/compiler.rb
CHANGED
@@ -18,13 +18,17 @@ module Dry
|
|
18
18
|
def visit_type(node)
|
19
19
|
type, args = node
|
20
20
|
|
21
|
-
if
|
21
|
+
if respond_to?(:"visit_#{type}")
|
22
22
|
send(:"visit_#{type}", args)
|
23
23
|
else
|
24
24
|
registry[type]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def visit_sum(node)
|
29
|
+
node.map { |type| visit(type) }.reduce(:|)
|
30
|
+
end
|
31
|
+
|
28
32
|
def visit_hash(node)
|
29
33
|
constructor, schema = node
|
30
34
|
registry['hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge))
|
@@ -32,7 +36,7 @@ module Dry
|
|
32
36
|
|
33
37
|
def visit_key(node)
|
34
38
|
name, types = node
|
35
|
-
{ name => types
|
39
|
+
{ name => visit(types) }
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/dry/data/types/form.rb
CHANGED
data/lib/dry/data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|