Sha256: 540089b156e271aede2664aca45e15c93c07063bf904e5f4f60328972f07adf7

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

require 'rib'

module Rib; module Caller
  extend Plugin
  Shell.use(self)

  module Imp
    def caller *filters
      return if Rib::Caller.disabled?

      backtrace = Rib.shell.format_backtrace(super().drop(1))

      lib = %r{\brib-#{Rib::VERSION}/lib/rib/}
      if backtrace.first =~ lib
        backtrace.shift while backtrace.first =~ lib
      elsif backtrace.last =~ lib
        backtrace.pop while backtrace.last =~ lib
      end

      result = filters.map do |f|
        case f
        when Regexp
          f
        when String
          %r{\bgems/#{Regexp.escape(f)}\-[\d\.]+/lib/}
        end
      end.inject(backtrace, &:grep_v)

      Rib.shell.puts result.map{ |l| "  #{l}" }.join("\n")

      Rib::Skip
    end
  end

  Rib.extend(Imp)
end; end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rib-1.5.4 lib/rib/more/caller.rb
rib-1.5.3 lib/rib/more/caller.rb
rib-1.5.2 lib/rib/more/caller.rb