Ruby on Rails
Sunday, November 29, 2015
On Saturday, November 28, 2015 at 3:55:25 PM UTC-5, Frederick Cheung wrote:
On Saturday, November 28, 2015 at 7:38:17 PM UTC, dave wrote:
> Hi Group,
> I'm trying to see how Rails at ``startup time'' creates Javascripts within the Clientside of the browser.
>
> rails s #starting my program
>
> I've used both Byebug within Ruby code and Firefoxe's debugger within the browser.
> ==> Firefox's debug shows me the generated scripts like jquery etc but this is after the fact: the code producing the scripts has already executed.
> I want to observe how/when it generates the script and how various callbacks are registered particularly in jquery. Eg plot function using flot.
sprockets turns manifests like application.js into a single JavaScript file. In development mode typically this doesn't happen - rails turns the call to javascript_include_tag into script tags that load all of the files specified by application.js. What happens next is entirely in the browser.
Rails doesn't execute any JavaScript (unless you count the compilation of coffeescript, transpiling via the Babel gem etc. This also goes via sprockets)
Fred
Hi Fred,
Thank you for your response and explanation: development vs production javascript tags. Yes I also set traces into sprockets and manifest.rb code before my original post.
Where the tracing falls down is in the eval statement which switches into another run context and so Byebug is left hanging.
Maybe this is a Byebug forum question? or possibly i'm pushing its run-context envelope past its original design?
By having Byebug trace Ruby lines allows me to investigate the other Ruby code used to generate the javascripts for the browser.
Do u know of any debugging facilities to continue these investigations? Or should i look at Dtrace?
My thoughts are that the Core Rails developers are faced with the same problem and have appropriate tools to set break points,and output line traces.
Any suggests appreciated
Dave
>--
> ==> Byebug stops when the Ruby code does an eval expression when tracing from config/application.rb :
> I used byebug's set linetrace to observe the following:
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:33 options = {}
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:34 if config =~ /\.ru$/
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:35 cfgfile = ::File.read(config)
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:36 if cfgfile[/^#\\(.*)/] && opts
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:39 cfgfile.sub!(/^__END__\n.*\Z/ m, '')
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:40 app = new_from_string cfgfile, config
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:49 eval "Rack::Builder.new {\n" + builder_script + "\n}.to_app",
> Tracing: /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder. rb:49 eval "Rack::Builder.new {\n" + builder_script + "\n}.to_app",
>
> where the eval statement just sits and waits. At that point I had to abort the program at startup using Cntl C
>
> My questions so far are:
> 1) how to trace outside programs called by Ruby like Rack::Builder'' above to continue my investigations. Other more powerfull debug tracers to use? DTRACE?
> 1.5) Can break points be placed against the source code before the dynamic tracing begins? or have a pre-programmed script set the breakpoints at runtime?
>
> 2) how is javascript executed by ``Ruby start up'' to manufacture the local registered scripts: ie, the various crossovers between Ruby and Javascript contexts
>
> Any pointers to documents/websites/forums where these questions allow me to continue my investigations is appreciated
>
> I thank you in advance for your ``eyes and ears'' evaluating my request
> Dave
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2ae027cb-5839-428e-92d1-593c7a1c2162%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment