rom-mapper 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -1
- data/.travis.yml +19 -13
- data/{Changelog.md → CHANGELOG.md} +6 -0
- data/Gemfile +23 -10
- data/README.md +17 -12
- data/Rakefile +12 -4
- data/lib/rom-mapper.rb +6 -15
- data/lib/rom/header.rb +195 -0
- data/lib/rom/header/attribute.rb +184 -0
- data/lib/rom/mapper.rb +63 -100
- data/lib/rom/mapper/attribute_dsl.rb +477 -0
- data/lib/rom/mapper/dsl.rb +120 -0
- data/lib/rom/mapper/model_dsl.rb +55 -0
- data/lib/rom/mapper/version.rb +3 -7
- data/lib/rom/model_builder.rb +99 -0
- data/lib/rom/processor.rb +28 -0
- data/lib/rom/processor/transproc.rb +388 -0
- data/rakelib/benchmark.rake +15 -0
- data/rakelib/mutant.rake +16 -0
- data/rakelib/rubocop.rake +18 -0
- data/rom-mapper.gemspec +7 -6
- data/spec/spec_helper.rb +32 -33
- data/spec/support/constant_leak_finder.rb +14 -0
- data/spec/support/mutant.rb +10 -0
- data/spec/unit/rom/mapper/dsl_spec.rb +467 -0
- data/spec/unit/rom/mapper_spec.rb +83 -0
- data/spec/unit/rom/processor/transproc_spec.rb +448 -0
- metadata +68 -89
- data/.ruby-version +0 -1
- data/Gemfile.devtools +0 -55
- data/config/devtools.yml +0 -2
- data/config/flay.yml +0 -3
- data/config/flog.yml +0 -2
- data/config/mutant.yml +0 -3
- data/config/reek.yml +0 -103
- data/config/rubocop.yml +0 -45
- data/lib/rom/mapper/attribute.rb +0 -31
- data/lib/rom/mapper/dumper.rb +0 -27
- data/lib/rom/mapper/loader.rb +0 -22
- data/lib/rom/mapper/loader/allocator.rb +0 -32
- data/lib/rom/mapper/loader/attribute_writer.rb +0 -23
- data/lib/rom/mapper/loader/object_builder.rb +0 -28
- data/spec/shared/unit/loader_call.rb +0 -13
- data/spec/shared/unit/loader_identity.rb +0 -13
- data/spec/shared/unit/mapper_context.rb +0 -13
- data/spec/unit/rom/mapper/call_spec.rb +0 -32
- data/spec/unit/rom/mapper/class_methods/build_spec.rb +0 -64
- data/spec/unit/rom/mapper/dump_spec.rb +0 -15
- data/spec/unit/rom/mapper/dumper/call_spec.rb +0 -29
- data/spec/unit/rom/mapper/dumper/identity_spec.rb +0 -28
- data/spec/unit/rom/mapper/header/each_spec.rb +0 -28
- data/spec/unit/rom/mapper/header/element_reader_spec.rb +0 -25
- data/spec/unit/rom/mapper/header/keys_spec.rb +0 -32
- data/spec/unit/rom/mapper/identity_from_tuple_spec.rb +0 -15
- data/spec/unit/rom/mapper/identity_spec.rb +0 -15
- data/spec/unit/rom/mapper/load_spec.rb +0 -15
- data/spec/unit/rom/mapper/loader/allocator/call_spec.rb +0 -7
- data/spec/unit/rom/mapper/loader/allocator/identity_spec.rb +0 -7
- data/spec/unit/rom/mapper/loader/attribute_writer/call_spec.rb +0 -7
- data/spec/unit/rom/mapper/loader/attribute_writer/identity_spec.rb +0 -7
- data/spec/unit/rom/mapper/loader/object_builder/call_spec.rb +0 -7
- data/spec/unit/rom/mapper/loader/object_builder/identity_spec.rb +0 -7
- data/spec/unit/rom/mapper/model_spec.rb +0 -11
- data/spec/unit/rom/mapper/new_object_spec.rb +0 -14
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mapper::Header, '#keys' do
|
6
|
-
subject { object.keys }
|
7
|
-
|
8
|
-
let(:object) { Mapper::Header.build(attributes, options) }
|
9
|
-
let(:id) { object[:id] }
|
10
|
-
let(:name) { object[:name] }
|
11
|
-
|
12
|
-
context 'without mapping' do
|
13
|
-
let(:options) { Hash[keys: [:id]] }
|
14
|
-
let(:attributes) { [[:id, Integer], [:name, String]] }
|
15
|
-
|
16
|
-
it { should eql([id]) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with mapping' do
|
20
|
-
let(:attributes) { [[:user_id, Integer], [:name, String]] }
|
21
|
-
let(:options) { Hash[keys: [:user_id], map: { user_id: :id }] }
|
22
|
-
|
23
|
-
it { should eql([id]) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with multiple keys' do
|
27
|
-
let(:attributes) { [[:id, Integer], [:name, String]] }
|
28
|
-
let(:options) { Hash[keys: [:id, :name]] }
|
29
|
-
|
30
|
-
it { should eql([id, name]) }
|
31
|
-
end
|
32
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mapper, '#identity_from_tuple' do
|
6
|
-
subject { mapper.identity_from_tuple(tuple) }
|
7
|
-
|
8
|
-
include_context 'Mapper'
|
9
|
-
|
10
|
-
before do
|
11
|
-
stub(loader).identity(tuple) { [1] }
|
12
|
-
end
|
13
|
-
|
14
|
-
it { should eq([1]) }
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mapper, '#load' do
|
6
|
-
include_context 'Mapper'
|
7
|
-
|
8
|
-
it 'loads the tuple into model' do
|
9
|
-
stub(loader).call(tuple) { object }
|
10
|
-
|
11
|
-
expect(mapper.load(tuple)).to be(object)
|
12
|
-
|
13
|
-
loader.should have_received.call(tuple)
|
14
|
-
end
|
15
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Mapper, '#new_object' do
|
6
|
-
subject { mapper.new_object(name: 'Jane', &block) }
|
7
|
-
|
8
|
-
include_context 'Mapper'
|
9
|
-
|
10
|
-
let(:attributes) { Hash[id: 1, name: 'Jane'] }
|
11
|
-
let(:block) { proc { self.id = 1 } }
|
12
|
-
|
13
|
-
it { should eql(model.new(attributes)) }
|
14
|
-
end
|