class Suspect::Storage::Appender

Constants

VERSION

Attributes

collector_id[R]
dir_helper[R]
dir_path[R]
writer[R]

Public Class Methods

new(opts) click to toggle source
# File lib/suspect/storage/appender.rb, line 11
def initialize(opts)
  @writer = opts[:writer] || ::Suspect::FileUtils::FlockWriter.new
  @dir_helper = opts[:dir_helper] ||fail(ArgumentError, 'No dir_helper found')
  @dir_path = opts[:dir_path] || fail(ArgumentError, 'No dir_path found')
  @collector_id = opts[:collector_id] || fail(ArgumentError, 'No collector_id found')
end

Public Instance Methods

append(run_info) click to toggle source
# File lib/suspect/storage/appender.rb, line 18
def append(run_info)
  dir_helper.mkdir dir_path.expand_path

  writer.write filename,
               serialize(run_info)
end

Private Instance Methods

filename() click to toggle source
# File lib/suspect/storage/appender.rb, line 29
def filename
  "#{dir_path.expand_path}/#{collector_id}-#{VERSION}.suspect"
end
serialize(run_info) click to toggle source
# File lib/suspect/storage/appender.rb, line 33
def serialize(run_info)
  ::JSON.generate(run_info.to_h)
end