Method: ToasterAppService#initialize

Defined in:
lib/toaster/toaster_app_service.rb

#initialize(*args) ⇒ ToasterAppService

Returns a new instance of ToasterAppService.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/toaster/toaster_app_service.rb', line 80

def initialize(*args)
  super(*args)
  @app = Toaster::ToasterApp.new
  @methods = ["chefsolo", "clean", "download", "exec", "lxc", 
    "proto", "runchef", "runtest", "runtests", "testinit", "time"
  ]
  @methods.each do |method|
    add_handler(method) { |*args|
      exception = nil
      out = capture_stdout do
        begin
          @app.send(method, *args)
        rescue Object => ex
          exception = ex
        end
      end
      if exception
        puts "#{exception} - #{exception.backtrace.join("\n")}"
        puts "stdout: #{out}"
        puts "-----"
        raise exception
      end
      out
    }
  end
end