Class: Nvoi::Configuration::Application

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

Overview

Application contains application-level configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Application

Returns a new instance of Application.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nvoi/configuration/application.rb', line 11

def initialize(data = nil)
  data ||= {}
  @name = data["name"]
  @environment = data["environment"] || "production"
  @domain_provider = Providers::DomainProvider.new(data["domain_provider"])
  @compute_provider = Providers::ComputeProvider.new(data["compute_provider"])
  @keep_count = data["keep_count"]&.to_i
  @servers = (data["servers"] || {}).transform_values { |v| Server.new(v) }
  @app = (data["app"] || {}).transform_values { |v| AppService.new(v) }
  @database = data["database"] ? Database.new(data["database"]) : nil
  @services = (data["services"] || {}).transform_values { |v| Service.new(v) }
  @env = data["env"] || {}
  @secrets = data["secrets"] || {}
  @ssh_keys = data["ssh_keys"] ? SshKey.new(data["ssh_keys"]) : nil
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def app
  @app
end

#compute_providerObject

Returns the value of attribute compute_provider.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def compute_provider
  @compute_provider
end

#databaseObject

Returns the value of attribute database.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def database
  @database
end

#domain_providerObject

Returns the value of attribute domain_provider.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def domain_provider
  @domain_provider
end

#envObject

Returns the value of attribute env.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def env
  @env
end

#environmentObject

Returns the value of attribute environment.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def environment
  @environment
end

#keep_countObject

Returns the value of attribute keep_count.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def keep_count
  @keep_count
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def name
  @name
end

#secretsObject

Returns the value of attribute secrets.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def secrets
  @secrets
end

#serversObject

Returns the value of attribute servers.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def servers
  @servers
end

#servicesObject

Returns the value of attribute services.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def services
  @services
end

#ssh_keysObject

Returns the value of attribute ssh_keys.



7
8
9
# File 'lib/nvoi/configuration/application.rb', line 7

def ssh_keys
  @ssh_keys
end

Instance Method Details

#app_by_name(name) ⇒ Object



27
28
29
# File 'lib/nvoi/configuration/application.rb', line 27

def app_by_name(name)
  @app[name.to_s]
end

#server_by_name(name) ⇒ Object



31
32
33
# File 'lib/nvoi/configuration/application.rb', line 31

def server_by_name(name)
  @servers[name.to_s]
end

#web_appsObject



35
36
37
# File 'lib/nvoi/configuration/application.rb', line 35

def web_apps
  @app.select { |_, cfg| cfg.web? }
end

#workersObject



39
40
41
# File 'lib/nvoi/configuration/application.rb', line 39

def workers
  @app.reject { |_, cfg| cfg.web? }
end