plunk 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/plunk/parser.rb +26 -5
- data/plunk.gemspec +1 -1
- data/spec/chained_search_spec.rb +1 -1
- data/spec/field_value_spec.rb +17 -2
- data/spec/last_spec.rb +3 -3
- 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: 74d7ec1b508c064ddcbd215df0bfb9611b08d96f
|
4
|
+
data.tar.gz: 151a4fd9a9470f02fc0eb57322874c7fbecb3627
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f16824dc828f397bc778d5cae699a5770fc7368d11c30f99da5645a6e9c406cc6beb33358e91537aee73bebd50813303a419c537280b7cbacbd93e276b5ba5
|
7
|
+
data.tar.gz: 3d66f23593c8854011275918c0d85b7f9f074cebfcd69efe25216e8ae2e88dd7f4ad708bdd4dfca5dd886e36136a646243fb954f94d340a8499ca1b429af632c
|
data/Gemfile.lock
CHANGED
data/lib/plunk/parser.rb
CHANGED
@@ -20,13 +20,34 @@ class Plunk::Parser < Parslet::Parser
|
|
20
20
|
str('-').maybe >> digit.repeat(1) >> str('.') >> digit.repeat(1) >> space?
|
21
21
|
}
|
22
22
|
rule(:number) { integer | float }
|
23
|
+
rule(:datetime) {
|
24
|
+
# 1979-05-27T07:32:00Z
|
25
|
+
digit.repeat(4) >> str("-") >>
|
26
|
+
digit.repeat(2) >> str("-") >>
|
27
|
+
digit.repeat(2) >> str("T") >>
|
28
|
+
digit.repeat(2) >> str(":") >>
|
29
|
+
digit.repeat(2) >> str(":") >>
|
30
|
+
digit.repeat(2) >> str("Z")
|
31
|
+
}
|
32
|
+
rule(:escaped_special) {
|
33
|
+
str("\\") >> match['0tnr"\\\\']
|
34
|
+
}
|
35
|
+
|
36
|
+
rule(:string_special) {
|
37
|
+
match['\0\t\n\r"\\\\']
|
38
|
+
}
|
39
|
+
rule(:string) {
|
40
|
+
str('"') >>
|
41
|
+
(escaped_special | string_special.absent? >> any).repeat >>
|
42
|
+
str('"')
|
43
|
+
}
|
23
44
|
|
24
45
|
# Field / value
|
25
|
-
rule(:identifier) { match['_@a-zA-Z.'].repeat(1) }
|
46
|
+
# rule(:identifier) { match['_@a-zA-Z.'].repeat(1) }
|
47
|
+
rule(:identifier) { match('[^=\s]').repeat(1) }
|
26
48
|
rule(:wildcard) { match('[a-zA-Z0-9.*]').repeat(1) }
|
27
49
|
rule(:searchop) { match('[=]').as(:op) }
|
28
|
-
|
29
|
-
rule(:query_value) { wildcard | integer }
|
50
|
+
rule(:query_value) { number | string | datetime | wildcard }
|
30
51
|
|
31
52
|
# boolean operators search
|
32
53
|
rule(:concatop) { (str('OR') | str('AND')) >> space? }
|
@@ -37,7 +58,8 @@ class Plunk::Parser < Parslet::Parser
|
|
37
58
|
|
38
59
|
# Grammar parts
|
39
60
|
rule(:rhs) {
|
40
|
-
regexp | subsearch |
|
61
|
+
regexp | subsearch | booleanop
|
62
|
+
# regexp | subsearch | integer | wildcard | booleanop
|
41
63
|
}
|
42
64
|
|
43
65
|
rule(:boolean_value) {
|
@@ -75,7 +97,6 @@ class Plunk::Parser < Parslet::Parser
|
|
75
97
|
}
|
76
98
|
|
77
99
|
rule(:nested_search) {
|
78
|
-
# match('[^|]').repeat.as(:initial_query) >> str('|') >> space? >>
|
79
100
|
job.as(:initial_query) >> space? >> str('|') >> space? >>
|
80
101
|
match('[^`]').repeat.as(:extractors)
|
81
102
|
}
|
data/plunk.gemspec
CHANGED
data/spec/chained_search_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'chained searches' do
|
4
|
-
|
4
|
+
pending 'should parse last 24h foo=bar baz=fez' do
|
5
5
|
result = @transformer.apply @parser.parse 'last 24h foo=bar baz=fez'
|
6
6
|
puts result
|
7
7
|
expect(result.query).to eq({query:{filtered:{query:{
|
data/spec/field_value_spec.rb
CHANGED
@@ -1,17 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'field / value searches' do
|
4
|
-
it 'should parse a
|
4
|
+
it 'should parse a _foo.@bar=baz' do
|
5
5
|
result = @transformer.apply @parser.parse('_foo.@bar=baz')
|
6
6
|
expect(result.query).to eq({query:{filtered:{query:{query_string:{
|
7
7
|
query: '_foo.@bar:baz'
|
8
8
|
}}}}})
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should parse a
|
11
|
+
it 'should parse a _foo.@bar=(baz)' do
|
12
12
|
result = @transformer.apply @parser.parse('_foo.@bar=(baz)')
|
13
13
|
expect(result.query).to eq({query:{filtered:{query:{query_string:{
|
14
14
|
query: '_foo.@bar:(baz)'
|
15
15
|
}}}}})
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'should parse _foo.@fields.@bar="bar baz"' do
|
19
|
+
result = @transformer.apply @parser.parse '_foo.@fields.@bar="bar baz"'
|
20
|
+
expect(result.query).to eq({query:{filtered:{query:{query_string:{
|
21
|
+
query: '_foo.@fields.@bar:"bar baz"'
|
22
|
+
}}}}})
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should parse _foo-barcr@5Y_+f!3*(name=bar' do
|
26
|
+
result = @transformer.apply @parser.parse '_foo-barcr@5Y_+f!3*(name=bar'
|
27
|
+
expect(result.query).to eq({query:{filtered:{query:{query_string:{
|
28
|
+
query: '_foo-barcr@5Y_+f!3*(name:bar'
|
29
|
+
}}}}})
|
30
|
+
|
31
|
+
end
|
17
32
|
end
|
data/spec/last_spec.rb
CHANGED
@@ -51,12 +51,12 @@ describe 'the last command' do
|
|
51
51
|
}}}}}}.to_s)
|
52
52
|
end
|
53
53
|
|
54
|
-
it 'should parse last 1h foo=bar' do
|
55
|
-
result = @transformer.apply @parser.parse('last 1h foo=bar')
|
54
|
+
it 'should parse last 1h @fields.foo.@field=bar' do
|
55
|
+
result = @transformer.apply @parser.parse('last 1h @fields.foo.@field=bar')
|
56
56
|
expect(result.query.to_s).to eq({query:{filtered:{
|
57
57
|
query:{
|
58
58
|
query_string: {
|
59
|
-
query: 'foo:bar'
|
59
|
+
query: '@fields.foo.field:bar'
|
60
60
|
}},
|
61
61
|
filter: {
|
62
62
|
and: [
|