yaoc 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +5 -1
  5. data/Guardfile +5 -0
  6. data/Rakefile +3 -0
  7. data/examples/01_hash_enabled_constructors.rb +8 -8
  8. data/examples/02_procs_as_constructors.rb +11 -13
  9. data/examples/03_positional_constructors.rb +7 -13
  10. data/examples/04_compositions.rb +3 -8
  11. data/examples/05_fill_existing_objects.rb +2 -8
  12. data/examples/06_lazy_loading.rb +0 -7
  13. data/examples/all_examples.rb +2 -2
  14. data/lib/yaoc.rb +2 -3
  15. data/lib/yaoc/converter_builder.rb +14 -21
  16. data/lib/yaoc/helper/struct_hash_constructor.rb +3 -4
  17. data/lib/yaoc/helper/to_proc_delegator.rb +4 -6
  18. data/lib/yaoc/many_to_one_mapper_chain.rb +11 -13
  19. data/lib/yaoc/mapper_registry.rb +3 -4
  20. data/lib/yaoc/mapping_base.rb +11 -12
  21. data/lib/yaoc/mapping_to_class.rb +7 -9
  22. data/lib/yaoc/object_mapper.rb +10 -13
  23. data/lib/yaoc/one_to_many_mapper_chain.rb +4 -6
  24. data/lib/yaoc/strategies/to_array_mapping.rb +1 -3
  25. data/lib/yaoc/strategies/to_hash_mapping.rb +1 -3
  26. data/lib/yaoc/transformation_command.rb +27 -8
  27. data/lib/yaoc/transformation_deferred_command.rb +3 -5
  28. data/lib/yaoc/version.rb +1 -1
  29. data/rubocop-todo.yml +96 -0
  30. data/spec/acceptance/fill_existing_objects_spec.rb +30 -30
  31. data/spec/acceptance/map_multiple_objects_to_one_in_a_chain_spec.rb +15 -15
  32. data/spec/acceptance/map_objects_spec.rb +22 -22
  33. data/spec/acceptance/map_one_object_to_many_in_a_chain_spec.rb +15 -15
  34. data/spec/acceptance/map_to_objects_using_other_converters_spec.rb +53 -55
  35. data/spec/acceptance/map_to_objects_with_lazy_loading_spec.rb +17 -17
  36. data/spec/acceptance/map_to_objects_with_positional_constructors_spec.rb +19 -19
  37. data/spec/integration/lib/yaoc/converter_builder_spec.rb +21 -21
  38. data/spec/spec_helper.rb +7 -7
  39. data/spec/support/feature.rb +1 -2
  40. data/spec/unit/lib/yaoc/converter_builder_spec.rb +42 -44
  41. data/spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb +15 -15
  42. data/spec/unit/lib/yaoc/helper/to_proc_delegator_spec.rb +11 -11
  43. data/spec/unit/lib/yaoc/many_to_one_mapper_chain_spec.rb +19 -20
  44. data/spec/unit/lib/yaoc/mapper_registry_spec.rb +6 -6
  45. data/spec/unit/lib/yaoc/mapping_base_spec.rb +36 -36
  46. data/spec/unit/lib/yaoc/mapping_to_class_spec.rb +19 -21
  47. data/spec/unit/lib/yaoc/object_mapper_spec.rb +45 -49
  48. data/spec/unit/lib/yaoc/one_to_many_mapper_chain_spec.rb +17 -18
  49. data/spec/unit/lib/yaoc/strategies/to_array_mapping_spec.rb +23 -24
  50. data/spec/unit/lib/yaoc/strategies/to_hash_mapping_spec.rb +25 -25
  51. data/spec/unit/lib/yaoc/transformation_command_spec.rb +13 -13
  52. data/spec/unit/lib/yaoc/transformation_deferred_command_spec.rb +9 -9
  53. data/yaoc.gemspec +1 -0
  54. metadata +18 -2
