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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60d6552bfc31e32d4098f7919bdef5296b74fdac
4
- data.tar.gz: 8eca5e969300fa63429c8332b4fa68e771f98f3c
3
+ metadata.gz: 888f5525802c8f106e5bd5432f4f03a6fa1a1e98
4
+ data.tar.gz: 61a9c8cd3fe194d14bc96723db96f758a825e23f
5
5
  SHA512:
6
- metadata.gz: 01590a1d49c956c48e07611f29693185973a50bfba4ce5099ae4a8fbc88da251db70d132326f5ad4887f9e4d349d979ae26e111d9c999de3af4649457703f230
7
- data.tar.gz: ad3179f84bd1df5314c736ba3fff9ba1aadd88241e64b285c75217242b7955de23abc26f40eac41b0a04d604b10311958d27a55103ae64afe34c2a15027da8a1
6
+ metadata.gz: 684566603982171e10278f29700ca6af5ac643356c6b0bf3953ade8603a4e4e40219e39d770441461f3efbd4f36e6001fd69ed23ec0a27c0138be767ad174133
7
+ data.tar.gz: 3cd50d174a5472f67f34216e128d480ba3ad754650425b83cdee62d1bcdfede53a169dd9b3aa1f59f84bef002f463b7b1443b5fe5440bade4264b03912da614b
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ script: "bundle exec rake ci"
6
6
  rvm:
7
7
  - 2.0
8
8
  - 2.1
9
- - 2.2
9
+ - 2.2.5
10
10
  - 2.3.0
11
11
  - rbx-2
12
12
  - jruby-9000
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
@@ -2,6 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'rom-support', github: 'rom-rb/rom-support', branch: 'master'
6
+
5
7
  group :test do
6
8
  gem 'anima', '~> 0.2.0'
7
9
  gem 'virtus'
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-rb.org/guides/basics/mappers/)
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
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  class Mapper
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -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', '~> 1.0.0'
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
- describe 'key from exsisting keys' do
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.3.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-01-06 00:00:00.000000000 Z
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: 1.0.0
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: 1.0.0
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.4.5
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: