Class: Jstdutil::JsTestDriver::Config
- Inherits:
-
Object
- Object
- Jstdutil::JsTestDriver::Config
- Defined in:
- lib/jstdutil/jstestdriver/config.rb
Overview
Simple interface to JsTestDriver configuration Can instantiate with either a configuration file or string contents
config = Jstdutil::JsTestDriverConfig.new "jsTestDriver.conf"
config.server #=> "http://localhost:4224"
Instance Method Summary collapse
-
#initialize(file) ⇒ Config
constructor
A new instance of Config.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(name) ⇒ Boolean
Constructor Details
#initialize(file) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jstdutil/jstestdriver/config.rb', line 12 def initialize(file) begin load_config(File.read(file)) rescue load_config(file) rescue msg = "Configuration must be an existing file or valid JsTestDriver " << "configuration string (contain atleast server)" raise ArgumentError.new(msg) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
24 25 26 27 |
# File 'lib/jstdutil/jstestdriver/config.rb', line 24 def method_missing(name, *args, &block) return @contents[name.to_s] if @contents.key?(name.to_s) super end |
Instance Method Details
#respond_to?(name) ⇒ Boolean
29 30 31 32 |
# File 'lib/jstdutil/jstestdriver/config.rb', line 29 def respond_to?(name) return true if @contents.key?(name.to_s) super end |