Sha256: bf603a1267725c4992b0bc3edae619db802ae9ac52bd59ede5ff2576361b05e6

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

require 'ro_helpers'
Out.say_status("set", " $root and $lib #{::File.basename __FILE__}, #{__LINE__}")

require 'active_support/core_ext'

module LinkableErrorsHandler
  class << self
    def link_to_code(text)
      text.scan(regexp).each do |part|
        path = part[0]
        line = part[1]
        text.gsub! "#{path}:#{line}", handle_part(path, line)
      end
      text
    end

    def regexp
      @regexp ||= %r{((?<path>/.*?\.rb)\:(?<line>\d+)\:in)}
    end

    def handle_part(path, line)
      href = File.join("/rodebug/start", path, line)
      anchor_text = "#{path}:#{line}"
      result = "<a href='http://localhost:3000#{href}'>#{anchor_text}</a>"
    end

    def handle_path(path)
      path.gsub(%r{/}, "$").gsub(%r{^$}, "")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rrjj-0.0.1 lib/rubymine_heaven/linkable_errors_handler.rb