Class: Cosmos::ScriptRunnerConfig
- Defined in:
- lib/cosmos/tools/script_runner/script_runner_config.rb
Overview
This class reads the Script Runner configuration file
Instance Method Summary collapse
-
#initialize(filename) ⇒ ScriptRunnerConfig
constructor
Processes the config file.
- #write_config ⇒ Object
Constructor Details
#initialize(filename) ⇒ ScriptRunnerConfig
Processes the config file
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cosmos/tools/script_runner/script_runner_config.rb', line 17 def initialize(filename) return unless filename @filename = filename parser = ConfigParser.new("http://cosmosrb.com/docs/tools/#script-runner-configuration") parser.parse_file(filename) do |keyword, params| case keyword when 'LINE_DELAY' parser.verify_num_parameters(1, 1, "#{keyword} <Delay in Seconds>") ScriptRunnerFrame.line_delay = params[0].to_f when 'PAUSE_ON_ERROR' parser.verify_num_parameters(1, 1, "#{keyword} <TRUE or FALSE>") ScriptRunnerFrame.pause_on_error = ConfigParser.handle_true_false(params[0]) when 'MONITOR_LIMITS' parser.verify_num_parameters(0, 0, keyword) ScriptRunnerFrame.monitor_limits = true when 'PAUSE_ON_RED' parser.verify_num_parameters(0, 0, keyword) ScriptRunnerFrame.monitor_limits = true ScriptRunnerFrame.pause_on_red = true else # blank config.lines will have a nil keyword and should not raise an exception raise parser.error("Unknown keyword '#{keyword}'") if keyword end end end |
Instance Method Details
#write_config ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/cosmos/tools/script_runner/script_runner_config.rb', line 43 def write_config @filename = File.join(Cosmos::USERPATH, 'config', 'tools', 'script_runner', 'script_runner.txt') unless @filename File.open(@filename, 'w') do |file| file.puts("LINE_DELAY #{ScriptRunnerFrame.line_delay}") file.puts("PAUSE_ON_ERROR #{ScriptRunnerFrame.pause_on_error ? 'TRUE' : 'FALSE'}") file.puts("MONITOR_LIMITS") if ScriptRunnerFrame.monitor_limits file.puts("PAUSE_ON_RED") if ScriptRunnerFrame.pause_on_red end end |