class Malevich::DSL
Constants
- PLUGIN_EXT
Attributes
plugins[R]
Public Class Methods
load(paths)
click to toggle source
# File lib/malevich/dsl.rb, line 59 def self.load(paths) dsl = Malevich::DSL.new paths.map do |path| File.directory?(path) ? Dir["#{path}/*#{PLUGIN_EXT}"].sort : path end.flatten.each do |path| begin log :debug, "Load plugin #{path}" dsl.plugins << Malevich::Plugin.new(File.basename(path, PLUGIN_EXT)) dsl.instance_eval(File.read(path), path) rescue ScriptError dsl.plugins.pop # todo: plugin.new creates log :error, "ScriptError: plugin from file #{path}" end end dsl.plugins end
new()
click to toggle source
# File lib/malevich/dsl.rb, line 8 def initialize @plugins = Array.new end
test(file)
click to toggle source
# File lib/malevich/dsl.rb, line 76 def self.test(file) dsl = Malevich::DSL.new dsl.plugins << Malevich::Plugin.new(File.basename(file, PLUGIN_EXT)) dsl.instance_eval(File.read(file), file) dsl.plugins[0] end
Public Instance Methods
always_start(val)
click to toggle source
# File lib/malevich/dsl.rb, line 16 def always_start(val) plugins.last.always_start = !!val end
Also aliased as: auto, auto_start
collect(*name, &block)
click to toggle source
# File lib/malevich/dsl.rb, line 54 def collect(*name, &block) return unless plugins.last.suitable_platform?(name) plugins.last.collect = block end
critical(val)
click to toggle source
# File lib/malevich/dsl.rb, line 34 def critical(val) plugins.last.settings[:critical] = val end
Also aliased as: critical=
interval(val)
click to toggle source
# File lib/malevich/dsl.rb, line 12 def interval(val) plugins.last.interval = val.to_f end
run_if(*name, &block)
click to toggle source
# File lib/malevich/dsl.rb, line 23 def run_if(*name, &block) return unless plugins.last.suitable_platform?(name) plugins.last.run_if = block end
settings(attr, val)
click to toggle source
# File lib/malevich/dsl.rb, line 46 def settings(attr, val) plugins.last.settings[attr] = val end
state(attr, val)
click to toggle source
# File lib/malevich/dsl.rb, line 28 def state(attr, val) plugins.last.settings[attr] = val end
Also aliased as: states
warning(val)
click to toggle source
# File lib/malevich/dsl.rb, line 40 def warning(val) plugins.last.settings[:warning] = val end
Also aliased as: warning=