class Thing

Top Level what everything is

Public Instance Methods

archive?(archive_names) click to toggle source

Filter / Archive Pattern Matching

# File lib/greenhat/thing.rb, line 59
def archive?(archive_names)
  archive_names.map(&:to_s).any? { |x| archive.name.include? x }
end
blank?() click to toggle source

Helper for empty logs

# File lib/greenhat/thing.rb, line 64
def blank?
  data.blank?
end
data() click to toggle source

Processor

# File lib/greenhat/thing.rb, line 46
def data
  process unless parsed

  result
end
formatter() click to toggle source

Helper Formatter Method

# File lib/greenhat/thing.rb, line 97
def formatter
  "format_#{kind}".to_sym
end
friendly_name() click to toggle source
# File lib/greenhat/thing.rb, line 30
def friendly_name
  "#{archive.friendly_name.pastel(:blue)} #{name.pastel(:green)}"
end
log?() click to toggle source

Log Identifier Helper

# File lib/greenhat/thing.rb, line 87
def log?
  GreenHat::SuperLog.log? kind
end
output(print_it = true) click to toggle source
# File lib/greenhat/thing.rb, line 78
def output(print_it = true)
  if print_it
    puts raw.join("\n")
  else
    raw
  end
end
process() click to toggle source
# File lib/greenhat/thing.rb, line 101
def process
  # Read First if Needed (Spinner)
  raw_read if raw_result.nil?

  if methods.include? formatter
    spin_start("Parse #{name.pastel(:blue)} #{kind.to_s.pastel(:bright_black)} ")
    begin
      send(formatter)
    rescue StandardError => e
      LogBot.fatal('Process', message: e.message, backtrace: e.backtrace.first)
    end
    spin_done
  else
    LogBot.fatal('Thing', "No Formatter for #{formatter}")
  end

  self.parsed = true

  save!
end
processed?() click to toggle source

Hashed values searching

# File lib/greenhat/thing.rb, line 92
def processed?
  kind != :raw
end
raw() click to toggle source
# File lib/greenhat/thing.rb, line 52
def raw
  raw_read if raw_result.nil?

  raw_result
end
raw_read() click to toggle source
# File lib/greenhat/thing.rb, line 68
def raw_read
  spin_start("Read  #{name.pastel(:blue)} #{size.pastel(:bright_black)}")
  self.raw_result = File.read(file).split("\n")
rescue StandardError => e
  LogBot.fatal('Raw Read', message: e.message, backtrace: e.backtrace.first)
  self.raw_result = ''
ensure
  spin_done
end
setup() click to toggle source
# File lib/greenhat/thing.rb, line 34
def setup
  self.name = build_path('/')
  self.path = build_path.gsub(/[^\w\s]/, '_')
  self.size = number_to_human_size File.size(file)

  kind_collect # Set Kind and Type
  kind_setup

  save!
end