Class: Backtrace
- Inherits:
-
Object
- Object
- Backtrace
- Defined in:
- lib/fig/backtrace.rb
Overview
Contains traces of file inclusions so that the user can track down which file an error occurred in.
Instance Attribute Summary collapse
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
Instance Method Summary collapse
- #add_override(package_name, version_name) ⇒ Object
- #collect(stack) ⇒ Object
- #dump(out) ⇒ Object
- #get_override(package_name) ⇒ Object
-
#initialize(parent, package_name, version_name, config_name) ⇒ Backtrace
constructor
A new instance of Backtrace.
Constructor Details
#initialize(parent, package_name, version_name, config_name) ⇒ Backtrace
Returns a new instance of Backtrace.
6 7 8 9 10 11 12 |
# File 'lib/fig/backtrace.rb', line 6 def initialize(parent, package_name, version_name, config_name) @parent = parent @package_name = package_name @version_name = version_name @config_name = config_name || 'default' @overrides = {} end |
Instance Attribute Details
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
4 5 6 |
# File 'lib/fig/backtrace.rb', line 4 def overrides @overrides end |
Instance Method Details
#add_override(package_name, version_name) ⇒ Object
31 32 33 34 35 |
# File 'lib/fig/backtrace.rb', line 31 def add_override(package_name, version_name) # Don't replace an existing override on the stack return if get_override(package_name) @overrides[package_name] = version_name end |
#collect(stack) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fig/backtrace.rb', line 14 def collect(stack) if @parent @parent.collect(stack) end elem = '' if @package_name elem = @package_name end if @version_name elem += '/' + @version_name end if @config_name elem += ':' + @config_name end stack << elem end |
#dump(out) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fig/backtrace.rb', line 41 def dump(out) stack = [] collect(stack) i=0 for elem in stack indent='' i.times { indent += ' ' } out.puts indent+elem i += 1 end end |
#get_override(package_name) ⇒ Object
37 38 39 |
# File 'lib/fig/backtrace.rb', line 37 def get_override(package_name) return @overrides[package_name] || (@parent ? @parent.get_override(package_name) : nil) end |