Class: Spackle::Output::Base
- Inherits:
-
Object
- Object
- Spackle::Output::Base
- Defined in:
- lib/spackle/output/base.rb
Overview
This is the foundation of all Spackle::Output classes, but by itself it does nothing.
Using an Output class should be simple: (assuming errors is an Array of Spackle::Error objects) puts Spackle::Output::VimQuickfix.format(errors)
The child class (VimQuickfix) only needs to implement the format_backtrace instance method.
Spackle::Output::Base is responsible for things like:
-
iterating over the backtrace collection
-
making pathnames relative
-
limiting the number of errors that are output
-
filtering the backtrace output by filename
Spackle::Output::Base interacts with Spackle’s Configuration
If you’re writing your own Output class, it should be quite easy to override some of the Configuration handling if your class requires it.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Class Method Summary collapse
Instance Method Summary collapse
- #format ⇒ Object
- #formatted_lines ⇒ Object
-
#initialize(error = nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
25 26 27 |
# File 'lib/spackle/output/base.rb', line 25 def error @error end |
Class Method Details
.format(error = nil) ⇒ Object
40 41 42 |
# File 'lib/spackle/output/base.rb', line 40 def self.format(error = nil) new(error || Spackle.current_error).format end |
Instance Method Details
#format ⇒ Object
36 37 38 |
# File 'lib/spackle/output/base.rb', line 36 def format formatted_lines.join("\n") + "\n" end |
#formatted_lines ⇒ Object
30 31 32 33 34 |
# File 'lib/spackle/output/base.rb', line 30 def formatted_lines error.backtrace.map do |bt| format_backtrace_line error., bt.file, bt.line end end |