@@ -1,35 +1,35 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Yaoc::Strategies::ToHashMapping do
4
- subject{
4
+ subject do
5
5
  Struct.new(:to_convert) do
6
6
  include Yaoc::MappingBase
7
7
  self.mapping_strategy = Yaoc::Strategies::ToHashMapping
8
8
  end
9
- }
9
+ end
10
10
 
11
- let(:mapper){
11
+ let(:mapper)do
12
12
  subject.new(source_object)
13
- }
13
+ end
14
14
 
15
- let(:source_object){
16
- {id: 1, name: "paul"}
17
- }
15
+ let(:source_object)do
16
+ { id: 1, name: 'paul' }
17
+ end
18
18
 
19
- let(:expected_hash){
20
- {id: 1, name: "paul"}
21
- }
19
+ let(:expected_hash)do
20
+ { id: 1, name: 'paul' }
21
+ end
22
22
 
23
- describe "#call" do
23
+ describe '#call' do
24
24
 
25
- it "creates a hash from a object" do
25
+ it 'creates a hash from a object' do
26
26
  subject.map(to: :id, from: :id)
27
27
  subject.map(to: :name, from: :name)
28
28
 
29
29
  expect(mapper.call).to eq(expected_hash)
30
30
  end
31
31
 
32
- it "renames attributes" do
32
+ it 'renames attributes' do
33
33
  subject.map(to: :id)
34
34
  subject.map(to: :fullname, from: :name)
35
35
 
@@ -39,22 +39,22 @@ describe Yaoc::Strategies::ToHashMapping do
39
39
  expect(mapper.call).to eq(renamed_expectation)
40
40
  end
41
41
 
42
- it "uses my converter proc" do
42
+ it 'uses my converter proc' do
43
43
  subject.map(to: :id)
44
- subject.map(to: :name, from: :fullname, converter: ->(source, result){ Yaoc::TransformationCommand.fill_result_with_value(result, :name, source.fetch(:name) + " Hello World") })
44
+ subject.map(to: :name, from: :fullname, converter: ->(source, result) { Yaoc::TransformationCommand.fill_result_with_value(result, :name, source.fetch(:name) + ' Hello World') })
45
45
 
46
46
  ext_expectation = expected_hash.clone
47
- ext_expectation[:name] += " Hello World"
47
+ ext_expectation[:name] += ' Hello World'
48
48
 
49
49
  expect(mapper.call).to eq(ext_expectation)
50
50
  end
51
51
 
52
- context "changed fetcher method" do
53
- let(:source_object){
54
- Struct.new(:id, :name).new(1, "paul")
55
- }
52
+ context 'changed fetcher method' do
53
+ let(:source_object)do
54
+ Struct.new(:id, :name).new(1, 'paul')
55
+ end
56
56
 
57
- it "uses custom fetcher methods" do
57
+ it 'uses custom fetcher methods' do
58
58
  subject.map(to: :id)
59
59
  subject.map(to: :name)
60
60
 
@@ -65,7 +65,7 @@ describe Yaoc::Strategies::ToHashMapping do
65
65
  expect(mapper.call).to eq(expected_hash)
66
66
  end
67
67
 
68
- it "works with arrays" do
68
+ it 'works with arrays' do
69
69
  subject.map(to: :id, from: 0)
70
70
  subject.map(to: :name, from: 1)
71
71
 
@@ -73,7 +73,7 @@ describe Yaoc::Strategies::ToHashMapping do
73
73
  :[]
74
74
  end
75
75
 
76
- mapper.to_convert = [1, "paul"]
76
+ mapper.to_convert = [1, 'paul']
77
77
 
78
78
  expect(mapper.call).to eq(expected_hash)
79
79
  end
@@ -81,4 +81,4 @@ describe Yaoc::Strategies::ToHashMapping do
81
81
 
82
82
  end
83
83
 
