Sha256: 896cff8d612c8621d7adf471e02fc69d99a32bda28c5f0d74d24c2ee2ecb3b30

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby
# $Id: tracelines.rb 143 2008-06-12 00:04:43Z rockyb $
begin require 'rubygems' rescue LoadError end
# require 'ruby-debug' ; Debugger.start(:post-mortem => true)

module TraceLineNumbers
  @@SRC_DIR = File.expand_path(File.dirname(__FILE__))
  begin
    require File.join(@@SRC_DIR, '..', 'ext', 'trace_nums')
  rescue LoadError
    # MSWindows seems to put this in lib rather than ext.
    require File.join(@@SRC_DIR, '..', 'lib', 'trace_nums')
  end

  # Return an array of lines numbers that could be 
  # stopped at given a file name of a Ruby program.
  def lnums_for_file(file)
    lnums_for_str(File.read(file))
  end
  module_function :lnums_for_file

  # Return an array of lines numbers that could be 
  # stopped at given a file name of a Ruby program.
  # We assume the each line has \n at the end. If not 
  # set the newline parameters to \n.
  def lnums_for_str_array(string_array, newline='')
    lnums_for_str(string_array.join(newline))
  end
  module_function :lnums_for_str_array
end

if __FILE__ == $0
  SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
  # test_file = '../test/rcov-bug.rb'
  test_file = '../test/lnum-data/begin1.rb'
  if  File.exists?(test_file)
    puts TraceLineNumbers.lnums_for_file(test_file).inspect 
    load(test_file, 0) # for later
  end
  puts TraceLineNumbers.lnums_for_file(__FILE__).inspect
  unless SCRIPT_LINES__.empty?
    key = SCRIPT_LINES__.keys.first
    puts key
    puts SCRIPT_LINES__[key]
    puts TraceLineNumbers.lnums_for_str_array(SCRIPT_LINES__[key]).inspect
  end
end

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.8/gems/linecache-0.46/lib/tracelines.rb
linecache-0.46 lib/tracelines.rb
linecache-0.46-mswin32 lib/tracelines.rb
linecache-0.45.1-mswin32 lib/tracelines.rb
linecache-0.45-mswin32 lib/tracelines.rb
linecache-0.45 lib/tracelines.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/linecache-0.43/lib/tracelines.rb
rackjour-0.1.8 vendor/gems/gems/linecache-0.43/lib/tracelines.rb
linecache-0.43-mswin32 lib/tracelines.rb
linecache-0.43 lib/tracelines.rb