From 2892d4fb79f9ef272e9a69a5e804428649d65a59 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 15 May 2013 13:00:08 +0100 Subject: Added store() method for use by test case. updated comments. --- lib/custodian/settings.rb | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'lib/custodian/settings.rb') diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb index 310de02..1efabf6 100644 --- a/lib/custodian/settings.rb +++ b/lib/custodian/settings.rb @@ -3,7 +3,8 @@ require 'singleton' # -# A class which encapsulates some global-settings from the custodian configuration file. +# A class which encapsulates some global-settings which are read from the +# global configuration file. # # The configuration file is optional, and we have defaults for every value. # @@ -34,14 +35,14 @@ module Custodian # # Load the configuration file; called only once. # - def _load + def _load( file = "/etc/custodian/custodian.cfg" ) + @parsed = true @settings = Hash.new() # # The global configuration file. # - file = "/etc/custodian/custodian.cfg" return unless( File.exists?( file ) ) # @@ -60,6 +61,15 @@ module Custodian end + # + # Privately set the value for a named key. + # + # Used by the test-suite. + # + def _store( key, val ) + @settings[key] = val + @parsed = true + end # @@ -80,19 +90,19 @@ module Custodian # - # The timeout period for all tests + # The timeout period for each individual test. # def timeout _load() unless( _loaded? ) - @settings['timeout'] || 30 + @settings['timeout'].to_i || 30 end # - # The number of times to re-execute a test before - # considering it is failed. + # The number of times to re-execute a failing test + # before raising an alert. # def retries _load() unless( _loaded? ) @@ -102,7 +112,13 @@ module Custodian # - # Should we sleep before repeating tests? + # When a test fails we repeat it up to five times. + # + # (The retries() method will return the number of repeats, but we default to five.) + # + # Here we configure a delay between those repeats. + # + # A delay of zero is permissable. # def retry_delay _load() unless( _loaded? ) @@ -132,7 +148,6 @@ module Custodian - # # The filename for the logfile. # -- cgit v1.2.1