faceter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +9 -0
- data/.metrics +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +18 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +9 -0
- data/Guardfile +10 -0
- data/LICENSE +21 -0
- data/README.md +295 -0
- data/Rakefile +37 -0
- data/benchmark/data.json +1 -0
- data/benchmark/faceter.rb +73 -0
- data/benchmark/rom.rb +85 -0
- data/benchmark/run.rb +54 -0
- data/config/metrics/STYLEGUIDE +230 -0
- data/config/metrics/cane.yml +5 -0
- data/config/metrics/churn.yml +6 -0
- data/config/metrics/flay.yml +2 -0
- data/config/metrics/metric_fu.yml +14 -0
- data/config/metrics/reek.yml +1 -0
- data/config/metrics/roodi.yml +24 -0
- data/config/metrics/rubocop.yml +75 -0
- data/config/metrics/saikuro.yml +3 -0
- data/config/metrics/simplecov.yml +6 -0
- data/config/metrics/yardstick.yml +37 -0
- data/faceter.gemspec +29 -0
- data/lib/faceter.rb +54 -0
- data/lib/faceter/coercers.rb +68 -0
- data/lib/faceter/functions.rb +30 -0
- data/lib/faceter/functions/add_prefix.rb +25 -0
- data/lib/faceter/functions/claster.rb +27 -0
- data/lib/faceter/functions/clean.rb +27 -0
- data/lib/faceter/functions/drop_prefix.rb +29 -0
- data/lib/faceter/functions/exclude.rb +27 -0
- data/lib/faceter/functions/group.rb +41 -0
- data/lib/faceter/functions/keep_symbol.rb +27 -0
- data/lib/faceter/functions/split.rb +28 -0
- data/lib/faceter/functions/ungroup.rb +31 -0
- data/lib/faceter/functions/unwrap.rb +32 -0
- data/lib/faceter/functions/wrap.rb +32 -0
- data/lib/faceter/mapper.rb +38 -0
- data/lib/faceter/nodes/add_prefix.rb +21 -0
- data/lib/faceter/nodes/change_prefix.rb +51 -0
- data/lib/faceter/nodes/create.rb +43 -0
- data/lib/faceter/nodes/exclude.rb +25 -0
- data/lib/faceter/nodes/field.rb +25 -0
- data/lib/faceter/nodes/fold.rb +25 -0
- data/lib/faceter/nodes/group.rb +26 -0
- data/lib/faceter/nodes/list.rb +25 -0
- data/lib/faceter/nodes/remove_prefix.rb +21 -0
- data/lib/faceter/nodes/rename.rb +25 -0
- data/lib/faceter/nodes/stringify_keys.rb +26 -0
- data/lib/faceter/nodes/symbolize_keys.rb +26 -0
- data/lib/faceter/nodes/unfold.rb +25 -0
- data/lib/faceter/nodes/ungroup.rb +26 -0
- data/lib/faceter/nodes/unwrap.rb +26 -0
- data/lib/faceter/nodes/wrap.rb +26 -0
- data/lib/faceter/rules/append_nested.rb +28 -0
- data/lib/faceter/rules/merge_branches.rb +41 -0
- data/lib/faceter/rules/merge_excludes.rb +29 -0
- data/lib/faceter/rules/merge_renames.rb +27 -0
- data/lib/faceter/rules/order_fields.rb +27 -0
- data/lib/faceter/rules/prepend_nested.rb +51 -0
- data/lib/faceter/version.rb +11 -0
- data/spec/integration/commands/add_prefix_spec.rb +37 -0
- data/spec/integration/commands/create_spec.rb +33 -0
- data/spec/integration/commands/exclude_spec.rb +55 -0
- data/spec/integration/commands/fold_spec.rb +41 -0
- data/spec/integration/commands/group_spec.rb +64 -0
- data/spec/integration/commands/remove_prefix_spec.rb +63 -0
- data/spec/integration/commands/rename_spec.rb +45 -0
- data/spec/integration/commands/stringify_keys_spec.rb +65 -0
- data/spec/integration/commands/symbolize_keys_spec.rb +49 -0
- data/spec/integration/commands/unfold_spec.rb +41 -0
- data/spec/integration/commands/ungroup_spec.rb +64 -0
- data/spec/integration/commands/unwrap_spec.rb +51 -0
- data/spec/integration/commands/wrap_spec.rb +51 -0
- data/spec/integration/rom_spec.rb +39 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/coercers/create_spec.rb +16 -0
- data/spec/unit/coercers/exclude_spec.rb +31 -0
- data/spec/unit/coercers/field_spec.rb +11 -0
- data/spec/unit/coercers/fold_spec.rb +11 -0
- data/spec/unit/coercers/prefix_spec.rb +38 -0
- data/spec/unit/coercers/rename_spec.rb +11 -0
- data/spec/unit/coercers/unfold_spec.rb +11 -0
- data/spec/unit/coercers/unwrap_spec.rb +35 -0
- data/spec/unit/coercers/wrap_spec.rb +35 -0
- data/spec/unit/functions/add_prefix_spec.rb +12 -0
- data/spec/unit/functions/claster_spec.rb +12 -0
- data/spec/unit/functions/clean_spec.rb +18 -0
- data/spec/unit/functions/drop_prefix_spec.rb +33 -0
- data/spec/unit/functions/exclude_spec.rb +64 -0
- data/spec/unit/functions/group_spec.rb +176 -0
- data/spec/unit/functions/keep_symbol_spec.rb +21 -0
- data/spec/unit/functions/split_spec.rb +64 -0
- data/spec/unit/functions/ungroup_spec.rb +87 -0
- data/spec/unit/functions/unwrap_spec.rb +54 -0
- data/spec/unit/functions/wrap_spec.rb +67 -0
- data/spec/unit/nodes/add_prefix_spec.rb +62 -0
- data/spec/unit/nodes/create_spec.rb +53 -0
- data/spec/unit/nodes/exclude_spec.rb +18 -0
- data/spec/unit/nodes/field_spec.rb +30 -0
- data/spec/unit/nodes/fold_spec.rb +19 -0
- data/spec/unit/nodes/group_spec.rb +163 -0
- data/spec/unit/nodes/list_spec.rb +27 -0
- data/spec/unit/nodes/remove_prefix_spec.rb +62 -0
- data/spec/unit/nodes/rename_spec.rb +16 -0
- data/spec/unit/nodes/stringify_keys_spec.rb +21 -0
- data/spec/unit/nodes/symbolize_keys_spec.rb +21 -0
- data/spec/unit/nodes/unfold_spec.rb +19 -0
- data/spec/unit/nodes/ungroup_spec.rb +92 -0
- data/spec/unit/nodes/unwrap_spec.rb +47 -0
- data/spec/unit/nodes/wrap_spec.rb +33 -0
- data/spec/unit/rules/append_nested_spec.rb +41 -0
- data/spec/unit/rules/merge_branches_spec.rb +58 -0
- data/spec/unit/rules/merge_excludes_spec.rb +31 -0
- data/spec/unit/rules/merge_renames_spec.rb +29 -0
- data/spec/unit/rules/order_fields_spec.rb +31 -0
- data/spec/unit/rules/prepend_nested_spec.rb +41 -0
- metadata +315 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::List do
|
4
|
+
|
5
|
+
before do
|
6
|
+
class Faceter::Test::Foo < AbstractMapper::Node
|
7
|
+
define_method(:transproc) { Faceter::Functions[:rename_keys, foo: :baz] }
|
8
|
+
end
|
9
|
+
|
10
|
+
class Faceter::Test::Bar < AbstractMapper::Node
|
11
|
+
define_method(:transproc) { Faceter::Functions[:rename_keys, bar: :qux] }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:foo) { Faceter::Test::Foo.new }
|
16
|
+
let(:bar) { Faceter::Test::Bar.new }
|
17
|
+
|
18
|
+
it_behaves_like :creating_immutable_branch
|
19
|
+
|
20
|
+
it_behaves_like :mapping_immutable_input do
|
21
|
+
let(:block) { proc { [foo, bar] } }
|
22
|
+
|
23
|
+
let(:input) { [{ foo: :FOO, bar: :BAR }, { foo: :BAZ, bar: :QUX }] }
|
24
|
+
let(:output) { [{ baz: :FOO, qux: :BAR }, { baz: :BAZ, qux: :QUX }] }
|
25
|
+
end
|
26
|
+
|
27
|
+
end # describe Faceter::Nodes::List
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::RemovePrefix do
|
4
|
+
|
5
|
+
it_behaves_like :creating_immutable_node do
|
6
|
+
let(:attributes) { { prefix: :foo } }
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like :mapping_immutable_input do
|
10
|
+
let(:attributes) { { prefix: "foo" } }
|
11
|
+
|
12
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
13
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like :mapping_immutable_input do
|
17
|
+
let(:selector) { Selector.new only: /foo_bar/ }
|
18
|
+
let(:attributes) { { prefix: "foo", selector: selector } }
|
19
|
+
|
20
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
21
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
22
|
+
end
|
23
|
+
|
24
|
+
it_behaves_like :mapping_immutable_input do
|
25
|
+
let(:selector) { Selector.new except: "foo_baz" }
|
26
|
+
let(:attributes) { { prefix: "foo", selector: selector } }
|
27
|
+
|
28
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
29
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
30
|
+
end
|
31
|
+
|
32
|
+
it_behaves_like :mapping_immutable_input do
|
33
|
+
let(:attributes) { { prefix: "foo", separator: "." } }
|
34
|
+
|
35
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
36
|
+
let(:output) { { foo_bar: { "foo_baz" => :QUX }, "baz" => :BAZ } }
|
37
|
+
end
|
38
|
+
|
39
|
+
it_behaves_like :mapping_immutable_input do
|
40
|
+
let(:attributes) { { prefix: "foo", nested: true } }
|
41
|
+
|
42
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
43
|
+
let(:output) { { bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
44
|
+
end
|
45
|
+
|
46
|
+
it_behaves_like :mapping_immutable_input do
|
47
|
+
let(:selector) { Selector.new(except: :foo_bar) }
|
48
|
+
let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
|
49
|
+
|
50
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
51
|
+
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
52
|
+
end
|
53
|
+
|
54
|
+
it_behaves_like :mapping_immutable_input do
|
55
|
+
let(:selector) { Selector.new(only: "foo_baz") }
|
56
|
+
let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
|
57
|
+
|
58
|
+
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
59
|
+
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
60
|
+
end
|
61
|
+
|
62
|
+
end # describe Faceter::Nodes::RemovePrefix
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::Rename do
|
4
|
+
|
5
|
+
it_behaves_like :creating_immutable_node do
|
6
|
+
let(:attributes) { { keys: {} } }
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like :mapping_immutable_input do
|
10
|
+
let(:attributes) { { keys: { foo: "bar", baz: "qux" } } }
|
11
|
+
|
12
|
+
let(:input) { { foo: :FOO, baz: :BAZ } }
|
13
|
+
let(:output) { { "bar" => :FOO, "qux" => :BAZ } }
|
14
|
+
end
|
15
|
+
|
16
|
+
end # describe Faceter::Nodes::Rename
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::StringifyKeys do
|
4
|
+
|
5
|
+
let(:input) { { foo: [{ 1 => :BAZ }] } }
|
6
|
+
|
7
|
+
it_behaves_like :creating_immutable_node do
|
8
|
+
let(:attributes) { {} }
|
9
|
+
end
|
10
|
+
|
11
|
+
it_behaves_like :mapping_immutable_input do
|
12
|
+
let(:attributes) { {} }
|
13
|
+
let(:output) { { "foo" => [{ "1" => :BAZ }] } }
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like :mapping_immutable_input do
|
17
|
+
let(:attributes) { { nested: false } }
|
18
|
+
let(:output) { { "foo" => [{ 1 => :BAZ }] } }
|
19
|
+
end
|
20
|
+
|
21
|
+
end # describe Faceter::Nodes::StringifyKeys
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::SymbolizeKeys do
|
4
|
+
|
5
|
+
let(:input) { { "foo" => [{ 1 => :BAZ }] } }
|
6
|
+
|
7
|
+
it_behaves_like :creating_immutable_node do
|
8
|
+
let(:attributes) { {} }
|
9
|
+
end
|
10
|
+
|
11
|
+
it_behaves_like :mapping_immutable_input do
|
12
|
+
let(:attributes) { {} }
|
13
|
+
let(:output) { { foo: [{ "1".to_sym => :BAZ }] } }
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like :mapping_immutable_input do
|
17
|
+
let(:attributes) { { nested: false } }
|
18
|
+
let(:output) { { foo: [{ 1 => :BAZ }] } }
|
19
|
+
end
|
20
|
+
|
21
|
+
end # describe Faceter::Nodes::SymbolizeKeys
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::Unfold do
|
4
|
+
|
5
|
+
let(:attributes) { { key: :foo } }
|
6
|
+
|
7
|
+
it_behaves_like :creating_immutable_node
|
8
|
+
|
9
|
+
it_behaves_like :mapping_immutable_input do
|
10
|
+
let(:input) { { foo: :FOO } }
|
11
|
+
let(:output) { :FOO }
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like :mapping_immutable_input do
|
15
|
+
let(:input) { {} }
|
16
|
+
let(:output) { nil }
|
17
|
+
end
|
18
|
+
|
19
|
+
end # describe Faceter::Nodes::Unfold
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::Ungroup do
|
4
|
+
|
5
|
+
let(:attributes) { { key: :baz, selector: selector } }
|
6
|
+
let(:selector) { Selector.new(options) }
|
7
|
+
|
8
|
+
it_behaves_like :creating_immutable_node do
|
9
|
+
let(:options) { {} }
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like :mapping_immutable_input do
|
13
|
+
let(:options) { {} }
|
14
|
+
|
15
|
+
let(:input) do
|
16
|
+
[{ qux: :QUX, baz: [] }]
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:output) do
|
20
|
+
[{ qux: :QUX }]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it_behaves_like :mapping_immutable_input do
|
25
|
+
let(:options) { {} }
|
26
|
+
|
27
|
+
let(:input) do
|
28
|
+
[{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:output) do
|
32
|
+
[{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it_behaves_like :mapping_immutable_input do
|
37
|
+
let(:options) { { only: [:foo, :bar] } }
|
38
|
+
|
39
|
+
let(:input) do
|
40
|
+
[{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:output) do
|
44
|
+
[{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it_behaves_like :mapping_immutable_input do
|
49
|
+
let(:options) { { only: :foo } }
|
50
|
+
|
51
|
+
let(:input) do
|
52
|
+
[{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:output) do
|
56
|
+
[
|
57
|
+
{ qux: :QUX, foo: :FOO, baz: [{ bar: :FOO }] },
|
58
|
+
{ qux: :QUX, foo: :BAR, baz: [{ bar: :BAR }] }
|
59
|
+
]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it_behaves_like :mapping_immutable_input do
|
64
|
+
let(:options) { { only: :foo } }
|
65
|
+
|
66
|
+
let(:input) do
|
67
|
+
[{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :FOO, bar: :BAR }] }]
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:output) do
|
71
|
+
[{ qux: :QUX, foo: :FOO, baz: [{ bar: :FOO }, { bar: :BAR }] }]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it_behaves_like :mapping_immutable_input do
|
76
|
+
let(:options) { { only: [:foo, :bar] } }
|
77
|
+
|
78
|
+
let(:input) do
|
79
|
+
[
|
80
|
+
{
|
81
|
+
qux: :QUX, foo: :QUX,
|
82
|
+
baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }]
|
83
|
+
}
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:output) do
|
88
|
+
[{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end # describe Faceter::Nodes::Ungroup
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::Unwrap do
|
4
|
+
|
5
|
+
let(:attributes) { { key: :baz, selector: selector } }
|
6
|
+
let(:selector) { Selector.new(options) }
|
7
|
+
|
8
|
+
it_behaves_like :creating_immutable_node do
|
9
|
+
let(:options) { {} }
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like :mapping_immutable_input do
|
13
|
+
let(:options) { {} }
|
14
|
+
|
15
|
+
let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
|
16
|
+
let(:output) { { qux: :QUX, foo: :FOO, bar: :BAR, baz: :BAZ } }
|
17
|
+
end
|
18
|
+
|
19
|
+
it_behaves_like :mapping_immutable_input do
|
20
|
+
let(:options) { { only: [:foo, :bar] } }
|
21
|
+
|
22
|
+
let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
|
23
|
+
let(:output) { { baz: { baz: :BAZ }, qux: :QUX, foo: :FOO, bar: :BAR } }
|
24
|
+
end
|
25
|
+
|
26
|
+
it_behaves_like :mapping_immutable_input do
|
27
|
+
let(:options) { { only: [:foo, :baz] } }
|
28
|
+
|
29
|
+
let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
|
30
|
+
let(:output) { { qux: :QUX, foo: :FOO, baz: :BAZ } }
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like :mapping_immutable_input do
|
34
|
+
let(:options) { { only: [:foo, :baz] } }
|
35
|
+
|
36
|
+
let(:input) { { baz: { foo: :FOO, baz: { bar: :BAR } }, qux: :QUX } }
|
37
|
+
let(:output) { { qux: :QUX, foo: :FOO, baz: { bar: :BAR } } }
|
38
|
+
end
|
39
|
+
|
40
|
+
it_behaves_like :mapping_immutable_input do
|
41
|
+
let(:options) { { only: :foo } }
|
42
|
+
|
43
|
+
let(:input) { { foo: { baz: :BAZ }, baz: { foo: { bar: :QUX } } } }
|
44
|
+
let(:output) { { foo: { bar: :QUX } } }
|
45
|
+
end
|
46
|
+
|
47
|
+
end # describe Faceter::Nodes::Unwrap
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Faceter::Nodes::Wrap do
|
4
|
+
|
5
|
+
let(:attributes) { { key: key, selector: selector } }
|
6
|
+
let(:selector) { Selector.new(only: [:foo, :bar]) }
|
7
|
+
|
8
|
+
it_behaves_like :creating_immutable_node do
|
9
|
+
let(:key) { :baz }
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like :mapping_immutable_input do
|
13
|
+
let(:key) { :bar }
|
14
|
+
|
15
|
+
let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
|
16
|
+
let(:output) { { bar: { foo: :FOO, bar: :BAR }, baz: :BAZ } }
|
17
|
+
end
|
18
|
+
|
19
|
+
it_behaves_like :mapping_immutable_input do
|
20
|
+
let(:key) { :baz }
|
21
|
+
|
22
|
+
let(:input) { { foo: :FOO, bar: :BAR, baz: { qux: :QUX } } }
|
23
|
+
let(:output) { { baz: { foo: :FOO, bar: :BAR, qux: :QUX } } }
|
24
|
+
end
|
25
|
+
|
26
|
+
it_behaves_like :mapping_immutable_input do
|
27
|
+
let(:key) { :bar }
|
28
|
+
|
29
|
+
let(:input) { { foo: :FOO, bar: { qux: :QUX }, baz: :BAZ } }
|
30
|
+
let(:output) { { bar: { foo: :FOO, bar: { qux: :QUX } }, baz: :BAZ } }
|
31
|
+
end
|
32
|
+
|
33
|
+
end # describe Faceter::Nodes::Wrap
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Faceter::Nodes
|
4
|
+
|
5
|
+
describe Faceter::Rules::AppendNested do
|
6
|
+
|
7
|
+
let(:one) { ice_double }
|
8
|
+
let(:input) { [left, right] }
|
9
|
+
|
10
|
+
it_behaves_like :skipping_nodes do
|
11
|
+
let(:left) { AddPrefix.new(prefix: :bar) }
|
12
|
+
let(:right) { AddPrefix.new(prefix: :foo) }
|
13
|
+
end
|
14
|
+
|
15
|
+
it_behaves_like :skipping_nodes do
|
16
|
+
let(:left) { Field.new(key: :bar) }
|
17
|
+
let(:right) { AddPrefix.new(prefix: :foo) }
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like :skipping_nodes do
|
21
|
+
let(:left) { List.new }
|
22
|
+
let(:right) { Exclude.new(prefix: :foo) }
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like :optimizing_nodes do
|
26
|
+
let(:left) { List.new { [one] } }
|
27
|
+
let(:right) { AddPrefix.new(prefix: :foo) }
|
28
|
+
|
29
|
+
let(:output) { left }
|
30
|
+
end
|
31
|
+
|
32
|
+
it_behaves_like :optimizing_nodes do
|
33
|
+
let(:left) { List.new { [one] } }
|
34
|
+
let(:right) { AddPrefix.new(prefix: :foo, nested: true) }
|
35
|
+
|
36
|
+
let(:output) { List.new { [one, right] } }
|
37
|
+
end
|
38
|
+
|
39
|
+
end # describe Faceter::Rules::AppendNested
|
40
|
+
|
41
|
+
end # module Faceter::Nodes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Faceter::Nodes # namespace for constants
|
4
|
+
|
5
|
+
describe Faceter::Rules::MergeBranches do
|
6
|
+
|
7
|
+
let(:one) { ice_double }
|
8
|
+
let(:two) { ice_double }
|
9
|
+
|
10
|
+
it_behaves_like :skipping_nodes do
|
11
|
+
let(:left) { AddPrefix.new(prefix: :foo) }
|
12
|
+
let(:right) { AddPrefix.new(prefix: :foo) }
|
13
|
+
let(:input) { [left, right] }
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like :skipping_nodes do
|
17
|
+
let(:left) { Field.new(key: :foo) }
|
18
|
+
let(:right) { AddPrefix.new(prefix: :foo) }
|
19
|
+
let(:input) { [left, right] }
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like :skipping_nodes do
|
23
|
+
let(:left) { List.new }
|
24
|
+
let(:right) { Field.new(key: :foo) }
|
25
|
+
let(:input) { [left, right] }
|
26
|
+
end
|
27
|
+
|
28
|
+
it_behaves_like :skipping_nodes do
|
29
|
+
let(:left) { AbstractMapper::Branch.new }
|
30
|
+
let(:right) { List.new }
|
31
|
+
let(:input) { [left, right] }
|
32
|
+
end
|
33
|
+
|
34
|
+
it_behaves_like :skipping_nodes do
|
35
|
+
let(:left) { Field.new(key: :foo) }
|
36
|
+
let(:right) { Field.new(key: :bar) }
|
37
|
+
let(:input) { [left, right] }
|
38
|
+
end
|
39
|
+
|
40
|
+
it_behaves_like :optimizing_nodes do
|
41
|
+
let(:left) { List.new { [one] } }
|
42
|
+
let(:right) { List.new { [two] } }
|
43
|
+
let(:input) { [left, right] }
|
44
|
+
|
45
|
+
let(:output) { List.new { [one, two] } }
|
46
|
+
end
|
47
|
+
|
48
|
+
it_behaves_like :optimizing_nodes do
|
49
|
+
let(:left) { Field.new(key: :foo) { [one] } }
|
50
|
+
let(:right) { Field.new(key: :foo) { [two] } }
|
51
|
+
let(:input) { [left, right] }
|
52
|
+
|
53
|
+
let(:output) { Field.new(key: :foo) { [one, two] } }
|
54
|
+
end
|
55
|
+
|
56
|
+
end # describe Faceter::Rules::MergeBranches
|
57
|
+
|
58
|
+
end # module Faceter
|