module Comandante::Helper::YamlTo(T)
A from_yaml wrapper that exits/raises on failure
Example
x = YamlTo(Array(Int32)).load("[1,2,3]", ":config")
Class methods
module Comandante::Helper
Some helper functions
Constants
EMPTY_STRING_ARRAY = Array(String).new
Class methods
.assert(cond, msg) : Nil
Asserts a condition, depending on Cleaner
will either exit with
message or raise an error
Example:
assert(value > 0, "Expecting a value > 0")
.debug_inspect(val, context = "")
Prints a colorized inspect of val if Cleaner
is in debug mode
Example:
debug_inspect(@opts, context: "@opts")
debug_inspect({test: x == y})
debug_inspect(["one", "two"])
.parse_yaml(str, context = "") : YAML::Any
Parses yaml string and fails with message, context is used in error messages
.read_gzip(path, &) : Nil
Reads gziped file line by line
read_gzip(path) { |line| puts line }
.run(cmd, args = EMPTY_STRING_ARRAY, msg = "cmd failed") : Nil
Runs a command using system and raises if command fails
.timer
Timer for a block of commands, prints time at the end Examples
timer { do_something }