Module: Breakpoint::CommandBundle
- Defined in:
- lib/breakpoint.rb
Overview
These commands are automatically available in all breakpoint shells.
Defined Under Namespace
Classes: Client
Instance Method Summary collapse
- 
  
    
      #client  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Lets an object that will forward method calls to the breakpoint client. 
- 
  
    
      #source_lines(context = 5, return_line_numbers = false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns the source code surrounding the location where the breakpoint was issued. 
Instance Method Details
#client ⇒ Object
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" }
| 216 217 218 219 220 221 222 223 | # File 'lib/breakpoint.rb', line 216 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 | 
#source_lines(context = 5, return_line_numbers = false) ⇒ Object
Returns the source code surrounding the location where the breakpoint was issued.
| 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | # File 'lib/breakpoint.rb', line 193 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 |