mardi 29 avril 2014

how to trace and debug an rails gem


Vote count:

0




I want to trace what does event_calendar do ,


So I added the gem then bundle install and I found its install location is at ~/.rvm/gems/ruby-1.9.3-p448/gems/event-calendar-2.3.3/generators/event_calendar


So I add require 'pry' and embedded the binding.pry in the line I want to debug,


However when I ran the rails g event_calendar


I thought it will invoke the event_calendar_generator.rb in ~/.rvm/gems/ruby-1.9.3-p448/gems/event-calendar-2.3.3/generators/event_calendar


However it didn't be blocked at the line I expected.



1 require 'pry'
2 require File.expand_path(File.dirname(__FILE__) + "/lib/insert_routes.rb")
3 binding.pry
4 class EventCalendarGenerator < Rails::Generator::Base
5 default_options :static_only => false,
6 :use_jquery => false,
7 :use_all_day => false
8
9 attr_reader :class_name, :view_name
10
11 def initialize(args, runtime_options = {})
12 super
13 binding.pry
14 usage if args.length > 0 and args.length < 2
15 @class_name = (args.shift || "event").underscore
16 @view_name = (args.shift || "calendar").underscore
17 end


asked 34 secs ago

poc

755





Aucun commentaire:

Enregistrer un commentaire