Class: Rascut::Plugin::WriteFcshErrorOutput

Inherits:
Base
  • Object
show all
Defined in:
lib/rascut/plugin/write_fcsh_error_output.rb

Instance Method Summary collapse

Methods inherited from Base

#config, #initialize

Constructor Details

This class inherits a constructor from Rascut::Plugin::Base

Instance Method Details

#runObject



8
9
10
11
12
13
14
# File 'lib/rascut/plugin/write_fcsh_error_output.rb', line 8

def run
  file = config[:filename] || Pathname.new(ENV['HOME']).join('.rascut/error_output')
  @path = Pathname.new(file.to_s)

  @command.wrapper.hooks[:compile_error] << method(:write_error_output)
  @command.wrapper.hooks[:compile_success] << method(:write_error_none)
end

#write_error_none(str) ⇒ Object



25
26
27
# File 'lib/rascut/plugin/write_fcsh_error_output.rb', line 25

def write_error_none(str)
  @path.open('w'){|f| f.write '' }
end

#write_error_output(str) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/rascut/plugin/write_fcsh_error_output.rb', line 16

def write_error_output(str)
  str.each_line do |line|
    if line.match 'Error: '
      @path.open('w'){|f| f.puts line.chomp }
      break
    end
  end
end