Class: Hell::App
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Hell::App
- Defined in:
- lib/hell/app.rb
Instance Method Summary collapse
- #cap ⇒ Object
- #send_error(task_id, message) ⇒ Object
- #send_success(task_id, command, opts = {}) ⇒ Object
Instance Method Details
#cap ⇒ Object
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, ) stream do |out| out << "event: start\ndata:\n\n" unless out.closed? out << "data: " + ("<p>#{}</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: " + ("<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 |