84
- end
84
+ end
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yaoc::TransformationCommand do
4
- subject{
4
+ subject do
5
5
  Yaoc::TransformationCommand.new(to: :id, from: :name, fetch_method: :fetch)
6
- }
6
+ end
7
7
 
8
- let(:source){
9
- {name: 'my_name'}
10
- }
8
+ let(:source)do
9
+ { name: 'my_name' }
10
+ end
11
11
 
12
- let(:result){
12
+ let(:result)do
13
13
  {}
14
- }
14
+ end
15
15
 
16
16
  describe '.create' do
17
- subject{
17
+ subject do
18
18
  Yaoc::TransformationCommand
19
- }
19
+ end
20
20
 
21
21
  it 'creates a proc' do
22
22
  expect(subject.create(to: :to, from: :from)).to respond_to :call
@@ -54,11 +54,11 @@ describe Yaoc::TransformationCommand do
54
54
  end
55
55
 
56
56
  describe '#value' do
57
- subject {
57
+ subject do
58
58
  Yaoc::TransformationCommand.new(to: :id, from: :name, fetch_method: :fetch, fetcher_proc: value_fetcher)
59
- }
59
+ end
60
60
 
61
- let(:value_fetcher) { double('value fetcher proc')}
61
+ let(:value_fetcher) { double('value fetcher proc') }
62
62
 
63
63
  it 'uses a given proc for value fetching' do
64
64
  expect(value_fetcher).to receive(:call).with(source, :fetch, :name).and_return(:some_thing_to_store)
@@ -67,4 +67,4 @@ describe Yaoc::TransformationCommand do
67
67
  end
68
68
 
69
69
  end
70
- end
70
+ end
@@ -1,20 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yaoc::TransformationDeferredCommand do
4
- subject{
4
+ subject do
5
5
  Yaoc::TransformationDeferredCommand.new(to: :id, from: :name, fetch_method: :fetch)
6
- }
6
+ end
7
7
 
8
- let(:source){
9
- {name: 'my_name'}
10
- }
8
+ let(:source)do
9
+ { name: 'my_name' }
10
+ end
11
11
 
12
- let(:result){
12
+ let(:result)do
13
13
  {}
14
- }
14
+ end
15
15
 
16
16
  describe '#value' do
17
- let(:value_fetcher) { double('value fetcher proc')}
17
+ let(:value_fetcher) { double('value fetcher proc') }
18
18
 
19
19
  it 'deferres access to source object' do
20
20
  expect(source).not_to receive :fetch
@@ -29,4 +29,4 @@ describe Yaoc::TransformationDeferredCommand do
29
29
  end
30
30
 
31
31
  end
32
- end
32
+ end
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'guard-rspec'
37
37
  spec.add_development_dependency 'guard-bundler'
38
38
  spec.add_development_dependency 'rb-fsevent'
39
+ spec.add_development_dependency 'guard-rubocop'
39
40
 
40
41
  # https://github.com/pry/pry-stack_explorer
41
42
  spec.add_development_dependency 'pry-stack_explorer'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dieter Späth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scoped_storage
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard-rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: pry-stack_explorer
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -214,6 +228,7 @@ extensions: []
214
228
  extra_rdoc_files: []
215
229
  files:
216
230
  - ".gitignore"
231
+ - ".rubocop.yml"
217
232
  - ".travis.yml"
218
233
  - Gemfile
219
234
  - Guardfile
@@ -242,6 +257,7 @@ files:
242
257
  - lib/yaoc/transformation_command.rb
243
258
  - lib/yaoc/transformation_deferred_command.rb
244
259
  - lib/yaoc/version.rb
260
+ - rubocop-todo.yml
245
261
  - spec/acceptance/fill_existing_objects_spec.rb
246
262
  - spec/acceptance/map_multiple_objects_to_one_in_a_chain_spec.rb
247
263
  - spec/acceptance/map_objects_spec.rb