Namespace
Methods
Instance Public methods
Lets an object that will forward method calls to the breakpoint client. This is useful for outputting longer things at the client and so on. You can for example do these things:
client.puts "Hello" # outputs "Hello" at client console # outputs "Hello" into the file temp.txt at the client client.File.open("temp.txt", "w") { |f| f.puts "Hello" }
Source: show
# File rails/railties/lib/breakpoint.rb, line 218 def client() if Breakpoint.use_drb? then sleep(0.5) until Breakpoint.drb_service.eval_handler Client.new(Breakpoint.drb_service.eval_handler) else Client.new(lambda { |code| eval(code, TOPLEVEL_BINDING) }) end end
Prints the call stack.
Source: show
# File rails/railties/lib/breakpoint.rb, line 200 def show_call_stack(depth = 10) base = Pathname.new(RAILS_ROOT).cleanpath.to_s caller[1..depth].each do |line| line.sub!(%r^[^:]*/) do |path| Pathname.new(path).cleanpath.to_s end client.puts(line.index(base) == 0 ? line[(base.length + 1)..-1] : line) end "#{Pathname.new(@__bp_file).cleanpath.to_s}:#{@__bp_line}" end
Prints the source code surrounding the location where the breakpoint was issued.
Source: show
# File rails/railties/lib/breakpoint.rb, line 189 def show_source_list(context = 5) start_line, break_line, result = source_lines(context, true) offset = [(break_line + context).to_s.length, 4].max result.each_with_index do |line, i| mark = (start_line + i == break_line ? '->' : ' ') client.puts("%0#{offset}d%s#{line}" % [start_line + i, mark]) end Pathname.new(@__bp_file).cleanpath.to_s end
Returns the source code surrounding the location where the breakpoint was issued.
Source: show
# File rails/railties/lib/breakpoint.rb, line 171 def source_lines(context = 5, return_line_numbers = false) lines = File.readlines(@__bp_file).map { |line| line.chomp } break_line = @__bp_line start_line = [break_line - context, 1].max end_line = break_line + context result = lines[(start_line - 1) .. (end_line - 1)] if return_line_numbers then return [start_line, break_line, result] else return result end end