class NetLinx::CompilerResult

Contains info pertaining to a job run through the compiler.

Attributes

compiler_include_paths[R]

See Compilable interface.

compiler_library_paths[R]

See Compilable interface.

compiler_module_paths[R]

See Compilable interface.

compiler_target_files[R]

See Compilable interface.

errors[R]

Number of compiler errors.

stream[R]

The raw stream of text returned by the compiler.

warnings[R]

Number of compiler warnings.

Public Class Methods

new(**kwargs) click to toggle source

@option kwargs [String] :stream The raw stream of text returned by the compiler. @option kwargs [Array<String>] :compiler_target_files See Compilable interface. @option kwargs [Array<String>] :compiler_include_paths See Compilable interface. @option kwargs [Array<String>] :compiler_module_paths See Compilable interface. @option kwargs [Array<String>] :compiler_library_paths See Compilable interface.

# File lib/netlinx/compiler_result.rb, line 27
def initialize(**kwargs)
  @stream   = kwargs.fetch :stream, ''
  
  @compiler_target_files  = kwargs.fetch :compiler_target_files,  []
  @compiler_include_paths = kwargs.fetch :compiler_include_paths, []
  @compiler_module_paths  = kwargs.fetch :compiler_module_paths,  []
  @compiler_library_paths = kwargs.fetch :compiler_library_paths, []      
  
  # Capture error and warning counts.
  @errors = nil
  @warnings = nil
  
  @stream.scan /(\d+) error\(s\), (\d+) warning\(s\)/ do |e, w|
    @errors   = e.to_i if e
    @warnings = w.to_i if w
  end
end

Public Instance Methods

error_items() click to toggle source

@return [Array<String>] a list of errors.

# File lib/netlinx/compiler_result.rb, line 66
def error_items
  @stream.scan(/(^ERROR: .*$)/).map {|i| i.first}
end
success?() click to toggle source

@return [Boolean] true if compile was successful.

# File lib/netlinx/compiler_result.rb, line 56
def success?
  @errors == 0 && @warnings == 0
end
target_file() click to toggle source

@return [String] the absolute path of the source code file that was compiled.

# File lib/netlinx/compiler_result.rb, line 51
def target_file
  @compiler_target_files.first
end
to_s() click to toggle source

Alias of {#stream}.

# File lib/netlinx/compiler_result.rb, line 46
def to_s
  @stream
end
warning_items() click to toggle source

@return [Array<String>] a list of warnings.

# File lib/netlinx/compiler_result.rb, line 61
def warning_items
  @stream.scan(/(^WARNING: .*$)/).map {|i| i.first}
end