plunk 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aaa198f780c8d3c6f9538cd86a7ee20fbf4d44c
4
- data.tar.gz: 4cb13fb58000bf09dca9fa3001077a2b46474c41
3
+ metadata.gz: 74d7ec1b508c064ddcbd215df0bfb9611b08d96f
4
+ data.tar.gz: 151a4fd9a9470f02fc0eb57322874c7fbecb3627
5
5
  SHA512:
6
- metadata.gz: a994a69ca9c8557f07869aaff1eb468773346caa06d5676e68cdea867d0e6642cb3bd573e419f557a224beb11c6a386a7189851b2f166a3ce74884f5a8e0e802
7
- data.tar.gz: bfbd1504b80387dd2b3695a030cbb9be35110052f9b5ec8857b4415d048219e9519e71d4f6849575c67b8d878da94dff80bd3fb52b39407385d3185f4170168a
6
+ metadata.gz: d7f16824dc828f397bc778d5cae699a5770fc7368d11c30f99da5645a6e9c406cc6beb33358e91537aee73bebd50813303a419c537280b7cbacbd93e276b5ba5
7
+ data.tar.gz: 3d66f23593c8854011275918c0d85b7f9f074cebfcd69efe25216e8ae2e88dd7f4ad708bdd4dfca5dd886e36136a646243fb954f94d340a8499ca1b429af632c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plunk (0.0.8)
4
+ plunk (0.1.5)
5
5
  activesupport
6
6
  json
7
7
  parslet
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 | integer | wildcard | booleanop
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "plunk"
3
- s.version = "0.1.4"
3
+ s.version = "0.1.5"
4
4
  s.date = "2013-12-03"
5
5
  s.add_runtime_dependency "json"
6
6
  s.add_runtime_dependency "parslet"
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'chained searches' do
4
- it 'should parse last 24h foo=bar baz=fez' do
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:{
@@ -1,17 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'field / value searches' do
4
- it 'should parse a single _foo.@bar=baz' do
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 single _foo.@bar=(baz)' do
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: [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ram Mehta