abstract_mapper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +34 -0
  4. data/Gemfile +1 -3
  5. data/README.md +29 -13
  6. data/Rakefile +4 -7
  7. data/abstract_mapper.gemspec +3 -2
  8. data/config/metrics/STYLEGUIDE +14 -15
  9. data/lib/abstract_mapper.rb +4 -1
  10. data/lib/abstract_mapper/attributes.rb +65 -0
  11. data/lib/abstract_mapper/branch.rb +17 -7
  12. data/lib/abstract_mapper/builder.rb +7 -3
  13. data/lib/abstract_mapper/command.rb +68 -0
  14. data/lib/abstract_mapper/commands.rb +11 -31
  15. data/lib/abstract_mapper/errors/unknown_command.rb +1 -1
  16. data/lib/abstract_mapper/errors/wrong_node.rb +1 -1
  17. data/lib/abstract_mapper/errors/wrong_rule.rb +2 -2
  18. data/lib/abstract_mapper/functions.rb +32 -5
  19. data/lib/abstract_mapper/node.rb +21 -10
  20. data/lib/abstract_mapper/optimizer.rb +3 -3
  21. data/lib/abstract_mapper/pair_rule.rb +2 -4
  22. data/lib/abstract_mapper/rspec.rb +1 -2
  23. data/lib/abstract_mapper/rule.rb +23 -2
  24. data/lib/abstract_mapper/rules.rb +3 -10
  25. data/lib/abstract_mapper/settings.rb +3 -3
  26. data/lib/abstract_mapper/sole_rule.rb +2 -4
  27. data/lib/abstract_mapper/version.rb +1 -1
  28. data/lib/rspec/doubles.rb +16 -0
  29. data/lib/rspec/nodes.rb +29 -16
  30. data/lib/rspec/rules.rb +3 -3
  31. data/spec/integration/faceter.rb +16 -7
  32. data/spec/integration/mapper_definition_spec.rb +1 -1
  33. data/spec/integration/rspec_examples_spec.rb +4 -30
  34. data/spec/spec_helper.rb +1 -1
  35. data/spec/unit/abstract_mapper/branch_spec.rb +91 -14
  36. data/spec/unit/abstract_mapper/builder_spec.rb +66 -48
  37. data/spec/unit/abstract_mapper/command_spec.rb +92 -0
  38. data/spec/unit/abstract_mapper/commands_spec.rb +38 -79
  39. data/spec/unit/abstract_mapper/dsl_spec.rb +60 -55
  40. data/spec/unit/abstract_mapper/errors/wrong_rule_spec.rb +1 -1
  41. data/spec/unit/abstract_mapper/functions/compact_spec.rb +3 -3
  42. data/spec/unit/abstract_mapper/functions/filter_spec.rb +1 -1
  43. data/spec/unit/abstract_mapper/functions/identity_spec.rb +21 -0
  44. data/spec/unit/abstract_mapper/functions/restrict_spec.rb +16 -0
  45. data/spec/unit/abstract_mapper/functions/subclass_spec.rb +1 -1
  46. data/spec/unit/abstract_mapper/node_spec.rb +119 -48
  47. data/spec/unit/abstract_mapper/optimizer_spec.rb +38 -32
  48. data/spec/unit/abstract_mapper/pair_rule_spec.rb +4 -11
  49. data/spec/unit/abstract_mapper/rule_spec.rb +31 -15
  50. data/spec/unit/abstract_mapper/rules_spec.rb +2 -2
  51. data/spec/unit/abstract_mapper/settings_spec.rb +80 -73
  52. data/spec/unit/abstract_mapper/sole_rule_spec.rb +3 -10
  53. data/spec/unit/abstract_mapper_spec.rb +13 -5
  54. metadata +33 -12
  55. data/lib/rspec/functions.rb +0 -25
  56. data/lib/rspec/mapper.rb +0 -40
@@ -5,14 +5,7 @@ describe AbstractMapper::SoleRule do
5
5
  let(:rule) { test.new(node) }
6
6
  let(:test) { AbstractMapper::Test::Rule = Class.new(described_class) }
7
7
  let(:nodes) { [node] }
