Class: NetLinx::CompilerResult
- Inherits:
-
Object
- Object
- NetLinx::CompilerResult
- Defined in:
- lib/netlinx/compiler_result.rb
Overview
Contains info pertaining to a job run through the compiler.
Instance Attribute Summary collapse
-
#compiler_include_paths ⇒ Object
readonly
See Compilable interface.
-
#compiler_library_paths ⇒ Object
readonly
See Compilable interface.
-
#compiler_module_paths ⇒ Object
readonly
See Compilable interface.
-
#compiler_target_files ⇒ Object
readonly
See Compilable interface.
-
#errors ⇒ Object
readonly
Number of compiler errors.
-
#stream ⇒ Object
readonly
The raw stream of text returned by the compiler.
-
#warnings ⇒ Object
readonly
Number of compiler warnings.
Instance Method Summary collapse
-
#error_items ⇒ Array<String>
A list of errors.
-
#initialize(**kwargs) ⇒ CompilerResult
constructor
A new instance of CompilerResult.
-
#success? ⇒ Boolean
True if compile was successful.
-
#target_file ⇒ String
The absolute path of the source code file that was compiled.
-
#to_s ⇒ Object
Alias of #stream.
-
#warning_items ⇒ Array<String>
A list of warnings.
Constructor Details
#initialize(**kwargs) ⇒ CompilerResult
Returns a new instance of CompilerResult.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 |
Instance Attribute Details
#compiler_include_paths ⇒ Object (readonly)
See Compilable interface.
16 17 18 |
# File 'lib/netlinx/compiler_result.rb', line 16 def compiler_include_paths @compiler_include_paths end |
#compiler_library_paths ⇒ Object (readonly)
See Compilable interface.
20 21 22 |
# File 'lib/netlinx/compiler_result.rb', line 20 def compiler_library_paths @compiler_library_paths end |
#compiler_module_paths ⇒ Object (readonly)
See Compilable interface.
18 19 20 |
# File 'lib/netlinx/compiler_result.rb', line 18 def compiler_module_paths @compiler_module_paths end |
#compiler_target_files ⇒ Object (readonly)
See Compilable interface.
14 15 16 |
# File 'lib/netlinx/compiler_result.rb', line 14 def compiler_target_files @compiler_target_files end |
#errors ⇒ Object (readonly)
Number of compiler errors.
7 8 9 |
# File 'lib/netlinx/compiler_result.rb', line 7 def errors @errors end |
#stream ⇒ Object (readonly)
The raw stream of text returned by the compiler.
5 6 7 |
# File 'lib/netlinx/compiler_result.rb', line 5 def stream @stream end |
#warnings ⇒ Object (readonly)
Number of compiler warnings.
9 10 11 |
# File 'lib/netlinx/compiler_result.rb', line 9 def warnings @warnings end |
Instance Method Details
#error_items ⇒ Array<String>
Returns a list of errors.
66 67 68 |
# File 'lib/netlinx/compiler_result.rb', line 66 def error_items @stream.scan(/(^ERROR: .*$)/).map {|i| i.first} end |
#success? ⇒ Boolean
Returns true if compile was successful.
56 57 58 |
# File 'lib/netlinx/compiler_result.rb', line 56 def success? @errors == 0 && @warnings == 0 end |
#target_file ⇒ String
Returns the absolute path of the source code file that was compiled.
51 52 53 |
# File 'lib/netlinx/compiler_result.rb', line 51 def target_file @compiler_target_files.first end |
#to_s ⇒ Object
Alias of #stream.
46 47 48 |
# File 'lib/netlinx/compiler_result.rb', line 46 def to_s @stream end |
#warning_items ⇒ Array<String>
Returns a list of warnings.
61 62 63 |
# File 'lib/netlinx/compiler_result.rb', line 61 def warning_items @stream.scan(/(^WARNING: .*$)/).map {|i| i.first} end |