Sha256: f26b257415bb4db4ec878847a452b65a9b99acb693e827b888d5fbb3faa3af8a
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require_relative 'platform' require_relative 'platforms/ruby' require_relative 'platforms/nodejs' require_relative 'platforms/phantomjs' require_relative 'platforms/go' module VagrantPlugins module Ventriloquist class PlatformsBuilder MAPPING = { 'ruby' => Platforms::Ruby, 'nodejs' => Platforms::NodeJS, 'phantomjs' => Platforms::PhantomJS, 'go' => Platforms::Go, } def initialize(platforms, mapping = MAPPING) @platforms = platforms.flatten @mapping = mapping end def self.build(platforms) new(platforms).build end 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 private def build_platforms(cfg_hash) cfg_hash.map do |name, config| create_platform_provisioner(name, config) end end def create_platform_provisioner(name, config) name, version = name.to_s.split(':') config[:version] ||= (version || 'latest') klass = @mapping.fetch(name.to_s) klass.new(name, config) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ventriloquist-0.1.0 | lib/ventriloquist/platforms_builder.rb |