Ruby on Rails Saturday, November 28, 2015

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

>
> ==> 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/b74a2dd4-a0af-4e74-a00c-50d4cff1f2c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment