msfl_visitors 1.1.0.dev4 → 1.1.0.dev5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/msfl_visitors/visitor.rb +3 -3
- data/msfl_visitors.gemspec +1 -1
- data/spec/msfl_visitors/visitors/chewy_term_filter_spec.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95d9fae385a3b9762ddba024ef96817d7d71739c
|
4
|
+
data.tar.gz: 2a8d3d903e18961b9c0bd3e5cfb412a8bbd7bec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7c6a16d6f6731ef09dce3c8efe5b87b1fc7368abb6326064636de15a2d9a5d11ef8994bcc7ed6776abcd599b17159ea5dd3f3df7d3905fa5844c4c6d9fa94a
|
7
|
+
data.tar.gz: a3f06451b7983b88d5435088bd0a02afad2b07ce6a1e6a45c0c2cabba50d08b3dec99c739ef1f1ca583c2b33bc262f2355df63ac0499d6ef6450c7a4340fa8ba
|
@@ -73,7 +73,7 @@ module MSFLVisitors
|
|
73
73
|
when Nodes::Field
|
74
74
|
node.value.to_s
|
75
75
|
when Nodes::Regex
|
76
|
-
"
|
76
|
+
%(Regexp.new( "#{Regexp.escape(node.value)}" ))
|
77
77
|
when Nodes::Word
|
78
78
|
"\"#{node.value}\""
|
79
79
|
when Nodes::Date, Nodes::Time
|
@@ -83,8 +83,8 @@ module MSFLVisitors
|
|
83
83
|
|
84
84
|
when Nodes::Match
|
85
85
|
if node.right.is_a? Nodes::Set
|
86
|
-
regex =
|
87
|
-
"#{node.left.accept(visitor)} #{BINARY_OPERATORS[node.class]} #{regex}"
|
86
|
+
regex = node.right.contents.map { |right_child| MSFLVisitors::Nodes::Regex.new(right_child.value.to_s).accept(visitor)[13..-4] }.join('|')
|
87
|
+
"#{node.left.accept(visitor)} #{BINARY_OPERATORS[node.class]} Regexp.new( \"#{regex}\" )"
|
88
88
|
else
|
89
89
|
"#{node.left.accept(visitor)} #{BINARY_OPERATORS[node.class]} #{MSFLVisitors::Nodes::Regex.new(node.right.value.to_s).accept(visitor)}"
|
90
90
|
end
|
data/msfl_visitors.gemspec
CHANGED
@@ -202,8 +202,8 @@ describe MSFLVisitors::Visitor do
|
|
202
202
|
|
203
203
|
context "when using the TermFilter visitor" do
|
204
204
|
|
205
|
-
it "results in: '
|
206
|
-
expect(result).to eq "
|
205
|
+
it "results in: 'Regexp.new( \"foobar \")'" do
|
206
|
+
expect(result).to eq %(Regexp.new( "foobar" ))
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -223,8 +223,8 @@ describe MSFLVisitors::Visitor do
|
|
223
223
|
|
224
224
|
context "when using the TermFilter visitor" do
|
225
225
|
|
226
|
-
it "results in: 'left =~
|
227
|
-
expect(result).to eq
|
226
|
+
it "results in: 'left =~ Regexp.new( \"rhs\" )'" do
|
227
|
+
expect(result).to eq %(lhs =~ Regexp.new( "rhs" ))
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -249,8 +249,8 @@ describe MSFLVisitors::Visitor do
|
|
249
249
|
|
250
250
|
context "when using the TermFilter visitor" do
|
251
251
|
|
252
|
-
it "results in: 'left =~
|
253
|
-
expect(result).to eq
|
252
|
+
it "results in: 'left =~ Regexp.new( \"foo|bar|baz\" )'" do
|
253
|
+
expect(result).to eq %(lhs =~ Regexp.new( "foo|bar|baz" ))
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
@@ -690,8 +690,8 @@ describe MSFLVisitors::Visitor do
|
|
690
690
|
|
691
691
|
let(:node) { MSFLVisitors::Nodes::Regex.new regex }
|
692
692
|
|
693
|
-
it "returns: \"
|
694
|
-
expect(result).to eq "
|
693
|
+
it "returns: 'Regexp.new( \"content\" )'" do
|
694
|
+
expect(result).to eq %(Regexp.new( "#{regex}" ))
|
695
695
|
end
|
696
696
|
|
697
697
|
context "when using the Aggregations visitor" do
|
@@ -709,8 +709,8 @@ describe MSFLVisitors::Visitor do
|
|
709
709
|
|
710
710
|
let(:node) { MSFLVisitors::Nodes::Regex.new regex }
|
711
711
|
|
712
|
-
it "returns: '
|
713
|
-
expect(result).to eq "
|
712
|
+
it "returns: 'Regexp.new( \"this\\ /\\ needs\\ to\\ %\\ \\{be,escaped\\}\\ \\*\\.\\ \\^\\[or\\]\\ \\|\\ \\\\else\" )'" do
|
713
|
+
expect(result).to eq "Regexp.new( \"this\\ /\\ needs\\ to\\ %\\ \\{be,escaped\\}\\ \\*\\.\\ \\^\\[or\\]\\ \\|\\ \\\\else\" )"
|
714
714
|
end
|
715
715
|
|
716
716
|
context "when using the Aggregations visitor" do
|