Class: RubyYacht::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

This initializer creates an empty configuration.


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

def initialize
  self.clear
end

Instance Attribute Details

#hooksObject

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


28
29
30
# File 'lib/ruby_yacht/dsl/configuration.rb', line 28

def hooks
  @hooks
end

#projectsObject

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


24
25
26
# File 'lib/ruby_yacht/dsl/configuration.rb', line 24

def projects
  @projects
end

#server_typesObject

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


32
33
34
# File 'lib/ruby_yacht/dsl/configuration.rb', line 32

def server_types
  @server_types
end

Instance Method Details

#clearObject

This method erases all the configuration.


16
17
18
19
20
# File 'lib/ruby_yacht/dsl/configuration.rb', line 16

def clear
  @projects = []
  @hooks = []
  @server_types = []
end

#fetch_hooks(attributes = {}) ⇒ Object

This method pulls up the hooks that we have defined.

The hooks can be filtered by the attributes on the hook, like event_type and event_time.

Parameters

  • attributes: Hash The attributes to look for in the returned hooks.

Returns

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


47
48
49
50
51
52
53
# File 'lib/ruby_yacht/dsl/configuration.rb', line 47

def fetch_hooks(attributes={})
  self.hooks.select do |hook|
    attributes.keys.all? do |key|
      hook.send(key) == attributes[key]
    end
  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.


64
65
66
# File 'lib/ruby_yacht/dsl/configuration.rb', line 64

def find_server_type(name)
  self.server_types.find { |type| type.name == name }
end