Sha256: 1c5dfb890aca44ef7276819ac06e2caa24f733c75a4ccab324c786670d1f4811

Contents?: true

Size: 999 Bytes

Versions: 15

Compression:

Stored size: 999 Bytes

Contents

module Footnotes
  module Extensions
    module Exception
      def self.included(base)
        base.class_eval do
          alias_method_chain :clean_backtrace, :links
        end
      end

      def add_links_to_backtrace(lines)
        lines.collect do |line|
          expanded = line.gsub('#{RAILS_ROOT}', Rails.root)
          if match = expanded.match(/^(.+):(\d+):in/) || match = expanded.match(/^(.+):(\d+)\s*$/)
            file = File.expand_path(match[1])
            line_number = match[2]
            html = %[<a href="#{Footnotes::Filter.prefix(file, line_number, 1)}">#{line}</a>]
          else
            line
          end
        end
      end

      def clean_backtrace_with_links
        unless ::Footnotes::Filter.prefix.blank?
          add_links_to_backtrace(clean_backtrace_without_links)
        else
          clean_backtrace_without_links
        end
      end
    end
  end
end

if Rails.version < '3.0'
  Exception.send :include, Footnotes::Extensions::Exception
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rails-footnotes-3.7.2 lib/rails-footnotes/backtracer.rb
rails-footnotes-3.7.1 lib/rails-footnotes/backtracer.rb
rails-footnotes-3.7.1.pre lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.10 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.9 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.8 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.7 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.6 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.5 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.4 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.3 lib/rails-footnotes/backtracer.rb
rails-footnotes-3.7.0 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.2 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre.1 lib/rails-footnotes/backtracer.rb
rails3-footnotes-4.0.0.pre lib/rails-footnotes/backtracer.rb