Defly
Upcoming SlideShare
Loading in...5
×
 

Defly

on

  • 1,144 views

Debugging and tracing tool for Ruby

Debugging and tracing tool for Ruby

Statistics

Views

Total Views
1,144
Views on SlideShare
1,139
Embed Views
5

Actions

Likes
0
Downloads
18
Comments
0

2 Embeds 5

http://www.hanrss.com 3
http://twitter.com 2

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Defly Defly Presentation Transcript

  • DeflyDebugging and Tracing Tool for Ruby http://github.com/eggegg/defly
  • Andrew Liu• Collage Student• Intern @ Cardinalblue• eggegg @ github• Ruby, iOS, Android• andrewliu33@gmail.com
  • gem install defly
  • Defly is for...• Trace method calls• Trace instance variables• Better error messages• Inspect the point of error
  • class Warrior attr_accessor :hp, :mp def sleep self.hp += 10 self.mp += 2 endend
  • class Warrior attr_accessor :hp, :mp def sleep puts "BEFORE: #{@hp}, #{@mp}" self.hp += 10 puts "AFTER ADDING HP: #{@hp}, #{@mp}" self.mp += 2 puts "AFTER ADDING MP: #{@hp}, #{@mp}" endend
  • class Warrior attr_accessor :hp, :mp def sleep self.hp += 10 self.mp += 2 endendrequire deflyWarrior.debug!Warrior.new.trace([:hp, :hp=, :mp, :mp=, :sleep], [:@hp, :@mp]) do |warrior| warrior.hp = 10 warrior.mp = 20 warrior.sleepend
  • Tracing hp, hp=, mp, mp=, sleep on Warrior instanceTracing @hp, @mp on Warrior instance<<<<< Warrior#hp=(10) # (irb):14:in `block in irb_binding @hp = 10 # undefined @mp = nil # undefined>>>>> 10<<<<< Warrior#mp=(20) # (irb):15:in `block in irb_binding @mp = 20 # undefined>>>>> 20<<<<< Warrior#sleep() # (irb):16:in `block in irb_binding <<<<< Warrior#hp() # (irb):7:in `sleep >>>>> 10 <<<<< Warrior#hp=(20) # (irb):7:in `sleep @hp = 20 # 10 -> 20 >>>>> 20 <<<<< Warrior#mp() # (irb):8:in `sleep >>>>> 20 <<<<< Warrior#mp=(22) # (irb):8:in `sleep @mp = 22 # 20 -> 22 >>>>> 22>>>>> 22
  • NoMethodError bug.rb debugging = nil debugging.is_annoyingirbirb(main):001:0> require bugNoMethodError: undefined method `is_annoying for nil:NilClass from /Users/eggegg/bug.rb:2:in `<top (required)> ... Where is the bug???
  • irb(main):003:0> require defly=> trueirb(main):004:0> require bugNoMethodError: undefined method `is_annoying for nil:NilClassbug.rb:2> debugging.<<is_annoying>> from /Users/andrewliu/bug.rb:2:in `<top (required)>
  • Inspecting Errorsclass Rocket def launch! @reason = "Bugs invasion" raise "Engine Fail" endendRocket.debug!rocket = Rocket.newrocket.watch_error "Engine Fail"rocket.launch!
  • Ruby shell (Rib by godfat) to inspect errors!>>>>> Error received:"Engine Fail">>>>>#<Rocket:0(0)>> @reason=> "Bugs invasion"#<Rocket:0(0)>>
  • Thanks!Any Question?