lib/airake/fcsh.rb in airake-0.1.6 vs lib/airake/fcsh.rb in airake-0.1.7

- old
+ new

@@ -24,10 +24,11 @@ module PatternPark class FCSHError < StandardError; end class FCSHConnectError < FCSHError; end + class FCSHCompileError < FCSHError; end class FCSH attr_accessor :ip, :port @@ -52,25 +53,27 @@ def execute(args) start_time = Time.now error_found = false + warning_found = false begin @socket = TCPSocket.open(@ip, @port) do |s| puts ">> Opened connection to fcshd on #{@ip}:#{@port}" s.puts args s.close_write - while(line = s.gets) - break if (line.match(/^\[PROMPT\]/)) - error_found = true if (line.match(/^\[FCSH ERROR\]/)) - puts line + while line = s.gets + break if line =~ /^\[PROMPT\]/ + error_found = true if line =~ /^\[FCSH ERROR\]/ + warning_found = true if line =~ /^\[FCSH WARNING\]/ + puts line end end rescue StandardError => e raise FCSHConnectError.new("[FCSH] Unable to connect to FCSHD process") end - raise FCSHError.new("[ERROR] Compile error encountered") if error_found + raise FCSHCompileError.new("[ERROR] Compile error encountered") if error_found end_time = Time.now - start_time puts "[FCSH] Compilation complete in: #{end_time} seconds" end