8
- let(:node) { double }
9
-
10
- describe ".composer" do
11
-
12
- subject { test.composer }
13
- it { is_expected.to eql :filter }
14
-
15
- end # describe .pair?
8
+ let(:node) { AbstractMapper::Node.new }
16
9
 
17
10
  describe ".new" do
18
11
 
@@ -41,9 +34,9 @@ describe AbstractMapper::SoleRule do
41
34
  test.send(:define_method, :optimize) { -node if node < 7 }
42
35
  end
43
36
 
44
- subject { test.transproc[array] }
45
-
46
37
  let(:array) { [5, 1, 38, 4] }
38
+
39
+ subject { test.transproc[array] }
47
40
  it { is_expected.to eql [-5, 1, -4] }
48
41
 
49
42
  end # describe #transproc
@@ -2,16 +2,23 @@
2
2
 
3
3
  describe AbstractMapper do
4
4
 
5
- let(:test) { Class.new(described_class) }
6
- let(:tree) { double transproc: transproc }
7
- let(:transproc) { double }
8
-
9
5
  let(:mapper) do
10
- allow(transproc).to receive(:call) { |input| "called: #{input}" }
11
6
  allow(test).to receive(:finalize) { tree }
12
7
  test.new
13
8
  end
14
9
 
10
+ let(:test) { Class.new(described_class) }
11
+
12
+ let(:tree) { klass.new }
13
+
14
+ let(:klass) do
15
+ Class.new(AbstractMapper::Branch) do
16
+ def transproc
17
+ -> v { "called: #{v}" }
18
+ end
19
+ end
20
+ end
21
+
15
22
  describe ".new" do
16
23
 
17
24
  subject { mapper }
@@ -23,6 +30,7 @@ describe AbstractMapper do
23
30
 
24
31
  subject { mapper.tree }
25
32
  it { is_expected.to eql tree }
33
+ it { is_expected.to be_frozen }
26
34
 
27
35
  end # describe #tree
28
36
 
metadata CHANGED
@@ -1,49 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-04 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ice_nine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.11'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: transproc
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0.2'
20
- - - ">"
33
+ version: '0.3'
34
+ - - ">="
21
35
  - !ruby/object:Gem::Version
22
- version: 0.2.3
36
+ version: 0.3.1
23
37
  type: :runtime
24
38
  prerelease: false
25
39
  version_requirements: !ruby/object:Gem::Requirement
26
40
  requirements:
27
41
  - - "~>"
28
42
  - !ruby/object:Gem::Version
29
- version: '0.2'
30
- - - ">"
43
+ version: '0.3'
44
+ - - ">="
31
45
  - !ruby/object:Gem::Version
32
- version: 0.2.3
46
+ version: 0.3.1
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: hexx-rspec
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: '0.4'
53
+ version: '0.5'
40
54
  type: :development
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: '0.4'
60
+ version: '0.5'
47
61
  description: The abstract syntax tree for ruby mappers
48
62
  email: andrew.kozin@gmail.com
49
63
  executables: []
@@ -78,8 +92,10 @@ files:
78
92
  - config/metrics/simplecov.yml
79
93
  - config/metrics/yardstick.yml
80
94
  - lib/abstract_mapper.rb
95
+ - lib/abstract_mapper/attributes.rb
81
96
  - lib/abstract_mapper/branch.rb
82
97
  - lib/abstract_mapper/builder.rb
98
+ - lib/abstract_mapper/command.rb
83
99
  - lib/abstract_mapper/commands.rb
84
100
  - lib/abstract_mapper/dsl.rb
85
101
  - lib/abstract_mapper/errors/unknown_command.rb
@@ -95,8 +111,7 @@ files:
95
111
  - lib/abstract_mapper/settings.rb
96
112
  - lib/abstract_mapper/sole_rule.rb
97
113
  - lib/abstract_mapper/version.rb
98
- - lib/rspec/functions.rb
99
- - lib/rspec/mapper.rb
114
+ - lib/rspec/doubles.rb
100
115
  - lib/rspec/nodes.rb
101
116
  - lib/rspec/rules.rb
102
117
  - spec/integration/faceter.rb
@@ -105,6 +120,7 @@ files:
105
120
  - spec/spec_helper.rb
106
121
  - spec/unit/abstract_mapper/branch_spec.rb
