Extracts structured data from given text based on a given template.
Add this line to your application's Gemfile:
gem 'stractor'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stractor
Templates are defined by replacing the desired structured text with liquid-style tags.
***** Nagios *****
Notification Type: PROBLEM
Service: check_https_cms
Host: nginx.jsf.io
Address: nginx.jsf.io
State: CRITICAL
Date/Time: Fri Feb 28 11:34:02 UTC 2014
Additional Info:
CHECK_NRPE: Socket timeout after 10 seconds.
***** Nagios *****
Notification Type: {{ problem }}
Service: {{ service }}
Host: {{ host }}
Address: {{ address }}
State: {{ state }}
Date/Time: {{ datetime }}
Additional Info:
{{ additional_info }}
Stractor.parse(content, template)
Parses to a MatchData object, can be accessed roughly like a Hash with the following structure
{
problem: 'PROBLEM',
service: 'check_https_cms',
host: 'nginx.jsf.io',
address: 'nginx.jsf.io',
state: 'CRITICAL',
datetime: 'Fri Feb 28 11:34:02 UTC 2014',
additional_info: 'CHECK_NRPE: Socket timeout after 10 seconds.'
}
- Fork it ( http://github.com/modsognir/stractor/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request