'require' to fill $" with long names?

Discussion in 'Ruby' started by Erik Veenstra, Oct 3, 2005.

  1. Require fills $" with (the short names of) the library files it
    is able to find. When the program has ended, RubyScript2Exe
    tries to match the libraries in $" with the directories in $:
    and the default extensions in order to collect the files. But,
    since $: might change when running the program (RubyGems!...),
    the files RubyScript2Exe finds are not necessarily the ones
    Ruby finds.

    I came up with this solution (see below). Just redefine require
    before executing the application and $" will be filled with the
    full names of the library files. Seems to work....

    Any suggestions or considerations?

    gegroet,
    Erik V. - http://www.erikveen.dds.nl/

    ----------------------------------------------------------------

    alias :eek:ld_require :require

    def require(lib, *rest)
    extensions = ["", ".rb", ".so", ".o", ".dll"]
    search_list = $:.collect{|dir| extensions.collect{|ext|
    File.expand_path(lib + ext, dir)}}.flatten
    found = search_list.find{|file| File.file?(file)}
    lib = found unless found.nil?

    old_require(lib, *rest)
    end

    ----------------------------------------------------------------
    Erik Veenstra, Oct 3, 2005
    #1
    1. Advertising

  2. Hi,

    At Tue, 4 Oct 2005 00:41:47 +0900,
    Erik Veenstra wrote in [ruby-talk:158842]:
    > I came up with this solution (see below). Just redefine require
    > before executing the application and $" will be filled with the
    > full names of the library files. Seems to work....


    1.9 does so.

    --
    Nobu Nakada
    nobuyoshi nakada, Oct 4, 2005
    #2
    1. Advertising

  3. > > I came up with this solution (see below). Just redefine
    > > require before executing the application and $" will be
    > > filled with the full names of the library files. Seems to
    > > work....

    >
    > 1.9 does so.


    Quick check...

    Well, uh, just partly. It does expand all pathes, except for
    enumerator.so. Where does enumerator.so come from? Why isn't it
    a full path?

    Running on Cygwin on XP.

    gegroet,
    Erik V. - http://www.erikveen.dds.nl/

    ----------------------------------------------------------------

    $ ./ruby.exe -v
    ruby 1.9.0 (2005-10-04) [i386-cygwin]

    $ ./ruby.exe -e 'p $"'
    ["enumerator.so"]

    $ ./ruby.exe -r rbconfig -e 'p $"'
    ["enumerator.so", "/scratch/snapshot/ruby/rbconfig.rb"]

    ----------------------------------------------------------------
    Erik Veenstra, Oct 4, 2005
    #3
  4. Hi,

    At Tue, 4 Oct 2005 21:41:48 +0900,
    Erik Veenstra wrote in [ruby-talk:158980]:
    > Well, uh, just partly. It does expand all pathes, except for
    > enumerator.so. Where does enumerator.so come from? Why isn't it
    > a full path?


    It is built-in now, and defined for backward compatibility
    purpose.

    --
    Nobu Nakada
    nobuyoshi nakada, Oct 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    645
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,161
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    449
    santosh
    Jul 24, 2007
  4. Bart C

    Use of Long and Long Long

    Bart C, Jan 9, 2008, in forum: C Programming
    Replies:
    27
    Views:
    768
    Peter Nilsson
    Jan 15, 2008
  5. veryhotsausage
    Replies:
    1
    Views:
    1,766
    veryhotsausage
    Jul 4, 2008
Loading...

Share This Page