class Splash::Commands::CmdRecords
Public Class Methods
new(name)
click to toggle source
# File lib/splash/commands.rb, line 46 def initialize(name) @name = name @backend = get_backend :execution_trace end
Public Instance Methods
add_record(record)
click to toggle source
# File lib/splash/commands.rb, line 73 def add_record(record) data = get_all_records data.push({ DateTime.now.to_s => record }) @backend.put key: @name, value: data.to_yaml end
clear()
click to toggle source
# File lib/splash/commands.rb, line 52 def clear @backend.del({:key => @name}) if @backend.exist?({key: @name}) end
get_all_records(options={})
click to toggle source
# File lib/splash/commands.rb, line 79 def get_all_records(options={}) return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : [] end
purge(retention)
click to toggle source
# File lib/splash/commands.rb, line 56 def purge(retention) retention = {} if retention.nil? if retention.include? :hours then adjusted_datetime = DateTime.now - retention[:hours].to_f / 24 elsif retention.include? :hours then adjusted_datetime = DateTime.now - retention[:days].to_i else adjusted_datetime = DateTime.now - DEFAULT_RETENTION end data = get_all_records data.delete_if { |item| DateTime.parse(item.keys.first) <= (adjusted_datetime)} @backend.put key: @name, value: data.to_yaml end