Class: DiffRunner::Invocation

Inherits:
Object
  • Object
show all
Defined in:
lib/diff-runner/invocation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ Invocation

Returns a new instance of Invocation.



6
7
8
# File 'lib/diff-runner/invocation.rb', line 6

def initialize(cmd)
  @cmd = cmd
end

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



4
5
6
# File 'lib/diff-runner/invocation.rb', line 4

def pid
  @pid
end

Instance Method Details

#outputObject



17
18
19
20
21
# File 'lib/diff-runner/invocation.rb', line 17

def output
  IO.popen(@cmd) do |io|
    io.read
  end
end

#present(message) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/diff-runner/invocation.rb', line 23

def present(message)
  if @pid
    Process.kill("QUIT", @pid) rescue nil
  end

  IO.popen("less", "w") do |io|
    io.puts message
    @pid = io.pid
  end
end

#runObject



10
11
12
13
14
15
# File 'lib/diff-runner/invocation.rb', line 10

def run
  Thread.new do            
    puts `clear`
    present output
  end
end