config grammar: Allow spaces in [field references][like this]

Tests included.

Note about grammar compilation:
  I had to use treetop 1.4.15 (1.5.3 generates ruby code that fails to
  parse, haven't spent any time debugging)

Fixes #1513
This commit is contained in:
Jordan Sissel 2014-07-08 22:58:46 +00:00
parent 7db44419ee
commit 384dffd2d8
3 changed files with 24 additions and 4 deletions

View file

@ -3453,7 +3453,7 @@ module LogStashConfig
if r1
s2, i2 = [], index
loop do
if has_terminal?('\G[^\\], ]', true, index)
if has_terminal?('\G[^\\],]', true, index)
r3 = true
@index += 1
else

View file

@ -234,7 +234,7 @@ grammar LogStashConfig
end
rule selector_element
"[" [^\], ]+ "]"
"[" [^\],]+ "]"
<LogStash::Config::AST::SelectorElement>
end

View file

@ -1,6 +1,6 @@
require "test_utils"
module ConditionalFancines
module ConditionalFanciness
def description
return example.metadata[:example_group][:description_args][0]
end
@ -23,7 +23,7 @@ end
describe "conditionals" do
extend LogStash::RSpec
extend ConditionalFancines
extend ConditionalFanciness
describe "simple" do
config <<-CONFIG
@ -320,4 +320,24 @@ describe "conditionals" do
end
end
end
describe "field references" do
conditional "[field with space]" do
sample("field with space" => "hurray") do
insist { subject["tags"].include?("success") }
end
end
conditional "[field with space] == 'hurray'" do
sample("field with space" => "hurray") do
insist { subject["tags"].include?("success") }
end
end
conditional "[nested field][reference with][some spaces] == 'hurray'" do
sample({"nested field" => { "reference with" => { "some spaces" => "hurray" } } }) do
insist { subject["tags"].include?("success") }
end
end
end
end