107
122
  - spec/unit/abstract_mapper/builder_spec.rb
123
+ - spec/unit/abstract_mapper/command_spec.rb
108
124
  - spec/unit/abstract_mapper/commands_spec.rb
109
125
  - spec/unit/abstract_mapper/dsl_spec.rb
110
126
  - spec/unit/abstract_mapper/errors/unknown_command_spec.rb
@@ -112,6 +128,8 @@ files:
112
128
  - spec/unit/abstract_mapper/errors/wrong_rule_spec.rb
113
129
  - spec/unit/abstract_mapper/functions/compact_spec.rb
114
130
  - spec/unit/abstract_mapper/functions/filter_spec.rb
131
+ - spec/unit/abstract_mapper/functions/identity_spec.rb
132
+ - spec/unit/abstract_mapper/functions/restrict_spec.rb
115
133
  - spec/unit/abstract_mapper/functions/subclass_spec.rb
116
134
  - spec/unit/abstract_mapper/node_spec.rb
117
135
  - spec/unit/abstract_mapper/optimizer_spec.rb
@@ -156,7 +174,9 @@ test_files:
156
174
  - spec/unit/abstract_mapper/pair_rule_spec.rb
157
175
  - spec/unit/abstract_mapper/functions/compact_spec.rb
158
176
  - spec/unit/abstract_mapper/functions/filter_spec.rb
177
+ - spec/unit/abstract_mapper/functions/restrict_spec.rb
159
178
  - spec/unit/abstract_mapper/functions/subclass_spec.rb
179
+ - spec/unit/abstract_mapper/functions/identity_spec.rb
160
180
  - spec/unit/abstract_mapper/rules_spec.rb
161
181
  - spec/unit/abstract_mapper/builder_spec.rb
162
182
  - spec/unit/abstract_mapper/errors/wrong_node_spec.rb
@@ -167,5 +187,6 @@ test_files:
167
187
  - spec/unit/abstract_mapper/settings_spec.rb
168
188
  - spec/unit/abstract_mapper/branch_spec.rb
169
189
  - spec/unit/abstract_mapper/optimizer_spec.rb
190
+ - spec/unit/abstract_mapper/command_spec.rb
170
191
  - spec/unit/abstract_mapper_spec.rb
171
192
  has_rdoc:
@@ -1,25 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # ==============================================================================
4
- # Examples for testing transproc functions
5
- # ==============================================================================
6
-
7
- shared_examples :transforming_immutable_data do
8
-
9
- let(:fn) { described_class[*arguments] }
10
-
11
- subject { fn[input.dup.freeze] }
12
-
13
- it do
14
- is_expected.to eql(output), <<-REPORT.gsub(/.+\|/, "")
15
- |
16
- |fn = #{described_class}[{arguments}]
17
- |
18
- |fn#{Array[*input]}
19
- |
20
- | expected: #{output}
21
- | got: #{subject}
22
- REPORT
23
- end
24
-
25
- end # shared examples
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # ==============================================================================
4
- # Examples for testing DSL registry
5
- # ==============================================================================
6
-
7
- shared_examples :defining_rule do
8
-
9
- subject { described_class.settings.rules.registry }
10
- it do
11
- is_expected.to include(rule), <<-REPORT.gsub(/.+\|/, "")
12
- |
13
- |#{described_class} optimization rules
14
- |
15
- |expected to include #{rule.inspect}
16
- | got rules:
17
- |#{subject.map { |rule| "#{" " * 9}- #{rule.inspect}" }.join("\n")}
18
- REPORT
19
- end
20
-
21
- end # shared examples
22
-
23
- shared_examples :defining_command do
24
-
25
- subject { described_class.settings.commands.registry }
26
- it "registers the command" do
27
- expect(subject[name]).to eql(node), <<-REPORT.gsub(/.+\|/, "")
28
- |
29
- |#{described_class} DSL commands
30
- |
31
- |expected to include '#{name}' adding #{node.inspect}
32
- | got commands:
33
- |#{subject
34
- .map { |name, node| "#{" " * 9}- #{name}: #{node.inspect}" }
35
- .sort
36
- .join("\n")}
37
- REPORT
38
- end
39
-
40
- end # shared examples