Sha256: fa2dc0f51eed76ef75b751a1e85bd71fe1bc3d8b94bf5ca84382dc2581e8cb56

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# Contains traces of file inclusions so that the user can track down which file
# an error occurred in.
class Backtrace
  attr_reader :overrides

  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

  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

  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

  def get_override(package_name)
    return @overrides[package_name] || (@parent ? @parent.get_override(package_name) : nil)
  end

  def dump(out)
    stack = []
    collect(stack)
    i=0
    for elem in stack
      indent=''
      i.times { indent += '  ' }
      out.puts indent+elem
      i += 1
    end
   end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
fig18-0.1.51-i386-mswin32 lib/fig/backtrace.rb
fig18-0.1.51-i386-mingw32 lib/fig/backtrace.rb
fig18-0.1.51 lib/fig/backtrace.rb
fig-0.1.51-java lib/fig/backtrace.rb
fig-0.1.51 lib/fig/backtrace.rb