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)
-
- (Object) compiler_include_paths
readonly
See Compilable interface.
-
- (Object) compiler_library_paths
readonly
See Compilable interface.
-
- (Object) compiler_module_paths
readonly
See Compilable interface.
-
- (Object) compiler_target_files
readonly
See Compilable interface.
-
- (Object) errors
readonly
Number of compiler errors.
-
- (Object) stream
readonly
The raw stream of text returned by the compiler.
-
- (Object) warnings
readonly
Number of compiler warnings.
Instance Method Summary (collapse)
-
- (Array<String>) error_items
A list of errors.
-
- (CompilerResult) initialize(**kwargs)
constructor
A new instance of CompilerResult.
-
- (Boolean) success?
True if compile was successful.
-
- (String) target_file
The absolute path of the source code file that was compiled.
-
- (Object) to_s
Alias of #stream.
-
- (Array<String>) warning_items
A list of warnings.
Constructor Details
- (CompilerResult) initialize(**kwargs)
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
- (Object) compiler_include_paths (readonly)
See Compilable interface.
16 17 18 |
# File 'lib/netlinx/compiler_result.rb', line 16 def compiler_include_paths @compiler_include_paths end |
- (Object) compiler_library_paths (readonly)
See Compilable interface.
20 21 22 |
# File 'lib/netlinx/compiler_result.rb', line 20 def compiler_library_paths @compiler_library_paths end |
- (Object) compiler_module_paths (readonly)
See Compilable interface.
18 19 20 |
# File 'lib/netlinx/compiler_result.rb', line 18 def compiler_module_paths @compiler_module_paths end |
- (Object) compiler_target_files (readonly)
See Compilable interface.
14 15 16 |
# File 'lib/netlinx/compiler_result.rb', line 14 def compiler_target_files @compiler_target_files end |
- (Object) errors (readonly)
Number of compiler errors.
7 8 9 |
# File 'lib/netlinx/compiler_result.rb', line 7 def errors @errors end |
- (Object) stream (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 |
- (Object) warnings (readonly)
Number of compiler warnings.
9 10 11 |
# File 'lib/netlinx/compiler_result.rb', line 9 def warnings @warnings end |
Instance Method Details
- (Array<String>) error_items
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 |
- (Boolean) success?
Returns true if compile was successful.
56 57 58 |
# File 'lib/netlinx/compiler_result.rb', line 56 def success? @errors == 0 && @warnings == 0 end |
- (String) target_file
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 |
- (Object) to_s
Alias of #stream.
46 47 48 |
# File 'lib/netlinx/compiler_result.rb', line 46 def to_s @stream end |
- (Array<String>) warning_items
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 |