dry-data 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -5
- data/lib/dry/data/compiler.rb +4 -0
- data/lib/dry/data/type/array.rb +3 -5
- data/lib/dry/data/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d798aac2e4dd90dc419ed04f7366d04a5aae2a1
|
4
|
+
data.tar.gz: 35060cab0302057a57e3f098ec2842cb9824840d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b60ca79d4da30f0af580450b3ea05b4d2fc09cf45235f419ef38d7de4a0f0e87cb5640e925433d7aa5d6a6a3153447b7505f973e9460e23a529ded9903827893
|
7
|
+
data.tar.gz: d71b05244589161fbe4a464f11eeb56ed94b7a8408b4c29e6ad934231b998545e9b3fdf3ba4bbcc01c097763489c6c0a43571f7b91a14f831a63cb859494a9d5
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
# v0.4.
|
1
|
+
# v0.4.2 2015-12-27
|
2
2
|
|
3
3
|
## Added
|
4
4
|
|
5
|
-
*
|
6
|
-
* `Dry::Data::Struct#[]` for reading attribute values (solnic)
|
7
|
-
* Ability to pass any class to hash schema assuming it has a corresponding type registered (solnic)
|
5
|
+
* Support for arrays in type compiler (solnic)
|
8
6
|
|
9
|
-
|
7
|
+
## Changed
|
8
|
+
|
9
|
+
* Array member uses type objects now rather than just their constructors (solnic)
|
10
|
+
|
11
|
+
[Compare v0.4.1...v0.4.2](https://github.com/dryrb/dry-data/compare/v0.4.1...v0.4.2)
|
10
12
|
|
11
13
|
# v0.4.0 2015-12-11
|
12
14
|
|
data/lib/dry/data/compiler.rb
CHANGED
@@ -34,6 +34,10 @@ module Dry
|
|
34
34
|
registry['hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge))
|
35
35
|
end
|
36
36
|
|
37
|
+
def visit_array(node)
|
38
|
+
registry['array'].member(call(node))
|
39
|
+
end
|
40
|
+
|
37
41
|
def visit_key(node)
|
38
42
|
name, types = node
|
39
43
|
{ name => visit(types) }
|
data/lib/dry/data/type/array.rb
CHANGED
@@ -3,16 +3,14 @@ module Dry
|
|
3
3
|
class Type
|
4
4
|
class Array < Type
|
5
5
|
def self.constructor(array_constructor, member_constructor, input)
|
6
|
-
array_constructor[input].map
|
6
|
+
array_constructor[input].map { |value| member_constructor[value] }
|
7
7
|
end
|
8
8
|
|
9
9
|
def member(type)
|
10
10
|
member_constructor =
|
11
11
|
case type
|
12
|
-
when
|
13
|
-
|
14
|
-
else
|
15
|
-
raise ArgumentError, "+#{type}+ is an unsupported array member"
|
12
|
+
when String, Class then Data[type]
|
13
|
+
else type
|
16
14
|
end
|
17
15
|
|
18
16
|
array_constructor = self.class
|
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.4.
|
4
|
+
version: 0.4.2
|
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-12-
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|
@@ -202,9 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
204
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.4.5
|
205
|
+
rubygems_version: 2.4.5.1
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Simple type-system for Ruby
|
209
209
|
test_files: []
|
210
|
-
has_rdoc:
|