Class: RubyYacht::Configuration
- Inherits:
-
Object
- Object
- RubyYacht::Configuration
- Defined in:
- lib/ruby_yacht/dsl/configuration.rb
Overview
This class stores the configuration for the system.
For more information on the configuration DSL, see RubyYacht::Configuration::DSL.
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#disable_docker_machine ⇒ Object
Whether we should avoid using docker-machine even if it is installed.
-
#hooks ⇒ Object
The hooks to customize the build and run processes.
-
#local_config ⇒ Object
The configuration that has been loaded from a local YAML file.
-
#projects ⇒ Object
The projects that are part of this system.
-
#server_types ⇒ Object
The app types that we can support.
Instance Method Summary collapse
-
#clear ⇒ Object
This method erases all the configuration.
-
#fetch_hooks(server, event_type) ⇒ Object
This method pulls up the hooks that we have defined.
-
#find_server_type(name) ⇒ Object
This method finds an server type by name.
-
#initialize ⇒ Configuration
constructor
This initializer creates an empty configuration.
Constructor Details
#initialize ⇒ Configuration
This initializer creates an empty configuration.
12 13 14 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 12 def initialize self.clear end |
Instance Attribute Details
#disable_docker_machine ⇒ Object
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.
41 42 43 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 41 def disable_docker_machine @disable_docker_machine end |
#hooks ⇒ Object
The hooks to customize the build and run processes. Each entry is a RubyYacht::Hook
31 32 33 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 31 def hooks @hooks end |
#local_config ⇒ Object
The configuration that has been loaded from a local YAML file.
44 45 46 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 44 def local_config @local_config end |
#projects ⇒ Object
The projects that are part of this system. Each entry is a RubyYacht::Project
27 28 29 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 27 def projects @projects end |
#server_types ⇒ Object
The app types that we can support. Each entry is a Symbol.
35 36 37 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 35 def server_types @server_types end |
Instance Method Details
#clear ⇒ Object
This method erases all the configuration.
17 18 19 20 21 22 23 |
# 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) ⇒ Object
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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# 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) ⇒ Object
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.
97 98 99 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 97 def find_server_type(name) self.server_types.find { |type| type.name == name } end |