Class: Vpsb::Commands::Base

Inherits:
Object
  • Object
show all
Includes:
Executable
Defined in:
lib/vpsb/commands/base.rb

Instance Method Summary collapse

Instance Method Details

#build(*params) ⇒ Object



25
26
27
# File 'lib/vpsb/commands/base.rb', line 25

def build(*params)
  Build.new(core).execute(*params)
end

#call(name = nil, *params) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/vpsb/commands/base.rb', line 54

def call(name=nil, *params)
  puts Vpsb::Commands::HelpMessages.intro
  case name.to_s.strip
    when 'go',     'g' then go(params)
    when 'init',   'i' then init(params)
    when 'deploy', 'd' then deploy(params)
    else puts Vpsb::Commands::HelpMessages.unknown_command
  end
end

#cook(*params) ⇒ Object



29
30
31
# File 'lib/vpsb/commands/base.rb', line 29

def cook(*params)
  Cook.new(core).execute(*params)
end

#coreObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/vpsb/commands/base.rb', line 43

def core
  @core ||= (
    c = Core.new
    Vpsb::Resources.constants.each do |k|
      klass = Vpsb::Resources.const_get(k)
      c.register_resource klass.new if klass.is_a?(Class)
    end
    c
  )
end

#deploy(*params) ⇒ Object



33
34
35
# File 'lib/vpsb/commands/base.rb', line 33

def deploy(*params)
  Deploy.new(core).execute(*params)
end

#go(*params) ⇒ Object



10
11
12
13
14
15
# File 'lib/vpsb/commands/base.rb', line 10

def go(*params)
  setup(*params)
  build(*params)
  cook(*params)
  deploy(*params)
end

#help!Object Also known as: h!



37
38
39
40
# File 'lib/vpsb/commands/base.rb', line 37

def help!
  puts Vpsb::Commands::HelpMessages.show
  exit
end

#init(*params) ⇒ Object



17
18
19
# File 'lib/vpsb/commands/base.rb', line 17

def init(*params)
  Init.new.execute(*params)
end

#setup(*params) ⇒ Object



21
22
23
# File 'lib/vpsb/commands/base.rb', line 21

def setup(*params)
  Setup.new(core).execute(*params)
end