/rshade

Primary LanguageRubyMIT LicenseMIT

RShade

warcraft shade

Ruby Shade or RShade gem to help you to reveal which code are used in program execution.

trace = RShade::Trace.new  
trace.reveal do  
  #your code here
end
trace.show
#rspec
 rshade_reveal do
   #code here
 end 

Example

I've took example from https://github.com/spree/spree code base. Wrap code to take a look what code used when you save variant. On huge codebase as spree it's helpful to know what callbacks are triggered and so on.

  context '#cost_currency' do
    context 'when cost currency is nil' do
      before { variant.cost_currency = nil }

      it 'populates cost currency with the default value on save', focus: true do
        rshade_reveal do
          variant.save!
        end
        expect(variant.cost_currency).to eql 'USD'
      end
    end
  end

Below is example how output will looks like. As you can see all code that have been use are printed. asciicast

Installation

Add this line to your application's Gemfile:

gem 'rshade'  

TODO

Use stack to keep connections between current method and caller
take a look on https://github.com/matugm/visual-call-graph

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gingray/rshade.

License

The gem is available as open source under the terms of the MIT License.