class Scron::History

Overview

Keeps track of the last time a command ran. When a command runs, update the timestamp with Scron::History#touch. The entire history database can be written to a string with Scron::History#to_s.

Defined in:

scron/history.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(text : String, now : Time) #

Instantiates a new history. Example history format looks like:

2020-01-01.06:00 /path/to/command1
2020-02-05.22:15 /path/to/command2 arg1 arg2

Example usage:

Scron::History.new("2020-01-01.06:00 /path/to/command1")

[View source]

Instance Method Detail

def [](command) #

Returns Time for the last time this command ran. Raises error if it never ran.


[View source]
def has?(command) #

Returns true if this command ever ran at least once.


[View source]
def to_s(io) #

Returns history database as string via string builder pattern to save memory.


[View source]
def to_s #

Returns history database as string, meant to be saved to ~/.scrondb file.


[View source]
def touch(command) #

Sets timestamp to current time. This method should be called whenever the command runs.


[View source]