Class: DevDNSd::Configuration
- Inherits:
-
Bovem::Configuration
- Object
- Bovem::Configuration
- DevDNSd::Configuration
- Defined in:
- lib/devdnsd/configuration.rb
Overview
This class holds the configuration of the applicaton.
Instance Method Summary (collapse)
-
- (Array) add_rule(*args, &block)
Adds a rule to the configuration.
-
- (Configuration) initialize(file = nil, overrides = {}, logger = nil)
constructor
Creates a new configuration.
Constructor Details
- (Configuration) initialize(file = nil, overrides = {}, logger = nil)
Creates a new configuration. A configuration file is a plain Ruby file with a top-level config object.
Example:
config.add_rule("match.dev", "10.0.0.1")
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/devdnsd/configuration.rb', line 46 def initialize(file = nil, overrides = {}, logger = nil) super(file, overrides, logger) # Make sure some arguments are of correct type self.log_file = $stdout if self.log_file == "STDOUT" self.log_file = $stderr if self.log_file == "STDERR" self.port = self.port.to_integer self.log_level = self.log_level.to_integer # Add a default rule self.add_rule(/.+/, "127.0.0.1") if self.rules.blank? end |
Instance Method Details
- (Array) add_rule(*args, &block)
Adds a rule to the configuration.
65 66 67 68 |
# File 'lib/devdnsd/configuration.rb', line 65 def add_rule(*args, &block) @rules ||= [] @rules << DevDNSd::Rule.create(*args, &block) end |