eclasses: updated ruby eclasses

Moved eclasses from the upstream directory to de local eclass directory.

BUG=chromium:1095743
TEST=None

Change-Id: Idc6ce598b0607a3d9ae6387ff0b246c3e32300e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2261314
Tested-by: Kevin Ruvalcaba <kevinruvalcaba@google.com>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Kevin Ruvalcaba <kevinruvalcaba@google.com>
diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
index a6a7654..d095608 100644
--- a/eclass/ruby-fakegem.eclass
+++ b/eclass/ruby-fakegem.eclass
@@ -155,20 +155,24 @@
 case ${RUBY_FAKEGEM_RECIPE_TEST} in
 	rake)
 		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
 		ruby_add_bdepend "test? ( dev-ruby/rake )"
 		;;
 	rspec)
 		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
 		# Also require a new enough rspec-core version that installs the
 		# rspec-2 wrapper.
 		ruby_add_bdepend "test? ( dev-ruby/rspec:2 >=dev-ruby/rspec-core-2.14.8-r2 )"
 		;;
 	rspec3)
 		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
 		ruby_add_bdepend "test? ( dev-ruby/rspec:3 )"
 		;;
 	cucumber)
 		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
 		ruby_add_bdepend "test? ( dev-util/cucumber )"
 		;;
 	*)
@@ -176,7 +180,7 @@
 		;;
 esac
 
-SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${RUBY_FAKEGEM_SUFFIX:+-${RUBY_FAKEGEM_SUFFIX}}.gem"
+SRC_URI="https://rubygems.org/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${RUBY_FAKEGEM_SUFFIX:+-${RUBY_FAKEGEM_SUFFIX}}.gem"
 
 ruby_add_bdepend virtual/rubygems
 ruby_add_rdepend virtual/rubygems
@@ -207,7 +211,7 @@
 }
 
 # @FUNCTION: ruby_fakegem_doins
-# @USAGE: file [file...]
+# @USAGE: <file> [file...]
 # @DESCRIPTION:
 # Installs the specified file(s) into the gems directory.
 ruby_fakegem_doins() {
@@ -217,8 +221,8 @@
 	) || die "failed $0 $@"
 }
 
-# @FUNCTION: ruby_fakegem_newsins
-# @USAGE: file filename
+# @FUNCTION: ruby_fakegem_newins
+# @USAGE: <file> <newname>
 # @DESCRIPTION:
 # Installs the specified file into the gems directory using the provided filename.
 ruby_fakegem_newins() {
@@ -262,7 +266,7 @@
 }
 
 # @FUNCTION: ruby_fakegem_gemspec_gemspec
-# @USAGE: gemspec-input gemspec-output
+# @USAGE: <gemspec-input> <gemspec-output>
 # @DESCRIPTION:
 # Generates an installable version of the specification indicated by
 # RUBY_FAKEGEM_GEMSPEC. This file is eval'ed to produce a final specification
@@ -272,7 +276,7 @@
 }
 
 # @FUNCTION: ruby_fakegem_metadata_gemspec
-# @USAGE: gemspec-metadata gemspec-output
+# @USAGE: <gemspec-metadata> <gemspec-output>
 # @DESCRIPTION:
 # Generates an installable version of the specification indicated by
 # the metadata distributed by the gem itself. This is similar to how
@@ -282,7 +286,7 @@
 }
 
 # @FUNCTION: ruby_fakegem_genspec
-# @USAGE: output-gemspec
+# @USAGE: <output-gemspec>
 # @DESCRIPTION:
 # Generates a gemspec for the package and places it into the "specifications"
 # directory of RubyGems.
@@ -327,7 +331,7 @@
 }
 
 # @FUNCTION: ruby_fakegem_binwrapper
-# @USAGE: command [path] [content]
+# @USAGE: <command> [path] [content]
 # @DESCRIPTION:
 # Creates a new binary wrapper for a command installed by the RubyGem.
 # path defaults to /usr/bin/$command content is optional and can be used
