Module: RakeBubbler::RakeBubbler

Extended by:
RakeBubbler
Included in:
RakeBubbler
Defined in:
lib/rake_bubbler/rake_bubbler.rb

Instance Method Summary collapse

Instance Method Details

#capture_outputObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rake_bubbler/rake_bubbler.rb', line 19

def capture_output
  file = Tempfile.new(Digest::MD5.hexdigest((Time.now.to_i + rand(2**16)).to_s))
  
  read, write = IO.pipe
  
  save_stdout = $stdout.dup
  $stdout.reopen(write)
  
  if fork
    read.close
    yield
    write.close
    $stdout.reopen(save_stdout)
    save_stdout.close
    Process.wait
    file.unlink
    file.read
  else
    write.close
    $stdout.close
    Shell.new.tee(file.path) < read > save_stdout
    read.close
    save_stdout.close
    exit!
  end  # fork
end

#capture_task?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rake_bubbler/rake_bubbler.rb', line 15

def capture_task?(name)
  @config.tasks_include?(name) && @config.call_conditions
end

#config {|@config| ... } ⇒ Object

Yields:



7
8
9
# File 'lib/rake_bubbler/rake_bubbler.rb', line 7

def config
  yield @config
end

#executed(name, duration, output, started, error) ⇒ Object



11
12
13
# File 'lib/rake_bubbler/rake_bubbler.rb', line 11

def executed(name, duration, output, started, error)
  @config.call_executed(name, duration, output, started, error) 
end