Where to install data files?

Discussion in 'Ruby' started by Marek Janukowicz, Feb 3, 2004.

  1. Where should I install data files for the library I wrote? They are
    connected with .rb files, so they should stay in the same directory, but
    setup.rb does not install anything but .rb files from lib/ subdirectory.
    The default data dir (/usr/share on my Gentoo Linux) does not seems
    appropiate, too (I want my library to be installed in one place).

    Maybe there should be something like java .jar files, which can contain
    not only java class files, but also the resource files (corrent me if
    I'm wrong)?

    --
    Marek Janukowicz
     
    Marek Janukowicz, Feb 3, 2004
    #1
    1. Advertising

  2. Marek Janukowicz

    Jim Weirich Guest

    Marek Janukowicz said:
    > Where should I install data files for the library I wrote? They are
    > connected with .rb files, so they should stay in the same directory, but
    > setup.rb does not install anything but .rb files from lib/ subdirectory.
    > The default data dir (/usr/share on my Gentoo Linux) does not seems
    > appropiate, too (I want my library to be installed in one place).
    >
    > Maybe there should be something like java .jar files, which can contain
    > not only java class files, but also the resource files (corrent me if
    > I'm wrong)?


    You might consider creating a RubyGem. Each gems installs in its own
    directory. See http://rubygems.rubyforge.org/wiki/wiki.pl

    --
    -- Jim Weirich http://onestepback.org
    -----------------------------------------------------------------
    "Beware of bugs in the above code; I have only proved it correct,
    not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
     
    Jim Weirich, Feb 3, 2004
    #2
    1. Advertising

  3. --fwqqG+mf3f7vyBCB
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    On Wed, Feb 04, 2004 at 06:20:04AM +0900, Marek Janukowicz wrote:
    > Where should I install data files for the library I wrote? They are
    > connected with .rb files, so they should stay in the same directory, but
    > setup.rb does not install anything but .rb files from lib/ subdirectory.
    > The default data dir (/usr/share on my Gentoo Linux) does not seems
    > appropiate, too (I want my library to be installed in one place).=20
    >=20
    > Maybe there should be something like java .jar files, which can contain
    > not only java class files, but also the resource files (corrent me if
    > I'm wrong)?


    The nice thing about putting it in something like /usr/share is rbconfig
    sets the location for you:

    require 'rbconfig'
    puts Config::CONFIG['datadir'] # =3D> /usr/share on my machine

    That being said, I have one project that uses a .glade file. I decided
    to put it next to the .rb files, as you said. I had to modify setup.rb
    slightly to allow this though. I changed the following:

    def ruby_scripts
    collect_filenames_auto().select {|n| /\.rb\z/ =3D=3D=3D n }
    end

    to just

    def ruby_scripts
    collect_filenames_auto()
    end

    You could keep the select and just add your datafile extensions there
    too, of course. Just as a bonus, this is the code I use to find the data
    file in the ruby path:

    def find_in_path(filename)
    $LOAD_PATH.find do |dir|
    try_file =3D File.join(dir, filename)
    return try_file if File.readable?(try_file)
    end
    end

    --
    Zachary P. Landau <>
    GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc

    --fwqqG+mf3f7vyBCB
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFAIBa2CwWyMCTlrZkRAgu4AJ9TSAbds8/QYnMsKY9gd6SMmt88qgCeLmWD
    ubemwhdEPPn3WwTvRvsL9CU=
    =eiz7
    -----END PGP SIGNATURE-----

    --fwqqG+mf3f7vyBCB--
     
    Zachary P. Landau, Feb 3, 2004
    #3
  4. On Wed, 4 Feb 2004 06:41:08 +0900, Jim Weirich wrote:
    >> Where should I install data files for the library I wrote? They are
    >> connected with .rb files, so they should stay in the same directory, but
    >> setup.rb does not install anything but .rb files from lib/ subdirectory.
    >> The default data dir (/usr/share on my Gentoo Linux) does not seems
    >> appropiate, too (I want my library to be installed in one place).
    >>
    >> Maybe there should be something like java .jar files, which can contain
    >> not only java class files, but also the resource files (corrent me if
    >> I'm wrong)?

    >
    > You might consider creating a RubyGem. Each gems installs in its own
    > directory. See http://rubygems.rubyforge.org/wiki/wiki.pl


    Actually I just looked at RubyGems before asking the question, but now
    I see I need to make a closer look :) Btw. what is the status of
    RubyGems development? I don't see anything new for about 2 months...

    --
    Marek Janukowicz
     
    Marek Janukowicz, Feb 3, 2004
    #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. RJGraham
    Replies:
    8
    Views:
    10,413
    Ryan Stewart
    Feb 14, 2004
  2. Richard Hanson
    Replies:
    13
    Views:
    764
    David Bolen
    Aug 31, 2004
  3. Omita
    Replies:
    2
    Views:
    363
    Piet van Oostrum
    Apr 30, 2009
  4. Nils Ruettershoff
    Replies:
    0
    Views:
    514
    Nils Ruettershoff
    Jul 22, 2010
  5. Nils Ruettershoff
    Replies:
    0
    Views:
    537
    Nils Ruettershoff
    Jul 22, 2010
Loading...

Share This Page