Class: VagrantPlugins::Ventriloquist::ServicesBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ventriloquist/services_builder.rb

Constant Summary collapse

MAPPING =
{
  'postgres'      => Services::PostgreSQL,
  'elasticsearch' => Services::ElasticSearch,
  'mailcatcher'   => Services::MailCatcher,
  'mysql'         => Services::MySql,
  'redis'         => Services::Redis,
  'memcached'     => Services::Memcached,
  'rethinkdb'     => Services::RethinkDB,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(services, mapping = MAPPING) ⇒ ServicesBuilder

Returns a new instance of ServicesBuilder.



23
24
25
26
# File 'lib/ventriloquist/services_builder.rb', line 23

def initialize(services, mapping = MAPPING)
  @services = services.flatten
  @mapping  = mapping
end

Class Method Details

.build(services, docker_client) ⇒ Object



28
29
30
# File 'lib/ventriloquist/services_builder.rb', line 28

def self.build(services, docker_client)
  new(services).build(docker_client)
end

Instance Method Details

#build(docker_client) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ventriloquist/services_builder.rb', line 32

def build(docker_client)
  @services.each_with_object([]) do |cfg, built_services|
    case cfg
      when Hash
        built_services.concat build_services(cfg, docker_client)
      when String, Symbol
        built_services << create_service_provisioner(cfg, {}, docker_client)
      else
        raise "Unknown cfg type: #{cfg.class}"
    end
  end
end