dry-data 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66f872c57c14fed55be62785dabd619e72cf79ff
4
- data.tar.gz: 663d9e422d10619df80ff448ecc268c66651586a
3
+ metadata.gz: 51e010763886f9dde2222d1c7846875136242d2a
4
+ data.tar.gz: fcdcfcc354e6d9ffa962a03f9d7994e9f4ae4cf0
5
5
  SHA512:
6
- metadata.gz: e675b8735a351ec4f5d086cbc51eeb64a1f1d06ad28d3b96e09024ee076eef687cac70cc209afc63b6bc463f73ebe2f8c6dbdb86159befed7fb61e40d7610282
7
- data.tar.gz: a44e721d53be8ff1e25c34e95acd174bf15982199e5bcd9626f4aaa608c022658454a3e03f3d5260f6011e839cd7c37d84b0996224cb1bd54835e616c88d8ec2
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
- # Dry::Data <a href="https://gitter.im/dryrb/chat" target="_blank">![Join the chat at https://gitter.im/dryrb/chat](https://badges.gitter.im/Join%20Chat.svg)</a>
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
- <a href="https://rubygems.org/gems/dry-data" target="_blank">![Gem Version](https://badge.fury.io/rb/dry-data.svg)</a>
4
- <a href="https://travis-ci.org/dryrb/dry-data" target="_blank">![Build Status](https://travis-ci.org/dryrb/dry-data.svg?branch=master)</a>
5
- <a href="https://gemnasium.com/dryrb/dry-data" target="_blank">![Dependency Status](https://gemnasium.com/dryrb/dry-data.svg)</a>
6
- <a href="https://codeclimate.com/github/dryrb/dry-data" target="_blank">![Code Climate](https://codeclimate.com/github/dryrb/dry-data/badges/gpa.svg)</a>
7
- <a href="http://inch-ci.org/github/dryrb/dry-data" target="_blank">![Documentation Status](http://inch-ci.org/github/dryrb/dry-data.svg?branch=master&style=flat)</a>
8
+ # dry-data [![Join the chat at https://gitter.im/dryrb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dryrb/chat)
8
9
 
9
- A simple type-system for Ruby respecting ruby's built-in coercion mechanisms.
10
+ [![Gem Version](https://badge.fury.io/rb/dry-data.svg)][gem]
11
+ [![Build Status](https://travis-ci.org/dryrb/dry-data.svg?branch=master)][travis]
12
+ [![Dependency Status](https://gemnasium.com/dryrb/dry-data.svg)][gemnasium]
13
+ [![Code Climate](https://codeclimate.com/github/dryrb/dry-data/badges/gpa.svg)][codeclimate]
14
+ [![Test Coverage](https://codeclimate.com/github/dryrb/dry-data/badges/coverage.svg)][codeclimate]
15
+ [![Inline docs](http://inch-ci.org/github/dryrb/dry-data.svg?branch=master)][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
- Non-coercible:
69
+ Optional strict types:
53
70
 
54
- - `nil`
55
- - `true`
56
- - `false`
57
- - `date`
58
- - `date_time`
59
- - `time`
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
- Form-coercible types:
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`
@@ -18,13 +18,17 @@ module Dry
18
18
  def visit_type(node)
19
19
  type, args = node
20
20
 
21
- if args
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.map { |id| registry[id] }.reduce(:|) }
39
+ { name => visit(types) }
36
40
  end
37
41
  end
38
42
  end
@@ -23,7 +23,7 @@ module Dry
23
23
  end
24
24
 
25
25
  register('form.false') do
26
- Type.new(Coercions::Form.method(:to_true), FalseClass)
26
+ Type.new(Coercions::Form.method(:to_false), FalseClass)
27
27
  end
28
28
 
29
29
  register('form.bool') do
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Data
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
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.0
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-29 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container