Class: Pec::Command::Up

Inherits:
Base
  • Object
show all
Defined in:
lib/pec/command/up.rb

Class Method Summary collapse

Methods inherited from Base

before_do, print_exception, run

Class Method Details

.make_attribute(source, klass) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/pec/command/up.rb', line 24

def self.make_attribute(source, klass)
  source.keys.each do |k|
    Object.const_get(klass.to_s).constants.each do |c|
      object = Object.const_get("#{klass.to_s}::#{c}")
      yield k, object if  k.to_s == object.kind.to_s
    end
  end
end

.task(host_name, options, server, config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pec/command/up.rb', line 4

def self.task(host_name, options, server, config)
  unless server
    Pec::Logger.info "make start #{config.name}"

    attribute = {name: config.name}
    make_attribute(config, Pec::Handler) do |key, klass|
      attribute.deep_merge!(klass.build(config))
    end

    make_attribute(attribute, Pec::Coordinate) do |key, klass|
      attribute.deep_merge!(klass.build(config, attribute))
    end

    Yao::Server.create(attribute)
    Pec::Logger.info "create success! #{config.name}"
  else
    Pec::Logger.notice "already server: #{config.name}"
  end
end