-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add regexp matching support to EventFormattingAgent. #214
Conversation
A new setting key `matchers` is added to define regular expression matching against contents of events and expand the match data for use in `instructions` setting.
def validate_options | ||
errors.add(:base, "instructions, mode, skip_agent, and skip_created_at all need to be present.") unless options['instructions'].present? and options['mode'].present? and options['skip_agent'].present? and options['skip_created_at'].present? | ||
|
||
case matchers = options['matchers'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is long, I'd suggest extracting it into a secondary private method, perhaps called validate_matchers
, and calling it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be nice if empty string ('') was treated like nil, since users often clear values out to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the method originally had just one line, so I just didn't bother making a separate method.
This is a really useful addition, thank you @knu! |
Updated! |
it "should validate the contents of matchers" do | ||
@checker.options[:matchers] = [ | ||
{} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a should
statement here I think.
Looks great, thanks @knu. At the moment, I don't think |
Yeah. I'm not so familiar with JSONPath I don't even know if there is a writer API, but I'd like to support that if possible. |
Add regexp matching support to EventFormattingAgent.
Great addition @knu, thanks! |
Add regexp matching support to EventFormattingAgent.
A new setting key
matchers
is added to define regular expressionmatching against contents of events and expand the match data for use
in
instructions
setting.