struct Dirwatch::Setting
- Dirwatch::Setting
- Struct
- Value
- Object
Overview
This represents a specific setting for a dirwatch task.
Defined in:
dirwatch/setting.crConstant Summary
-
GLOBAL_DEFAULTS =
{"directory" => ".", "interval" => 1}
-
Global defaults that are used if they are not specified.
Constructors
-
.new(key : String, directory : String, file_match : String, interval : Float64, scripts : Array(String))
Creates a new
Dirwatch::Setting
with this specific options.
Class Method Summary
-
.from_file(filename)
Read the configuration of the given filename (YAML) and return a list of all settings.
-
.from_yaml(yaml_content)
Read the configuration of the given YAML string and return a list of all settings.
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.
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
.
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"]
>
]