Adding a ruby_rbconfig_value function to ruby-ng.eclass for easy access even to not...
authorAlex Legler <a3li@gentoo.org>
Mon, 26 Apr 2010 15:07:58 +0000 (15:07 +0000)
committerAlex Legler <a3li@gentoo.org>
Mon, 26 Apr 2010 15:07:58 +0000 (15:07 +0000)
eclass/ruby-ng.eclass

index b8cb5d60ab12cdc866d4192ba2db2c1a6c99bd3a..41ffede517d9a24f5ffebbf3b2ed373a8d0127d7 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.10 2010/04/05 07:41:09 a3li Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.11 2010/04/26 15:07:58 a3li Exp $
 #
 # @ECLASS: ruby-ng.eclass
 # @MAINTAINER:
@@ -418,6 +418,13 @@ ruby-ng_src_install() {
                _ruby_each_implementation _each_ruby_check_install
 }
 
+# @FUNCTION: ruby_rbconfig_value
+# @USAGE: rbconfig item
+# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
+ruby_rbconfig_value() {
+       echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']")
+}
+
 # @FUNCTION: doruby
 # @USAGE: file [file...]
 # @DESCRIPTION:
@@ -425,7 +432,7 @@ ruby-ng_src_install() {
 doruby() {
        [[ -z ${RUBY} ]] && die "\$RUBY is not set"
        ( # don't want to pollute calling env
-               insinto $(${RUBY} -rrbconfig -e 'print Config::CONFIG["sitelibdir"]')
+               insinto $(ruby_rbconfig_value 'sitelibdir')
                insopts -m 0644
                doins "$@"
        ) || die "failed to install $@"
@@ -440,10 +447,10 @@ ruby_get_libruby() {
 # @FUNCTION: ruby_get_hdrdir
 # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
 ruby_get_hdrdir() {
-       local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]')
+       local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
 
        if [[ "${rubyhdrdir}" = "nil" ]] ; then
-               rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]')
+               rubyhdrdir=$(ruby_rbconfig_value 'archdir')
        fi
 
        echo "${rubyhdrdir}"