The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Whoa, SCRIPT_LINES__?!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Whoa, SCRIPT_LINES__?! Posted: Feb 23, 2005 10:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Whoa, SCRIPT_LINES__?!
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

Did you know this? I had no idea. If you define SCRIPT_LINES__ constant as a Hash, then the source code for all load‘d or require‘d files will be stored in the Hash! The key is the path to the source file and the value is an array of strings, each a line of source code.

 >> SCRIPT_LINES__ = {}
 >> require 'drb'
 >> SCRIPT_LINES__.keys
 => ["/usr/local/lib/ruby/1.8/drb/drb.rb", 
     "/usr/local/lib/ruby/1.8/drb/eq.rb", 
     "/usr/local/lib/ruby/1.8/drb/invokemethod.rb", 
     "/usr/local/lib/ruby/1.8/thread.rb", 
     "/usr/local/lib/ruby/1.8/drb.rb"]
 >> SCRIPT_LINES__['/usr/local/lib/ruby/1.8/drb.rb']
 => ["require 'drb/drb'\n", "\n"]

WEIRD. What gives with the trailing underscores? It’s such a big constant that it leaves a two-character shadow!!

Note that $SAFE must be zero. See yycompile() in parse.y for details. But, yes, I saw this in PickAxe the Second.

Read: Whoa, SCRIPT_LINES__?!

Topic: Step Three: HTML Mockups Previous Topic   Next Topic Topic: Jamis Buck presents Rails at Utah JUG

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use