Class: Hell::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/hell/app.rb

Instance Method Summary collapse

Instance Method Details

#capObject



154
155
156
157
158
159
# File 'lib/hell/app.rb', line 154

def cap
  FileUtils.chdir HELL_APP_ROOT do
    @cap ||= Capistrano::CLI.parse(["-T"])
  end
  return @cap
end

#send_error(task_id, message) ⇒ Object



161
162
163
164
165
166
167
168
# File 'lib/hell/app.rb', line 161

def send_error(task_id, message)
  stream do |out|
    out << "event: start\ndata:\n\n" unless out.closed?
    out << "data: " + ws_message("<p>#{message}</p>")  + "\n\n" unless out.closed?
    out << "event: end\ndata:\n\n" unless out.closed?
    out.close
  end
end

#send_success(task_id, command, opts = {}) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/hell/app.rb', line 170

def send_success(task_id, command, opts = {})
  opts = {:prepend => false}.merge(opts)
  stream do |out|
    out << "event: start\ndata:\n\n" unless out.closed?
    out << "data: " + ws_message("<p>#{command}</p>") + "\n\n" unless out.closed? or opts[:prepend] == false
    IO.popen(command, 'rb') do |io|
      io.each {|line| stream_line(task_id, line, out, io)}
    end
    close_stream(out)
  end
end