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.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -1
  4. data/.travis.yml +19 -13
  5. data/{Changelog.md → CHANGELOG.md} +6 -0
  6. data/Gemfile +23 -10
  7. data/README.md +17 -12
  8. data/Rakefile +12 -4
  9. data/lib/rom-mapper.rb +6 -15
  10. data/lib/rom/header.rb +195 -0
  11. data/lib/rom/header/attribute.rb +184 -0
  12. data/lib/rom/mapper.rb +63 -100
  13. data/lib/rom/mapper/attribute_dsl.rb +477 -0
  14. data/lib/rom/mapper/dsl.rb +120 -0
  15. data/lib/rom/mapper/model_dsl.rb +55 -0
  16. data/lib/rom/mapper/version.rb +3 -7
  17. data/lib/rom/model_builder.rb +99 -0
  18. data/lib/rom/processor.rb +28 -0
  19. data/lib/rom/processor/transproc.rb +388 -0
  20. data/rakelib/benchmark.rake +15 -0
  21. data/rakelib/mutant.rake +16 -0
  22. data/rakelib/rubocop.rake +18 -0
  23. data/rom-mapper.gemspec +7 -6
  24. data/spec/spec_helper.rb +32 -33
  25. data/spec/support/constant_leak_finder.rb +14 -0
  26. data/spec/support/mutant.rb +10 -0
  27. data/spec/unit/rom/mapper/dsl_spec.rb +467 -0
  28. data/spec/unit/rom/mapper_spec.rb +83 -0
  29. data/spec/unit/rom/processor/transproc_spec.rb +448 -0
  30. metadata +68 -89
  31. data/.ruby-version +0 -1
  32. data/Gemfile.devtools +0 -55
  33. data/config/devtools.yml +0 -2
  34. data/config/flay.yml +0 -3
  35. data/config/flog.yml +0 -2
  36. data/config/mutant.yml +0 -3
  37. data/config/reek.yml +0 -103
  38. data/config/rubocop.yml +0 -45
  39. data/lib/rom/mapper/attribute.rb +0 -31
  40. data/lib/rom/mapper/dumper.rb +0 -27
  41. data/lib/rom/mapper/loader.rb +0 -22
  42. data/lib/rom/mapper/loader/allocator.rb +0 -32
  43. data/lib/rom/mapper/loader/attribute_writer.rb +0 -23
  44. data/lib/rom/mapper/loader/object_builder.rb +0 -28
  45. data/spec/shared/unit/loader_call.rb +0 -13
  46. data/spec/shared/unit/loader_identity.rb +0 -13
  47. data/spec/shared/unit/mapper_context.rb +0 -13
  48. data/spec/unit/rom/mapper/call_spec.rb +0 -32
  49. data/spec/unit/rom/mapper/class_methods/build_spec.rb +0 -64
  50. data/spec/unit/rom/mapper/dump_spec.rb +0 -15
  51. data/spec/unit/rom/mapper/dumper/call_spec.rb +0 -29
  52. data/spec/unit/rom/mapper/dumper/identity_spec.rb +0 -28
  53. data/spec/unit/rom/mapper/header/each_spec.rb +0 -28
  54. data/spec/unit/rom/mapper/header/element_reader_spec.rb +0 -25
  55. data/spec/unit/rom/mapper/header/keys_spec.rb +0 -32
  56. data/spec/unit/rom/mapper/identity_from_tuple_spec.rb +0 -15
  57. data/spec/unit/rom/mapper/identity_spec.rb +0 -15
  58. data/spec/unit/rom/mapper/load_spec.rb +0 -15
  59. data/spec/unit/rom/mapper/loader/allocator/call_spec.rb +0 -7
  60. data/spec/unit/rom/mapper/loader/allocator/identity_spec.rb +0 -7
  61. data/spec/unit/rom/mapper/loader/attribute_writer/call_spec.rb +0 -7
  62. data/spec/unit/rom/mapper/loader/attribute_writer/identity_spec.rb +0 -7
  63. data/spec/unit/rom/mapper/loader/object_builder/call_spec.rb +0 -7
  64. data/spec/unit/rom/mapper/loader/object_builder/identity_spec.rb +0 -7
  65. data/spec/unit/rom/mapper/model_spec.rb +0 -11
  66. 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, '#identity' do
6
- subject { mapper.identity(object) }
7
-
8
- include_context 'Mapper'
9
-
10
- before do
11
- stub(dumper).identity(object) { [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,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::Allocator, '#call' do
6
- it_behaves_like 'Mapper::Loader#call'
7
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::Allocator, '#identity' do
6
- it_behaves_like 'Mapper::Loader#identity'
7
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::AttributeWriter, '#call' do
6
- it_behaves_like 'Mapper::Loader#call'
7
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::AttributeWriter, '#identity' do
6
- it_behaves_like 'Mapper::Loader#identity'
7
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::ObjectBuilder, '#call' do
6
- it_behaves_like 'Mapper::Loader#call'
7
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper::Loader::ObjectBuilder, '#identity' do
6
- it_behaves_like 'Mapper::Loader#identity'
7
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mapper, '#model' do
6
- subject { mapper.model }
7
-
8
- include_context 'Mapper'
9
-
10
- it { should be(model) }
11
- 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