cutter

For now it is two-methods-gem, I use a lot for simple debugging & performance measuring purposes.

Include it into Gemfile: gem ‘cutter’

Methods are:

I) As inspect! method to any of your methods:

def your_method *args
  inspect!(local_variables,binding) # this string exactly!    
  ...
end

your_method(1,"foo",:bar) => 
  method `your_method'
    variables: 
      args: [1, "foo", :bar]

Gives simple but nice trace for inspection: method’s name, local_variables(they include args passed to method)

If you want all #inspect! methods fall silent at once, use

Cutter::Inspection.quiet!

II)

def your_method
  stamper("testing pieces of code") do
    piece_of_code #1
    stamp("piece #1 performed!")
    piece_of_code #2
    stamp("piece #2 performed!")
    pirce_of_code #3
  end
end

your_method => 
~ testing pieces of code 
~ testing: start
~ testing: piece #1 performed!, 10ms
~ testing: piece #2 performed!, 231ms
~ testing: end (247ms)

or simply:
def test_method
  stamper {
    piece of code
  }
end

Acts as self.benchmark{} or Benchmark.measure{} but with stamps in any position in block executed, and it is much simpler to write it quickly than all these Measure-dos.

Contributing to cutter

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 stanislaw. See LICENSE.txt for further details.