class Dramaturg::Script
Public Class Methods
new(config = {})
click to toggle source
# File lib/dramaturg/script.rb, line 3 def initialize(config = {}) @config = Dramaturg::DEFAULT_CONFIG.deep_merge(config) @commands = [] end
Public Instance Methods
cmd(command_str, &opts)
click to toggle source
# File lib/dramaturg/script.rb, line 9 def cmd(command_str, &opts) run_all if @config[:run_previous_on_declare] c = Command.new(command_str, self) @commands << c if opts c.instance_eval &opts end c end
execute(cmd)
click to toggle source
# File lib/dramaturg/script.rb, line 27 def execute(cmd) parser.(cmd) prompter.(cmd) runner.(cmd) end
masked_value(str)
click to toggle source
# File lib/dramaturg/script.rb, line 23 def masked_value(str) Value::Masked.new(str) end
parser()
click to toggle source
# File lib/dramaturg/script.rb, line 41 def parser @config[:parser][:class] end
prompter()
click to toggle source
# File lib/dramaturg/script.rb, line 45 def prompter @prompter ||= @config[:prompter][:class].new( self, @config[:prompter] ) end
run_all()
click to toggle source
# File lib/dramaturg/script.rb, line 33 def run_all @commands.each do |cmd| unless cmd.ran? execute(cmd) end end end
runner()
click to toggle source
# File lib/dramaturg/script.rb, line 52 def runner @runner ||= @config[:runner][:class].new( self, @config[:runner] ) end