struct Dirwatch::Setting

Overview

This represents a specific setting for a dirwatch task.

Defined in:

dirwatch/setting.cr

Constant Summary

GLOBAL_DEFAULTS = {"directory" => ".", "interval" => 1}

Global defaults that are used if they are not specified.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(key : String, directory : String, file_match : String, interval : Float64, scripts : Array(String)) #

Creates a new Dirwatch::Setting with this specific options.


[View source]

Class Method Detail

def self.from_file(filename) #

Read the configuration of the given filename (YAML) and return a list of all settings.

See .from_yaml.


[View source]
def self.from_yaml(yaml_content) #

Read the configuration of the given YAML string and return a list of all settings.

Example of a file:

defaults:
  interval: 1

my-task-1:
  file_match: "*.txt"
  script: "echo file changed >> txt.log"

my-task-2:
  interval: 5
  directory: folder/to/csv/files
  file_match: "*.csv"
  script:
    - "echo CSV >> csv.log"
    - "echo file changed >> csv.log"

Which will return an array like:

[
  #<Dirwatch::Setting
    @key="my-task-1",
    @directory=".",
    @file_match="*.txt",
    @interval=2.0,
    @scripts=["echo file changed >> txt.log"]
  >,
  #<Dirwatch::Setting
    @key="my-task-2",
    @directory="folder/to/csv/files",
    @file_match="*.csv",
    @interval=5.0,
    @scripts=["echo CSV >> csv.log", "echo file changed >> csv.log"]
  >
]

[View source]

Instance Method Detail

def directory : String #

[View source]
def file_match : String #

[View source]
def interval : Float64 #

[View source]
def key : String #

[View source]
def scripts : Array(String) #

[View source]