Class: LogMagic::SearchkickRefiner

Inherits:
BaseRefiner show all
Defined in:
lib/log_magic/refiners/searchkick_refiner.rb

Instance Attribute Summary

Attributes inherited from BaseRefiner

#lines

Instance Method Summary collapse

Methods inherited from BaseRefiner

#initialize, #matches?, #persistance_layer

Constructor Details

This class inherits a constructor from LogMagic::BaseRefiner

Instance Method Details

#computeObject



6
7
8
9
10
11
12
13
14
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 6

def compute
  elasticsearch_url = extract_elasticsearch_url
  persist_elasticsearch_url(elasticsearch_url)

  query_json = extract_query_json
  persist_query_json(query_json)

  output(query_json, persistance_layer.uuid)
end

#extract_elasticsearch_urlObject



25
26
27
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 25

def extract_elasticsearch_url
  @lines.last.match(/https?:\/\/[^\/]*\/[^\/]*/)[0]
end

#extract_query_jsonObject



21
22
23
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 21

def extract_query_json
  @lines.last.match(/(?<=[^\{])\{.*\}/)[0]
end

#line_match_regexObject



2
3
4
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 2

def line_match_regex
  /Search[^c]*curl/
end

#output(query_json, uuid) ⇒ Object



16
17
18
19
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 16

def output(query_json, uuid)
  searchkick_printer = ::LogMagic::SearchkickPrinter.new(query_json, uuid)
  searchkick_printer.print
end

#persist_elasticsearch_url(elasticsearch_url) ⇒ Object



33
34
35
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 33

def persist_elasticsearch_url(elasticsearch_url)
  persistance_layer.add_value('elasticsearch_url', elasticsearch_url)
end

#persist_query_json(query_json) ⇒ Object



29
30
31
# File 'lib/log_magic/refiners/searchkick_refiner.rb', line 29

def persist_query_json(query_json)
  persistance_layer.add_value('query_json', query_json)
end