From: Alex Legler Date: Mon, 5 Apr 2010 07:41:09 +0000 (+0000) Subject: Add ruby_get_version() and ruby_get_implementation() convenience helper functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=82f1a257ff56b4c746b9f8c050de0752d9647b7a;p=gentoo.git Add ruby_get_version() and ruby_get_implementation() convenience helper functions --- diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 407e3077f0b5..b8cb5d60ab12 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -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.9 2010/04/02 20:26:21 a3li Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.10 2010/04/05 07:41:09 a3li Exp $ # # @ECLASS: ruby-ng.eclass # @MAINTAINER: @@ -448,3 +448,29 @@ ruby_get_hdrdir() { echo "${rubyhdrdir}" } + +# @FUNCTION: ruby_get_version +# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. +ruby_get_version() { + local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} + + echo $(${ruby} -e 'puts RUBY_VERSION') +} + +# @FUNCTION: ruby_get_implementation +# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. +ruby_get_implementation() { + local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} + + case $(${ruby} --version) in + *Enterprise*) + echo "ree" + ;; + *jruby*) + echo "jruby" + ;; + *) + echo "mri" + ;; + esac +}