Class: VagrantPlugins::Ventriloquist::PlatformsBuilder

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

Constant Summary collapse

MAPPING =
{
  'ruby'      => Platforms::Ruby,
  'nodejs'    => Platforms::NodeJS,
  'phantomjs' => Platforms::PhantomJS,
  'go'        => Platforms::Go,
  'erlang'    => Platforms::Erlang,
  'elixir'    => Platforms::Elixir,
  'python'    => Platforms::Python
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platforms, mapping = MAPPING) ⇒ PlatformsBuilder

Returns a new instance of PlatformsBuilder.



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

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

Class Method Details

.build(platforms) ⇒ Object



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

def self.build(platforms)
  new(platforms).build
end

Instance Method Details

#buildObject



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

def build
  @platforms.each_with_object([]) do |cfg, built_platforms|
    case cfg
      when Hash
        built_platforms.concat build_platforms(cfg)
      when String, Symbol
        built_platforms << create_platform_provisioner(cfg, {})
      else
        raise "Unknown cfg type: #{cfg.class}"
    end
  end
end