Class: Nonnative::Configuration
- Inherits:
-
Object
- Object
- Nonnative::Configuration
- Defined in:
- lib/nonnative/configuration.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#processes ⇒ Object
Returns the value of attribute processes.
-
#servers ⇒ Object
Returns the value of attribute servers.
-
#services ⇒ Object
Returns the value of attribute services.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_file(path) ⇒ Object
- #process {|process| ... } ⇒ Object
- #process_by_name(name) ⇒ Object
- #server {|server| ... } ⇒ Object
- #service {|service| ... } ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 |
# File 'lib/nonnative/configuration.rb', line 5 def initialize @processes = [] @servers = [] @services = [] end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def log @log end |
#processes ⇒ Object
Returns the value of attribute processes.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def processes @processes end |
#servers ⇒ Object
Returns the value of attribute servers.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def servers @servers end |
#services ⇒ Object
Returns the value of attribute services.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def services @services end |
#url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/nonnative/configuration.rb', line 11 def version @version end |
Instance Method Details
#load_file(path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nonnative/configuration.rb', line 13 def load_file(path) cfg = Nonnative.configurations(path) self.version = cfg.version self.url = cfg.url self.log = cfg.log add_processes(cfg) add_servers(cfg) add_services(cfg) end |
#process {|process| ... } ⇒ Object
25 26 27 28 29 30 |
# File 'lib/nonnative/configuration.rb', line 25 def process process = Nonnative::ConfigurationProcess.new yield process processes << process end |
#process_by_name(name) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/nonnative/configuration.rb', line 46 def process_by_name(name) process = processes.find { |s| s.name == name } raise NotFoundError, "Could not find process with name '#{name}'" if process.nil? process end |
#server {|server| ... } ⇒ Object
32 33 34 35 36 37 |
# File 'lib/nonnative/configuration.rb', line 32 def server server = Nonnative::ConfigurationServer.new yield server servers << server end |
#service {|service| ... } ⇒ Object
39 40 41 42 43 44 |
# File 'lib/nonnative/configuration.rb', line 39 def service service = Nonnative::ConfigurationService.new yield service services << service end |