class RubyYacht::Configuration

This class stores the configuration for the system.

For more information on the configuration DSL, see RubyYacht::Configuration::DSL.

Attributes

disable_docker_machine[RW]

Whether we should avoid using docker-machine even if it is installed.

If docker-machine is not installed, the value of this flag will be ignored.

hooks[RW]

The hooks to customize the build and run processes. Each entry is a RubyYacht::Hook

local_config[RW]

The configuration that has been loaded from a local YAML file.

projects[RW]

The projects that are part of this system. Each entry is a RubyYacht::Project

server_types[RW]

The app types that we can support. Each entry is a Symbol.

Public Class Methods

new() click to toggle source

This initializer creates an empty configuration.

# File lib/ruby_yacht/dsl/configuration.rb, line 12
def initialize
  self.clear
end

Public Instance Methods

clear() click to toggle source

This method erases all the configuration.

# File lib/ruby_yacht/dsl/configuration.rb, line 17
def clear
  @projects = []
  @hooks = []
  @server_types = []
  @avoid_docker_machine = false
  @local_config = {}
end
fetch_hooks(server, event_type) click to toggle source

This method pulls up the hooks that we have defined.

### Parameters

  • **server: App/Database**: The server we are fetching hooks for.

  • **event_type: Symbol**: The event that we are fetching hooks for.

### Returns

The matching hooks. This will be an Array where each item is a Hook.

# File lib/ruby_yacht/dsl/configuration.rb, line 56
def fetch_hooks(server, event_type)
  case server
  when App
    app_types = [server.server_type,:all]
    database_types = [:all]
    database = server.database
    database_types << database.server_type if database
    web_server_types = [:all] + server.project.web_servers.map(&:server_type).uniq
    container_type = :app
  when Database
    database_types = [server.server_type, :all]
    app_types = [:all]
    app_types += server.apps.map(&:server_type)
    web_server_types = [:all] + server.project.web_servers.map(&:server_type).uniq
    container_type = :database
  when WebServer
    app_types = [:all] + server.project.apps.map(&:server_type).uniq
    database_types = [:all] + server.project.databases.map(&:server_type).uniq
    web_server_types = [:all, server.server_type]
    container_type = :web
  else
    return []
  end
  self.hooks.select do |hook|
    hook.event_type == event_type &&
      app_types.include?(hook.app_server_type) &&
      database_types.include?(hook.database_server_type) &&
      web_server_types.include?(hook.web_server_type) &&
      hook.container_type == container_type
  end
end
find_server_type(name) click to toggle source

This method finds an server type by name.

### Parameters

  • **name: Symbol** The name of the server type to return.

### Returns

The RubyYacht::ServerType with that name.

# File lib/ruby_yacht/dsl/configuration.rb, line 97
def find_server_type(name)
  self.server_types.find { |type| type.name == name }
end