Module: Sumologic::Interactive::FzfViewer::SearchableBuilder

Defined in:
lib/sumologic/interactive/fzf_viewer/searchable_builder.rb

Class Method Summary collapse

Class Method Details

.add_custom_fields(parts, map) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/sumologic/interactive/fzf_viewer/searchable_builder.rb', line 29

def add_custom_fields(parts, map)
  map.each do |key, value|
    next if key.start_with?('_')
    next if value.nil? || value.to_s.empty?

    parts << "#{key}:#{value}"
  end
end

.add_primary_content(parts, map) ⇒ Object



19
20
21
# File 'lib/sumologic/interactive/fzf_viewer/searchable_builder.rb', line 19

def add_primary_content(parts, map)
  parts << Formatter.sanitize(map['_raw'] || map['message'] || '')
end

.add_standard_fields(parts, map) ⇒ Object



23
24
25
26
27
# File 'lib/sumologic/interactive/fzf_viewer/searchable_builder.rb', line 23

def add_standard_fields(parts, map)
  Config::SEARCHABLE_FIELDS.each do |field|
    parts << map[field] if map[field]
  end
end

.build_searchable_content(map) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/sumologic/interactive/fzf_viewer/searchable_builder.rb', line 9

def build_searchable_content(map)
  parts = []

  add_primary_content(parts, map)
  add_standard_fields(parts, map)
  add_custom_fields(parts, map)

  parts.compact.join(' ')
end