diff --git a/eclass/ruby-ng-gnome2.eclass b/eclass/ruby-ng-gnome2.eclass
index 5bfe59c..ce52f27 100644
--- a/eclass/ruby-ng-gnome2.eclass
+++ b/eclass/ruby-ng-gnome2.eclass
@@ -1,17 +1,25 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng-gnome2.eclass,v 1.17 2014/10/27 19:48:35 graaff Exp $
 
 # @ECLASS: ruby-ng-gnome2.eclass
 # @MAINTAINER:
 # Ruby herd <ruby@gentoo.org>
 # @AUTHOR:
 # Author: Hans de Graaff <graaff@gentoo.org>
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
 # @BLURB: An eclass to simplify handling of various ruby-gnome2 parts.
 # @DESCRIPTION:
 # This eclass simplifies installation of the various pieces of
 # ruby-gnome2 since they share a very common installation procedure.
 
+case "${EAPI:-0}" in
+	0|1|2|3|4|5|6)
+		;;
+	*)
+		die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+		;;
+esac
+
 RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN#ruby-}}"
 RUBY_FAKEGEM_TASK_TEST=""
 RUBY_FAKEGEM_TASK_DOC=""
@@ -37,7 +45,7 @@
 	RUBY_S=ruby-gnome2-all-${PV}/${subbinding}
 fi
 SRC_URI="mirror://sourceforge/ruby-gnome2/ruby-gnome2-all-${PV}.tar.gz"
-HOMEPAGE="http://ruby-gnome2.sourceforge.jp/"
+HOMEPAGE="https://ruby-gnome2.osdn.jp/"
 LICENSE="Ruby"
 SLOT="0"
 
diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
index ebeb01d..f92547b 100644
--- a/eclass/ruby-ng.eclass
+++ b/eclass/ruby-ng.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: ruby-ng.eclass
@@ -137,7 +137,7 @@
 	local res=
 	for _ruby_implementation in $(_ruby_get_all_impls); do
 		has -${_ruby_implementation} $@ || \
-			res="${res}ruby_targets_${_ruby_implementation}?,"
+			res="${res}ruby_targets_${_ruby_implementation}(-)?,"
 	done
 
 	echo "[${res%,}]"
@@ -151,9 +151,9 @@
 			"||" | "(" | ")" | *"?")
 				echo "${token}" ;;
 			*])
-				echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
+				echo "${token%[*}[RUBYTARGET(-),${token/*[}" ;;
 			*)
-				echo "${token}[RUBYTARGET]" ;;
+				echo "${token}[RUBYTARGET(-)]" ;;
 		esac
 	done
 	echo ")"
@@ -234,7 +234,10 @@
 		4|5|6) DEPEND="${DEPEND} test? ( ${dependency} )" ;;
 		*) BDEPEND="${BDEPEND} test? ( ${dependency} )" ;;
 	esac
-	has test "$IUSE" || IUSE="${IUSE} test"
+	if ! has test "$IUSE"; then
+		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
+	fi
 }
 
 # @FUNCTION: ruby_add_bdepend
@@ -467,7 +470,7 @@
 			;;
 		6)
 			if [[ -n ${RUBY_PATCHES[@]} ]]; then
-				eqawarn "RUBY_PATCHES is no longer supported, use PATCHES instead"
+			   eqawarn "RUBY_PATCHES is no longer supported, use PATCHES instead"
 			fi
 			;;
 		*)
diff --git a/eclass/ruby-utils.eclass b/eclass/ruby-utils.eclass
index 89d06fd..2934c94 100644
--- a/eclass/ruby-utils.eclass
+++ b/eclass/ruby-utils.eclass
@@ -28,10 +28,10 @@
 # provide for a better first installation experience.
 
 # All stable RUBY_TARGETS
-RUBY_TARGETS_PREFERENCE="ruby24 "
+RUBY_TARGETS_PREFERENCE="ruby25 ruby24 "
 
 # All other active ruby targets
-RUBY_TARGETS_PREFERENCE+="ruby25 ruby26"
+RUBY_TARGETS_PREFERENCE+="ruby26 ruby27"
 
 
 _ruby_implementation_depend() {
@@ -75,6 +75,10 @@
 			rubypn="dev-lang/ruby"
 			rubyslot=":2.6"
 			;;
+		ruby27)
+			rubypn="dev-lang/ruby"
+			rubyslot=":2.7"
+			;;
 		ree18)
 			rubypn="dev-lang/ruby-enterprise"
 			rubyslot=":1.8"