rom-mapper 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/lib/rom/mapper/version.rb +1 -1
- data/lib/rom/processor/transproc.rb +4 -1
- data/rom-mapper.gemspec +1 -1
- data/spec/unit/rom/processor/transproc_spec.rb +17 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 888f5525802c8f106e5bd5432f4f03a6fa1a1e98
|
4
|
+
data.tar.gz: 61a9c8cd3fe194d14bc96723db96f758a825e23f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 684566603982171e10278f29700ca6af5ac643356c6b0bf3953ade8603a4e4e40219e39d770441461f3efbd4f36e6001fd69ed23ec0a27c0138be767ad174133
|
7
|
+
data.tar.gz: 3cd50d174a5472f67f34216e128d480ba3ad754650425b83cdee62d1bcdfede53a169dd9b3aa1f59f84bef002f463b7b1443b5fe5440bade4264b03912da614b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v0.4.0 2016-07-27
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
* Raise a meaningful exception if no coercer exists (astupka)
|
6
|
+
* Don’t reject keys if copy_keys option is true (astupka)
|
7
|
+
|
8
|
+
[Compare v0.3.0..v0.4.0](https://github.com/rom-rb/rom-mapper/compare/v0.3.0...v0.4.0)
|
9
|
+
|
1
10
|
# v0.3.0 2016-01-06
|
2
11
|
|
3
12
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ backends. It is the default mapper in ROM.
|
|
18
18
|
|
19
19
|
Resources:
|
20
20
|
|
21
|
-
- [Guides](http://rom-
|
21
|
+
- [Guides](http://www.rubydoc.info/gems/rom-mapper/0.3.0/ROM/Mapper/AttributeDSL)
|
22
22
|
- [Importing Data with ROM and Transproc](http://solnic.eu/2015/07/15/importing-data-with-rom-and-transproc.html)
|
23
23
|
|
24
24
|
## License
|
data/lib/rom/mapper/version.rb
CHANGED
@@ -22,6 +22,7 @@ module ROM
|
|
22
22
|
import ::Transproc::HashTransformations
|
23
23
|
import ::Transproc::ClassTransformations
|
24
24
|
import ::Transproc::ProcTransformations
|
25
|
+
INVALID_INJECT_UNION_VALUE = "%s attribute: block is required for :from with union value.".freeze
|
25
26
|
|
26
27
|
def self.identity(tuple)
|
27
28
|
tuple
|
@@ -32,6 +33,8 @@ module ROM
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.inject_union_value(tuple, name, keys, coercer)
|
36
|
+
raise ROM::MapperMisconfiguredError, INVALID_INJECT_UNION_VALUE % [name] if !coercer
|
37
|
+
|
35
38
|
values = tuple.values_at(*keys)
|
36
39
|
result = coercer.call(*values)
|
37
40
|
|
@@ -128,7 +131,7 @@ module ROM
|
|
128
131
|
if attribute.union?
|
129
132
|
compose do |ops|
|
130
133
|
ops << t(:inject_union_value, attribute.name, attribute.key, coercer)
|
131
|
-
ops << t(:reject_keys, attribute.key)
|
134
|
+
ops << t(:reject_keys, attribute.key) unless header.copy_keys
|
132
135
|
end
|
133
136
|
elsif coercer
|
134
137
|
t(:map_value, attribute.name, t(:bind, mapper, coercer))
|
data/rom-mapper.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency 'dry-equalizer', '~> 0.2'
|
19
19
|
gem.add_dependency 'transproc', '~> 0.4.0'
|
20
|
-
gem.add_dependency 'rom-support', '~>
|
20
|
+
gem.add_dependency 'rom-support', '~> 2.0.0'
|
21
21
|
|
22
22
|
gem.add_development_dependency 'rake', '~> 10.3'
|
23
23
|
gem.add_development_dependency 'rspec', '~> 3.3'
|
@@ -86,7 +86,7 @@ describe ROM::Processor::Transproc do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
|
89
|
+
context 'key from existing keys' do
|
90
90
|
let(:attributes) do
|
91
91
|
coercer = ->(a, b) { b + a }
|
92
92
|
[[:c, { from: [:a, :b], coercer: coercer }]]
|
@@ -104,9 +104,25 @@ describe ROM::Processor::Transproc do
|
|
104
104
|
]
|
105
105
|
end
|
106
106
|
|
107
|
+
let(:copy_keys_expected_result) do
|
108
|
+
[
|
109
|
+
{ a: 'works', b: 'this', c: 'thisworks'}
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
107
113
|
it 'returns tuples a new key added based on exsiting keys' do
|
108
114
|
expect(transproc[relation]).to eql(expected_result)
|
109
115
|
end
|
116
|
+
|
117
|
+
it 'raises a configuration exception if coercer block does not exist' do
|
118
|
+
attributes[0][1][:coercer] = nil
|
119
|
+
expect { transproc[relation] }.to raise_error(ROM::MapperMisconfiguredError)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'honors the copy_keys option' do
|
123
|
+
options.merge!({ copy_keys: true })
|
124
|
+
expect(transproc[relation]).to eql(copy_keys_expected_result)
|
125
|
+
end
|
110
126
|
end
|
111
127
|
|
112
128
|
describe 'rejecting keys' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-equalizer
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.1
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: ROM mapper component
|
146
146
|
test_files: []
|
147
|
-
has_rdoc:
|