Class: Cfer::Auster::ScriptExecutor
- Inherits:
-
Object
- Object
- Cfer::Auster::ScriptExecutor
- Defined in:
- lib/cfer/auster/script_executor.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(consts) ⇒ ScriptExecutor
constructor
A new instance of ScriptExecutor.
- #run(filename) ⇒ Object
Constructor Details
#initialize(consts) ⇒ ScriptExecutor
Returns a new instance of ScriptExecutor.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cfer/auster/script_executor.rb', line 8 def initialize(consts) raise "consts must be a Hash" unless consts.is_a?(Hash) vars = [] consts.each_pair do |k, v| key_name = k.downcase.to_sym vars << key_name define_singleton_method(key_name) { v } end define_singleton_method(:vars) { vars } end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/cfer/auster/script_executor.rb', line 6 def logger @logger end |
Instance Method Details
#run(filename) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cfer/auster/script_executor.rb', line 21 def run(filename) @logger = Logger.new(Cfer::Auster::Logging.logdev) @logger.level = Cfer::Auster::Logging.logger.level basename = File.basename(filename) standard_formatter = Logger::Formatter.new logger.formatter = proc do |severity, datetime, progname, msg| standard_formatter.call(severity, datetime, progname, "> #{basename}: #{msg}") end instance_eval IO.read(filename), filename end |