/[gentoo-x86]/eclass/ruby-fakegem.eclass
Gentoo

Diff of /eclass/ruby-fakegem.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.40 Revision 1.43
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2014 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.40 2013/11/09 10:22:06 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.43 2014/12/28 07:23:56 graaff Exp $
4 4
5# @ECLASS: ruby-fakegem.eclass 5# @ECLASS: ruby-fakegem.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ruby herd <ruby@gentoo.org> 7# Ruby herd <ruby@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
139 IUSE+=" test" 139 IUSE+=" test"
140 ruby_add_bdepend "test? ( dev-ruby/rake )" 140 ruby_add_bdepend "test? ( dev-ruby/rake )"
141 ;; 141 ;;
142 rspec) 142 rspec)
143 IUSE+=" test" 143 IUSE+=" test"
144 ruby_add_bdepend "test? ( dev-ruby/rspec:2 )" 144 # Also require a new enough rspec-core version that installs the
145 # rspec-2 wrapper.
146 ruby_add_bdepend "test? ( dev-ruby/rspec:2 >=dev-ruby/rspec-core-2.14.8-r2 )"
145 ;; 147 ;;
146 cucumber) 148 cucumber)
147 IUSE+=" test" 149 IUSE+=" test"
148 # Unfortunately as of August 2012, cucumber is not supported on 150 # Unfortunately as of August 2012, cucumber is not supported on
149 # JRuby. We work it around here to avoid repeating the same 151 # JRuby. We work it around here to avoid repeating the same
251# Generates an installable version of the specification indicated by 253# Generates an installable version of the specification indicated by
252# the metadata distributed by the gem itself. This is similar to how 254# the metadata distributed by the gem itself. This is similar to how
253# rubygems creates an installation from a .gem file. 255# rubygems creates an installation from a .gem file.
254ruby_fakegem_metadata_gemspec() { 256ruby_fakegem_metadata_gemspec() {
255 case ${RUBY} in 257 case ${RUBY} in
256 *ruby19) 258 *jruby)
259 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1').read).to_ruby" > $2
260 ;;
261 *)
257 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1', :encoding => 'UTF-8').read).to_ruby" > $2 262 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1', :encoding => 'UTF-8').read).to_ruby" > $2
258 ;;
259 *)
260 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1').read).to_ruby" > $2
261 ;; 263 ;;
262 esac 264 esac
263} 265}
264 266
265# @FUNCTION: ruby_fakegem_genspec 267# @FUNCTION: ruby_fakegem_genspec
285 # copies with different implementations; while for now we're using 287 # copies with different implementations; while for now we're using
286 # the same exact content, we might have differences in the future, 288 # the same exact content, we might have differences in the future,
287 # so better taking this into consideration. 289 # so better taking this into consideration.
288 local quoted_description=${DESCRIPTION//\"/\\\"} 290 local quoted_description=${DESCRIPTION//\"/\\\"}
289 cat - > $1 <<EOF 291 cat - > $1 <<EOF
290# generated by ruby-fakegem.eclass $Revision: 1.40 $ 292# generated by ruby-fakegem.eclass $Revision: 1.43 $
291Gem::Specification.new do |s| 293Gem::Specification.new do |s|
292 s.name = "${RUBY_FAKEGEM_NAME}" 294 s.name = "${RUBY_FAKEGEM_NAME}"
293 s.version = "${RUBY_FAKEGEM_VERSION}" 295 s.version = "${RUBY_FAKEGEM_VERSION}"
294 s.summary = "${quoted_description}" 296 s.summary = "${quoted_description}"
295 s.homepage = "${HOMEPAGE}" 297 s.homepage = "${HOMEPAGE}"
297end 299end
298EOF 300EOF
299} 301}
300 302
301# @FUNCTION: ruby_fakegem_binwrapper 303# @FUNCTION: ruby_fakegem_binwrapper
302# @USAGE: command [path] 304# @USAGE: command [path] [content]
303# @DESCRIPTION: 305# @DESCRIPTION:
304# Creates a new binary wrapper for a command installed by the RubyGem. 306# Creates a new binary wrapper for a command installed by the RubyGem.
305# path defaults to /usr/bin/$command 307# path defaults to /usr/bin/$command content is optional and can be used
308# to inject additional ruby code into the wrapper. This may be useful to
309# e.g. force a specific version using the gem command.
306ruby_fakegem_binwrapper() { 310ruby_fakegem_binwrapper() {
307 ( 311 (
308 local gembinary=$1 312 local gembinary=$1
309 local newbinary=${2:-/usr/bin/$gembinary} 313 local newbinary=${2:-/usr/bin/$gembinary}
314 local content=$3
310 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary} 315 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary}
311 local binpath=$(dirname $newbinary) 316 local binpath=$(dirname $newbinary)
312 [[ ${binpath} = . ]] && binpath=/usr/bin 317 [[ ${binpath} = . ]] && binpath=/usr/bin
313 318
314 # Try to find out whether the package is going to install for 319 # Try to find out whether the package is going to install for
335 340
336 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF 341 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF
337#!${rubycmd} 342#!${rubycmd}
338# This is a simplified version of the RubyGems wrapper 343# This is a simplified version of the RubyGems wrapper
339# 344#
340# Generated by ruby-fakegem.eclass $Revision: 1.40 $ 345# Generated by ruby-fakegem.eclass $Revision: 1.43 $
341 346
342require 'rubygems' 347require 'rubygems'
343 348
349${content}
344load Gem::default_path[-1] + "/gems/${relativegembinary}" 350load Gem::default_path[-1] + "/gems/${relativegembinary}"
345 351
346EOF 352EOF
347 353
348 exeinto ${binpath:-/usr/bin} 354 exeinto ${binpath:-/usr/bin}
430 case ${RUBY_FAKEGEM_RECIPE_TEST} in 436 case ${RUBY_FAKEGEM_RECIPE_TEST} in
431 rake) 437 rake)
432 ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed" 438 ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
433 ;; 439 ;;
434 rspec) 440 rspec)
435 ruby-ng_rspec 441 RSPEC_VERSION=2 ruby-ng_rspec
436 ;; 442 ;;
437 cucumber) 443 cucumber)
438 ruby-ng_cucumber 444 ruby-ng_cucumber
439 ;; 445 ;;
440 none) 446 none)

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20