faceter 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/faceter.gemspec +1 -1
- data/lib/faceter/nodes/change_prefix.rb +1 -1
- data/lib/faceter/nodes/create.rb +1 -1
- data/lib/faceter/nodes/exclude.rb +1 -1
- data/lib/faceter/nodes/field.rb +1 -1
- data/lib/faceter/nodes/fold.rb +1 -1
- data/lib/faceter/nodes/group.rb +1 -1
- data/lib/faceter/nodes/list.rb +1 -1
- data/lib/faceter/nodes/rename.rb +1 -1
- data/lib/faceter/nodes/stringify_keys.rb +1 -1
- data/lib/faceter/nodes/symbolize_keys.rb +1 -1
- data/lib/faceter/nodes/unfold.rb +1 -1
- data/lib/faceter/nodes/ungroup.rb +1 -1
- data/lib/faceter/nodes/unwrap.rb +1 -1
- data/lib/faceter/nodes/wrap.rb +1 -1
- data/lib/faceter/rules/append_nested.rb +1 -1
- data/lib/faceter/rules/merge_branches.rb +2 -2
- data/lib/faceter/rules/merge_excludes.rb +1 -1
- data/lib/faceter/rules/merge_renames.rb +1 -1
- data/lib/faceter/rules/order_fields.rb +1 -1
- data/lib/faceter/rules/prepend_nested.rb +1 -1
- data/lib/faceter/version.rb +1 -1
- data/spec/integration/commands/add_prefix_spec.rb +2 -2
- data/spec/integration/commands/exclude_spec.rb +5 -5
- data/spec/integration/commands/fold_spec.rb +2 -2
- data/spec/integration/commands/group_spec.rb +5 -5
- data/spec/integration/commands/remove_prefix_spec.rb +6 -6
- data/spec/integration/commands/rename_spec.rb +2 -2
- data/spec/integration/commands/stringify_keys_spec.rb +8 -8
- data/spec/integration/commands/symbolize_keys_spec.rb +4 -4
- data/spec/integration/commands/unfold_spec.rb +2 -2
- data/spec/integration/commands/ungroup_spec.rb +5 -5
- data/spec/integration/commands/unwrap_spec.rb +4 -4
- data/spec/integration/commands/wrap_spec.rb +4 -4
- data/spec/unit/functions/add_prefix_spec.rb +1 -1
- data/spec/unit/functions/claster_spec.rb +1 -1
- data/spec/unit/functions/drop_prefix_spec.rb +3 -3
- data/spec/unit/functions/group_spec.rb +6 -6
- data/spec/unit/functions/ungroup_spec.rb +1 -1
- data/spec/unit/functions/wrap_spec.rb +6 -6
- data/spec/unit/nodes/add_prefix_spec.rb +7 -7
- data/spec/unit/nodes/create_spec.rb +6 -6
- data/spec/unit/nodes/exclude_spec.rb +1 -1
- data/spec/unit/nodes/field_spec.rb +3 -3
- data/spec/unit/nodes/fold_spec.rb +2 -2
- data/spec/unit/nodes/group_spec.rb +10 -10
- data/spec/unit/nodes/list_spec.rb +2 -2
- data/spec/unit/nodes/remove_prefix_spec.rb +7 -7
- data/spec/unit/nodes/rename_spec.rb +1 -1
- data/spec/unit/nodes/unfold_spec.rb +2 -2
- data/spec/unit/nodes/ungroup_spec.rb +1 -1
- data/spec/unit/nodes/unwrap_spec.rb +4 -4
- data/spec/unit/nodes/wrap_spec.rb +2 -2
- data/spec/unit/rules/append_nested_spec.rb +5 -5
- data/spec/unit/rules/merge_branches_spec.rb +11 -11
- data/spec/unit/rules/merge_excludes_spec.rb +2 -2
- data/spec/unit/rules/merge_renames_spec.rb +7 -7
- data/spec/unit/rules/prepend_nested_spec.rb +5 -5
- metadata +3 -3
@@ -3,11 +3,11 @@
|
|
3
3
|
describe Faceter::Nodes::List do
|
4
4
|
|
5
5
|
before do
|
6
|
-
class Faceter::Test::Foo < AbstractMapper::Node
|
6
|
+
class Faceter::Test::Foo < AbstractMapper::AST::Node
|
7
7
|
define_method(:transproc) { Faceter::Functions[:rename_keys, foo: :baz] }
|
8
8
|
end
|
9
9
|
|
10
|
-
class Faceter::Test::Bar < AbstractMapper::Node
|
10
|
+
class Faceter::Test::Bar < AbstractMapper::AST::Node
|
11
11
|
define_method(:transproc) { Faceter::Functions[:rename_keys, bar: :qux] }
|
12
12
|
end
|
13
13
|
end
|
@@ -10,7 +10,7 @@ describe Faceter::Nodes::RemovePrefix do
|
|
10
10
|
let(:attributes) { { prefix: "foo" } }
|
11
11
|
|
12
12
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
13
|
-
let(:output) { { bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ }
|
13
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
14
14
|
end
|
15
15
|
|
16
16
|
it_behaves_like :mapping_immutable_input do
|
@@ -18,7 +18,7 @@ describe Faceter::Nodes::RemovePrefix do
|
|
18
18
|
let(:attributes) { { prefix: "foo", selector: selector } }
|
19
19
|
|
20
20
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
21
|
-
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ }
|
21
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
22
22
|
end
|
23
23
|
|
24
24
|
it_behaves_like :mapping_immutable_input do
|
@@ -26,21 +26,21 @@ describe Faceter::Nodes::RemovePrefix do
|
|
26
26
|
let(:attributes) { { prefix: "foo", selector: selector } }
|
27
27
|
|
28
28
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
29
|
-
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ }
|
29
|
+
let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
|
30
30
|
end
|
31
31
|
|
32
32
|
it_behaves_like :mapping_immutable_input do
|
33
33
|
let(:attributes) { { prefix: "foo", separator: "." } }
|
34
34
|
|
35
35
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
36
|
-
let(:output) { { foo_bar: { "foo_baz" => :QUX }, "baz" => :BAZ }
|
36
|
+
let(:output) { { foo_bar: { "foo_baz" => :QUX }, "baz" => :BAZ } }
|
37
37
|
end
|
38
38
|
|
39
39
|
it_behaves_like :mapping_immutable_input do
|
40
40
|
let(:attributes) { { prefix: "foo", nested: true } }
|
41
41
|
|
42
42
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
43
|
-
let(:output) { { bar: { "baz" => :QUX }, "foo.baz" => :BAZ }
|
43
|
+
let(:output) { { bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
44
44
|
end
|
45
45
|
|
46
46
|
it_behaves_like :mapping_immutable_input do
|
@@ -48,7 +48,7 @@ describe Faceter::Nodes::RemovePrefix do
|
|
48
48
|
let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
|
49
49
|
|
50
50
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
51
|
-
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ }
|
51
|
+
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
52
52
|
end
|
53
53
|
|
54
54
|
it_behaves_like :mapping_immutable_input do
|
@@ -56,7 +56,7 @@ describe Faceter::Nodes::RemovePrefix do
|
|
56
56
|
let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
|
57
57
|
|
58
58
|
let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
|
59
|
-
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ }
|
59
|
+
let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
|
60
60
|
end
|
61
61
|
|
62
62
|
end # describe Faceter::Nodes::RemovePrefix
|
@@ -9,7 +9,7 @@ describe Faceter::Nodes::Rename do
|
|
9
9
|
it_behaves_like :mapping_immutable_input do
|
10
10
|
let(:attributes) { { keys: { foo: "bar", baz: "qux" } } }
|
11
11
|
|
12
|
-
let(:input) { { foo: :FOO, baz: :BAZ }
|
12
|
+
let(:input) { { foo: :FOO, baz: :BAZ } }
|
13
13
|
let(:output) { { "bar" => :FOO, "qux" => :BAZ } }
|
14
14
|
end
|
15
15
|
|
@@ -8,11 +8,11 @@ describe Faceter::Nodes::Unfold do
|
|
8
8
|
|
9
9
|
it_behaves_like :mapping_immutable_input do
|
10
10
|
let(:input) { { foo: :FOO } }
|
11
|
-
let(:output) { :FOO
|
11
|
+
let(:output) { :FOO }
|
12
12
|
end
|
13
13
|
|
14
14
|
it_behaves_like :mapping_immutable_input do
|
15
|
-
let(:input) { {}
|
15
|
+
let(:input) { {} }
|
16
16
|
let(:output) { nil }
|
17
17
|
end
|
18
18
|
|
@@ -13,7 +13,7 @@ describe Faceter::Nodes::Unwrap do
|
|
13
13
|
let(:options) { {} }
|
14
14
|
|
15
15
|
let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
|
16
|
-
let(:output) { { qux: :QUX, foo: :FOO, bar: :BAR, baz: :BAZ }
|
16
|
+
let(:output) { { qux: :QUX, foo: :FOO, bar: :BAR, baz: :BAZ } }
|
17
17
|
end
|
18
18
|
|
19
19
|
it_behaves_like :mapping_immutable_input do
|
@@ -27,21 +27,21 @@ describe Faceter::Nodes::Unwrap do
|
|
27
27
|
let(:options) { { only: [:foo, :baz] } }
|
28
28
|
|
29
29
|
let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
|
30
|
-
let(:output) { { qux: :QUX, foo: :FOO, baz: :BAZ }
|
30
|
+
let(:output) { { qux: :QUX, foo: :FOO, baz: :BAZ } }
|
31
31
|
end
|
32
32
|
|
33
33
|
it_behaves_like :mapping_immutable_input do
|
34
34
|
let(:options) { { only: [:foo, :baz] } }
|
35
35
|
|
36
36
|
let(:input) { { baz: { foo: :FOO, baz: { bar: :BAR } }, qux: :QUX } }
|
37
|
-
let(:output) { { qux: :QUX, foo: :FOO, baz: { bar: :BAR } }
|
37
|
+
let(:output) { { qux: :QUX, foo: :FOO, baz: { bar: :BAR } } }
|
38
38
|
end
|
39
39
|
|
40
40
|
it_behaves_like :mapping_immutable_input do
|
41
41
|
let(:options) { { only: :foo } }
|
42
42
|
|
43
43
|
let(:input) { { foo: { baz: :BAZ }, baz: { foo: { bar: :QUX } } } }
|
44
|
-
let(:output) { { foo: { bar: :QUX } }
|
44
|
+
let(:output) { { foo: { bar: :QUX } } }
|
45
45
|
end
|
46
46
|
|
47
47
|
end # describe Faceter::Nodes::Unwrap
|
@@ -12,7 +12,7 @@ describe Faceter::Nodes::Wrap do
|
|
12
12
|
it_behaves_like :mapping_immutable_input do
|
13
13
|
let(:key) { :bar }
|
14
14
|
|
15
|
-
let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ }
|
15
|
+
let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
|
16
16
|
let(:output) { { bar: { foo: :FOO, bar: :BAR }, baz: :BAZ } }
|
17
17
|
end
|
18
18
|
|
@@ -26,7 +26,7 @@ describe Faceter::Nodes::Wrap do
|
|
26
26
|
it_behaves_like :mapping_immutable_input do
|
27
27
|
let(:key) { :bar }
|
28
28
|
|
29
|
-
let(:input) { { foo: :FOO, bar: { qux: :QUX }, baz: :BAZ }
|
29
|
+
let(:input) { { foo: :FOO, bar: { qux: :QUX }, baz: :BAZ } }
|
30
30
|
let(:output) { { bar: { foo: :FOO, bar: { qux: :QUX } }, baz: :BAZ } }
|
31
31
|
end
|
32
32
|
|
@@ -4,7 +4,7 @@ module Faceter::Nodes
|
|
4
4
|
|
5
5
|
describe Faceter::Rules::AppendNested do
|
6
6
|
|
7
|
-
let(:one) { ice_double
|
7
|
+
let(:one) { ice_double }
|
8
8
|
let(:input) { [left, right] }
|
9
9
|
|
10
10
|
it_behaves_like :skipping_nodes do
|
@@ -13,24 +13,24 @@ module Faceter::Nodes
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it_behaves_like :skipping_nodes do
|
16
|
-
let(:left) { Field.new(key: :bar)
|
16
|
+
let(:left) { Field.new(key: :bar) }
|
17
17
|
let(:right) { AddPrefix.new(prefix: :foo) }
|
18
18
|
end
|
19
19
|
|
20
20
|
it_behaves_like :skipping_nodes do
|
21
|
-
let(:left) { List.new
|
21
|
+
let(:left) { List.new }
|
22
22
|
let(:right) { Exclude.new(prefix: :foo) }
|
23
23
|
end
|
24
24
|
|
25
25
|
it_behaves_like :optimizing_nodes do
|
26
|
-
let(:left) { List.new { [one] }
|
26
|
+
let(:left) { List.new { [one] } }
|
27
27
|
let(:right) { AddPrefix.new(prefix: :foo) }
|
28
28
|
|
29
29
|
let(:output) { left }
|
30
30
|
end
|
31
31
|
|
32
32
|
it_behaves_like :optimizing_nodes do
|
33
|
-
let(:left) { List.new { [one] }
|
33
|
+
let(:left) { List.new { [one] } }
|
34
34
|
let(:right) { AddPrefix.new(prefix: :foo, nested: true) }
|
35
35
|
|
36
36
|
let(:output) { List.new { [one, right] } }
|
@@ -10,37 +10,37 @@ module Faceter::Nodes # namespace for constants
|
|
10
10
|
it_behaves_like :skipping_nodes do
|
11
11
|
let(:left) { AddPrefix.new(prefix: :foo) }
|
12
12
|
let(:right) { AddPrefix.new(prefix: :foo) }
|
13
|
-
let(:input) { [left, right]
|
13
|
+
let(:input) { [left, right] }
|
14
14
|
end
|
15
15
|
|
16
16
|
it_behaves_like :skipping_nodes do
|
17
|
-
let(:left) { Field.new(key: :foo)
|
17
|
+
let(:left) { Field.new(key: :foo) }
|
18
18
|
let(:right) { AddPrefix.new(prefix: :foo) }
|
19
|
-
let(:input) { [left, right]
|
19
|
+
let(:input) { [left, right] }
|
20
20
|
end
|
21
21
|
|
22
22
|
it_behaves_like :skipping_nodes do
|
23
|
-
let(:left) { List.new
|
23
|
+
let(:left) { List.new }
|
24
24
|
let(:right) { Field.new(key: :foo) }
|
25
|
-
let(:input) { [left, right]
|
25
|
+
let(:input) { [left, right] }
|
26
26
|
end
|
27
27
|
|
28
28
|
it_behaves_like :skipping_nodes do
|
29
|
-
let(:left) { AbstractMapper::Branch.new }
|
30
|
-
let(:right) { List.new
|
31
|
-
let(:input) { [left, right]
|
29
|
+
let(:left) { AbstractMapper::AST::Branch.new }
|
30
|
+
let(:right) { List.new }
|
31
|
+
let(:input) { [left, right] }
|
32
32
|
end
|
33
33
|
|
34
34
|
it_behaves_like :skipping_nodes do
|
35
35
|
let(:left) { Field.new(key: :foo) }
|
36
36
|
let(:right) { Field.new(key: :bar) }
|
37
|
-
let(:input) { [left, right]
|
37
|
+
let(:input) { [left, right] }
|
38
38
|
end
|
39
39
|
|
40
40
|
it_behaves_like :optimizing_nodes do
|
41
41
|
let(:left) { List.new { [one] } }
|
42
42
|
let(:right) { List.new { [two] } }
|
43
|
-
let(:input) { [left, right]
|
43
|
+
let(:input) { [left, right] }
|
44
44
|
|
45
45
|
let(:output) { List.new { [one, two] } }
|
46
46
|
end
|
@@ -48,7 +48,7 @@ module Faceter::Nodes # namespace for constants
|
|
48
48
|
it_behaves_like :optimizing_nodes do
|
49
49
|
let(:left) { Field.new(key: :foo) { [one] } }
|
50
50
|
let(:right) { Field.new(key: :foo) { [two] } }
|
51
|
-
let(:input) { [left, right]
|
51
|
+
let(:input) { [left, right] }
|
52
52
|
|
53
53
|
let(:output) { Field.new(key: :foo) { [one, two] } }
|
54
54
|
end
|
@@ -10,13 +10,13 @@ module Faceter::Nodes # namespace for constants
|
|
10
10
|
let(:input) { [left, right] }
|
11
11
|
|
12
12
|
it_behaves_like :skipping_nodes do
|
13
|
-
let(:left) { Exclude.new(selector: foo)
|
13
|
+
let(:left) { Exclude.new(selector: foo) }
|
14
14
|
let(:right) { AddPrefix.new(prefix: :foo) }
|
15
15
|
end
|
16
16
|
|
17
17
|
it_behaves_like :skipping_nodes do
|
18
18
|
let(:left) { AddPrefix.new(prefix: :foo) }
|
19
|
-
let(:right) { Exclude.new(selector: foo)
|
19
|
+
let(:right) { Exclude.new(selector: foo) }
|
20
20
|
end
|
21
21
|
|
22
22
|
it_behaves_like :optimizing_nodes do
|
@@ -5,21 +5,21 @@ module Faceter::Nodes # namespace for constants
|
|
5
5
|
describe Faceter::Rules::MergeRenames do
|
6
6
|
|
7
7
|
it_behaves_like :skipping_nodes do
|
8
|
-
let(:left) { Rename.new(keys: { foo: :bar })
|
9
|
-
let(:right) { AbstractMapper::Node.new(keys: { foo: :bar }) }
|
10
|
-
let(:input) { [left, right]
|
8
|
+
let(:left) { Rename.new(keys: { foo: :bar }) }
|
9
|
+
let(:right) { AbstractMapper::AST::Node.new(keys: { foo: :bar }) }
|
10
|
+
let(:input) { [left, right] }
|
11
11
|
end
|
12
12
|
|
13
13
|
it_behaves_like :skipping_nodes do
|
14
|
-
let(:left) { AbstractMapper::Node.new(keys: { foo: :bar }) }
|
15
|
-
let(:right) { Rename.new(keys: { foo: :bar })
|
16
|
-
let(:input) { [left, right]
|
14
|
+
let(:left) { AbstractMapper::AST::Node.new(keys: { foo: :bar }) }
|
15
|
+
let(:right) { Rename.new(keys: { foo: :bar }) }
|
16
|
+
let(:input) { [left, right] }
|
17
17
|
end
|
18
18
|
|
19
19
|
it_behaves_like :optimizing_nodes do
|
20
20
|
let(:left) { Rename.new(keys: { foo: :bar }) }
|
21
21
|
let(:right) { Rename.new(keys: { baz: :qux }) }
|
22
|
-
let(:input) { [left, right]
|
22
|
+
let(:input) { [left, right] }
|
23
23
|
|
24
24
|
let(:output) { Rename.new(keys: { foo: :bar, baz: :qux }) }
|
25
25
|
end
|
@@ -4,7 +4,7 @@ module Faceter::Nodes
|
|
4
4
|
|
5
5
|
describe Faceter::Rules::PrependNested do
|
6
6
|
|
7
|
-
let(:one) { ice_double
|
7
|
+
let(:one) { ice_double }
|
8
8
|
let(:input) { [left, right] }
|
9
9
|
|
10
10
|
it_behaves_like :skipping_nodes do
|
@@ -14,24 +14,24 @@ module Faceter::Nodes
|
|
14
14
|
|
15
15
|
it_behaves_like :skipping_nodes do
|
16
16
|
let(:left) { AddPrefix.new(prefix: :foo) }
|
17
|
-
let(:right) { Field.new(key: :bar)
|
17
|
+
let(:right) { Field.new(key: :bar) }
|
18
18
|
end
|
19
19
|
|
20
20
|
it_behaves_like :skipping_nodes do
|
21
21
|
let(:left) { Exclude.new(prefix: :foo) }
|
22
|
-
let(:right) { List.new
|
22
|
+
let(:right) { List.new }
|
23
23
|
end
|
24
24
|
|
25
25
|
it_behaves_like :optimizing_nodes do
|
26
26
|
let(:left) { AddPrefix.new(prefix: :foo) }
|
27
|
-
let(:right) { List.new { [one] }
|
27
|
+
let(:right) { List.new { [one] } }
|
28
28
|
|
29
29
|
let(:output) { right }
|
30
30
|
end
|
31
31
|
|
32
32
|
it_behaves_like :optimizing_nodes do
|
33
33
|
let(:left) { AddPrefix.new(prefix: :foo, nested: true) }
|
34
|
-
let(:right) { List.new { [one] }
|
34
|
+
let(:right) { List.new { [one] } }
|
35
35
|
|
36
36
|
let(:output) { List.new { [left, one] } }
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faceter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0
|
19
|
+
version: 0.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0
|
26
|
+
version: 0.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: selector
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|