Class: Nonnative::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/nonnative/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#logObject

Returns the value of attribute log.



11
12
13
# File 'lib/nonnative/configuration.rb', line 11

def log
  @log
end

#processesObject

Returns the value of attribute processes.



11
12
13
# File 'lib/nonnative/configuration.rb', line 11

def processes
  @processes
end

#serversObject

Returns the value of attribute servers.



11
12
13
# File 'lib/nonnative/configuration.rb', line 11

def servers
  @servers
end

#servicesObject

Returns the value of attribute services.



11
12
13
# File 'lib/nonnative/configuration.rb', line 11

def services
  @services
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/nonnative/configuration.rb', line 11

def url
  @url
end

#versionObject

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

Yields:



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

Raises:



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

Yields:



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

Yields:



39
40
41
42
43
44
# File 'lib/nonnative/configuration.rb', line 39

def service
  service = Nonnative::ConfigurationService.new
  yield service

  services << service
end