Module: Clarity::GrepRenderer
- Defined in:
- lib/clarity/grep_renderer.rb
Instance Attribute Summary collapse
- #renderer ⇒ Object
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#receive_data(data) ⇒ Object
once download is complete, send it to client.
- #unbind ⇒ Object
Instance Attribute Details
#renderer ⇒ Object
6 7 8 |
# File 'lib/clarity/grep_renderer.rb', line 6 def renderer @renderer ||= LogRenderer.new end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/clarity/grep_renderer.rb', line 3 def response @response end |
Instance Method Details
#close ⇒ Object
25 26 27 |
# File 'lib/clarity/grep_renderer.rb', line 25 def close ProcessTree.kill(get_status.pid) end |
#flush ⇒ Object
21 22 23 |
# File 'lib/clarity/grep_renderer.rb', line 21 def flush response.send_chunks end |
#receive_data(data) ⇒ Object
once download is complete, send it to client
11 12 13 14 15 16 17 18 19 |
# File 'lib/clarity/grep_renderer.rb', line 11 def receive_data(data) @buffer ||= StringScanner.new("") @buffer << data while line = @buffer.scan_until(/\n/) response.chunk renderer.render(line) flush end end |
#unbind ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/clarity/grep_renderer.rb', line 29 def unbind response.chunk renderer.finalize response.chunk '' close flush puts 'Done' end |