[GEM PATCH] allow gem to install bin file to different location

Discussion in 'Ruby' started by Ara.T.Howard, Oct 27, 2005.

  1. Ara.T.Howard

    Ara.T.Howard Guest

    SYNOPSIS

    this patch allows any value in Config::CONFIG to be altered from the
    command line when using gem. by altering a value, for example bindir, fine
    grained control can be affected during the installation proccess. here is the
    patch:


    PATCH


    jib:~ > diff -u gem.org gem
    --- gem.org 2005-10-26 14:51:53.000000000 -0600
    +++ gem 2005-10-26 17:44:31.000000000 -0600
    @@ -14,4 +14,16 @@
    # it...its for the source building process.
    args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]

    +#
    +# munge rbconfig from any command line or environment kv pair
    +#
    +kvs = []
    +re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
    +args.delete_if{|arg| (m = re.match(arg)) and (kvs << m.to_a.last(2))}
    +ENV::each{|k,v| (k =~ %r/^GEM_/) and (kvs << [k.delete('GEM_'), v])}
    +unless kvs.empty?
    + require 'rbconfig'
    + kvs.each{|k,v| Config::CONFIG[k] = v}
    +end
    +
    Gem::GemRunner.new.run(args)


    EXAMPLE USAGE

    jib:~ > which rake
    which: no rake in ...

    jib: > ruby -r rbconfig -e'p Config::CONFIG["bindir"]'
    "/dmsp/reference/ruby-1.8.1//bin"

    jib: > gem install bindir=/dmsp/reference/bin rake
    Attempting local installation of 'rake'
    Local gem file not found: rake*.gem
    Attempting remote installation of 'rake'
    Successfully installed rake-0.6.2
    Installing RDoc documentation for rake-0.6.2...

    jib: > which rake
    /dmsp/reference/bin/rake


    so anything value in Config::CONFIG can be replaced on the command line.
    configuration via the environment is also supported. so i could have done the
    above via

    jib: > export GEM_bindir=/dmsp/reference/bin
    jib: > gem install rake

    any env var starting with 'GEM_' is taken to be a key/val pair for
    Config::CONFIG.

    thoughts?


    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | anything that contradicts experience and logic should be abandoned.
    | -- h.h. the 14th dalai lama
    ===============================================================================
    Ara.T.Howard, Oct 27, 2005
    #1
    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. sweety
    Replies:
    9
    Views:
    1,009
    Richard Heathfield
    Feb 7, 2006
  2. Ryan Taylor
    Replies:
    1
    Views:
    674
    Ryan Taylor
    Sep 9, 2004
  3. anne001
    Replies:
    1
    Views:
    400
  4. Mmcolli00 Mom
    Replies:
    7
    Views:
    121
    Eric Hodel
    Apr 30, 2009
  5. James Calfee
    Replies:
    0
    Views:
    142
    James Calfee
    Nov 25, 2009
Loading...

Share This Page