Module: Plunk
- Defined in:
- lib/plunk.rb,
lib/plunk/utils.rb,
lib/plunk/helper.rb,
lib/plunk/parser.rb,
lib/plunk/version.rb,
lib/plunk/result_set.rb,
lib/plunk/transformer.rb
Defined Under Namespace
Classes: Helper, Parser, ResultSet, Transformer, Utils
Constant Summary collapse
- VERSION =
"0.3.12"
Class Attribute Summary collapse
-
.elasticsearch_client ⇒ Object
Returns the value of attribute elasticsearch_client.
-
.elasticsearch_options ⇒ Object
Returns the value of attribute elasticsearch_options.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.max_number_of_hits ⇒ Object
Returns the value of attribute max_number_of_hits.
-
.parse_only ⇒ Object
Returns the value of attribute parse_only.
-
.parser ⇒ Object
Returns the value of attribute parser.
-
.timestamp_field ⇒ Object
Returns the value of attribute timestamp_field.
-
.transformer ⇒ Object
Returns the value of attribute transformer.
Class Method Summary collapse
- .configure(&block) ⇒ Object
- .initialize_elasticsearch ⇒ Object
- .initialize_parser ⇒ Object
- .initialize_transformer ⇒ Object
- .search(query_string) ⇒ Object
Class Attribute Details
.elasticsearch_client ⇒ Object
Returns the value of attribute elasticsearch_client.
11 12 13 |
# File 'lib/plunk.rb', line 11 def elasticsearch_client @elasticsearch_client end |
.elasticsearch_options ⇒ Object
Returns the value of attribute elasticsearch_options.
11 12 13 |
# File 'lib/plunk.rb', line 11 def @elasticsearch_options end |
.logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/plunk.rb', line 11 def logger @logger end |
.max_number_of_hits ⇒ Object
Returns the value of attribute max_number_of_hits.
11 12 13 |
# File 'lib/plunk.rb', line 11 def max_number_of_hits @max_number_of_hits end |
.parse_only ⇒ Object
Returns the value of attribute parse_only.
11 12 13 |
# File 'lib/plunk.rb', line 11 def parse_only @parse_only end |
.parser ⇒ Object
Returns the value of attribute parser.
11 12 13 |
# File 'lib/plunk.rb', line 11 def parser @parser end |
.timestamp_field ⇒ Object
Returns the value of attribute timestamp_field.
11 12 13 |
# File 'lib/plunk.rb', line 11 def @timestamp_field end |
.transformer ⇒ Object
Returns the value of attribute transformer.
11 12 13 |
# File 'lib/plunk.rb', line 11 def transformer @transformer end |
Class Method Details
.configure(&block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/plunk.rb', line 16 def self.configure(&block) class_eval(&block) self. ||= :timestamp initialize_parser initialize_transformer initialize_elasticsearch unless self.parse_only end |
.initialize_elasticsearch ⇒ Object
24 25 26 |
# File 'lib/plunk.rb', line 24 def self.initialize_elasticsearch self.elasticsearch_client ||= Elasticsearch::Client.new() end |
.initialize_parser ⇒ Object
28 29 30 |
# File 'lib/plunk.rb', line 28 def self.initialize_parser self.parser ||= Parser.new end |
.initialize_transformer ⇒ Object
32 33 34 |
# File 'lib/plunk.rb', line 32 def self.initialize_transformer self.transformer ||= Transformer.new end |
.search(query_string) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/plunk.rb', line 36 def self.search(query_string) parsed = parser.parse query_string transformed = transformer.apply parsed if self.logger self.logger.debug "Query String: #{query_string}" self.logger.debug "Parsed Output: #{transformed}" end result_set = ResultSet.new(transformed) if self.parse_only result_set.query else result_set.eval end end |