Prev | Current Page 80 | Next

Brad Ediger

"Advanced Rails"

Using the list (l) command, we show the context from the source:
(rdb:1) l
[800, 809] in .../gems/ruport-1.2.0/lib/ruport/data/table.rb
800 # # accepts all Data::Table.load options, including block
801 #
802 # t = Table("foo.csv")
803 # t = Table("bar.csv", :has_names => false)
804 def Table(*args,&block)
=> 805 table=
806 case(args[0])
807 when Array
808 opts = args[1] || {}
809 Ruport::Data::Table.new(f={:column_names => args[0]}.
merge(opts),&block)
The backtrace (bt) command shows the series of stack frames in which we are
nested:
(rdb:1) bt
--> #0 .../gems/ruport-1.2.0/lib/ruport/data/table.rb:805
in 'Table'
#1 ./time_report.rb:6
(rdb:1)
And we can step through the code until we have satisfied our curiosity, at which point
we use cont (c) to exit the debugger and allow the program??™s execution to continue:
54 | Chapter 2: ActiveSupport and RailTies
(rdb:1) n
.../gems/ruport-1.2.0/lib/ruport/data/table.rb:806 case(args[0])
(rdb:1)
.../gems/ruport-1.2.0/lib/ruport/data/table.rb:807 when Array
(rdb:1)
.../gems/ruport-1.2.0/lib/ruport/data/table.rb:810 when /\.csv/
(rdb:1) c
$
The debugger has many other commands and features. Breakpoints can be set and
cleared on arbitrary lines or methods, and they can be conditional:
(rdb:1) break table.rb:805 if args.first =~ /\.csv/
Set breakpoint 1 at table.rb:805
(rdb:1) c
Breakpoint 1 at table.rb:805
.


Pages:
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92