/[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.36 Revision 1.45
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2015 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.36 2012/08/15 15:06:09 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.45 2015/07/05 09:10:53 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:
16inherit ruby-ng 16inherit ruby-ng
17 17
18# @ECLASS-VARIABLE: RUBY_FAKEGEM_NAME 18# @ECLASS-VARIABLE: RUBY_FAKEGEM_NAME
19# @DESCRIPTION: 19# @DESCRIPTION:
20# Sets the Gem name for the generated fake gemspec. 20# Sets the Gem name for the generated fake gemspec.
21# This variable MUST be set before inheriting the eclass.
21# RUBY_FAKEGEM_NAME="${PN}" 22# RUBY_FAKEGEM_NAME="${PN}"
22 23
23# @ECLASS-VARIABLE: RUBY_FAKEGEM_VERSION 24# @ECLASS-VARIABLE: RUBY_FAKEGEM_VERSION
24# @DESCRIPTION: 25# @DESCRIPTION:
25# Sets the Gem version for the generated fake gemspec. 26# Sets the Gem version for the generated fake gemspec.
27# This variable MUST be set before inheriting the eclass.
26# RUBY_FAKEGEM_VERSION="${PV}" 28# RUBY_FAKEGEM_VERSION="${PV}"
27 29
28# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_DOC 30# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_DOC
29# @DESCRIPTION: 31# @DESCRIPTION:
30# Specify the rake(1) task to run to generate documentation. 32# Specify the rake(1) task to run to generate documentation.
33# @ECLASS-VARIABLE: RUBY_FAKEGEM_RECIPE_TEST 35# @ECLASS-VARIABLE: RUBY_FAKEGEM_RECIPE_TEST
34# @DESCRIPTION: 36# @DESCRIPTION:
35# Specify one of the default testing function for ruby-fakegem: 37# Specify one of the default testing function for ruby-fakegem:
36# - rake (default; see also RUBY_FAKEGEM_TASK_TEST) 38# - rake (default; see also RUBY_FAKEGEM_TASK_TEST)
37# - rspec (calls ruby-ng_rspec, adds dev-ruby/rspec:2 to the dependencies) 39# - rspec (calls ruby-ng_rspec, adds dev-ruby/rspec:2 to the dependencies)
40# - rspec3 (calls ruby-ng_rspec, adds dev-ruby/rspec:3 to the dependencies)
38# - cucumber (calls ruby-ng_cucumber, adds dev-util/cucumber to the 41# - cucumber (calls ruby-ng_cucumber, adds dev-util/cucumber to the
39# dependencies; does not work on JRuby). 42# dependencies; does not work on JRuby).
40# - none 43# - none
41# RUBY_FAKEGEM_RECIPE_TEST="rake" 44# RUBY_FAKEGEM_RECIPE_TEST="rake"
42 45
49# @ECLASS-VARIABLE: RUBY_FAKEGEM_RECIPE_DOC 52# @ECLASS-VARIABLE: RUBY_FAKEGEM_RECIPE_DOC
50# @DESCRIPTION: 53# @DESCRIPTION:
51# Specify one of the default API doc building function for ruby-fakegem: 54# Specify one of the default API doc building function for ruby-fakegem:
52# - rake (default; see also RUBY_FAKEGEM_TASK_DOC) 55# - rake (default; see also RUBY_FAKEGEM_TASK_DOC)
53# - rdoc (calls `rdoc-2`, adds dev-ruby/rdoc to the dependencies); 56# - rdoc (calls `rdoc-2`, adds dev-ruby/rdoc to the dependencies);
57# - yard (calls `yard`, adds dev-ruby/yard to the dependencies);
54# - none 58# - none
55# RUBY_FAKEGEM_RECIPE_DOC="rake" 59# RUBY_FAKEGEM_RECIPE_DOC="rake"
56 60
57# @ECLASS-VARIABLE: RUBY_FAKEGEM_DOCDIR 61# @ECLASS-VARIABLE: RUBY_FAKEGEM_DOCDIR
58# @DESCRIPTION: 62# @DESCRIPTION:
112 116
113case ${RUBY_FAKEGEM_RECIPE_DOC} in 117case ${RUBY_FAKEGEM_RECIPE_DOC} in
114 rake) 118 rake)
115 IUSE+=" doc" 119 IUSE+=" doc"
116 ruby_add_bdepend "doc? ( dev-ruby/rake )" 120 ruby_add_bdepend "doc? ( dev-ruby/rake )"
121 RUBY_FAKEGEM_DOCDIR="doc"
117 ;; 122 ;;
118 rdoc) 123 rdoc)
119 IUSE+=" doc" 124 IUSE+=" doc"
120 ruby_add_bdepend "doc? ( dev-ruby/rdoc )" 125 ruby_add_bdepend "doc? ( dev-ruby/rdoc )"
121 RUBY_FAKEGEM_DOCDIR="doc" 126 RUBY_FAKEGEM_DOCDIR="doc"
122 ;; 127 ;;
128 yard)
129 IUSE+="doc"
130 ruby_add_bdepend "doc? ( dev-ruby/yard )"
131 RUBY_FAKEGEM_DOCDIR="doc"
132 ;;
123 none) 133 none)
124 [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && IUSE+=" doc" 134 [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && IUSE+=" doc"
125 ;; 135 ;;
126esac 136esac
127 137
132 IUSE+=" test" 142 IUSE+=" test"
133 ruby_add_bdepend "test? ( dev-ruby/rake )" 143 ruby_add_bdepend "test? ( dev-ruby/rake )"
134 ;; 144 ;;
135 rspec) 145 rspec)
136 IUSE+=" test" 146 IUSE+=" test"
147 # Also require a new enough rspec-core version that installs the
148 # rspec-2 wrapper.
149 ruby_add_bdepend "test? ( dev-ruby/rspec:2 >=dev-ruby/rspec-core-2.14.8-r2 )"
150 ;;
151 rspec3)
152 IUSE+=" test"
137 ruby_add_bdepend "test? ( dev-ruby/rspec:2 )" 153 ruby_add_bdepend "test? ( dev-ruby/rspec:3 )"
138 ;; 154 ;;
139 cucumber) 155 cucumber)
140 IUSE+=" test" 156 IUSE+=" test"
141 # Unfortunately as of August 2012, cucumber is not supported on 157 # Unfortunately as of August 2012, cucumber is not supported on
142 # JRuby. We work it around here to avoid repeating the same 158 # JRuby. We work it around here to avoid repeating the same
243# @DESCRIPTION: 259# @DESCRIPTION:
244# Generates an installable version of the specification indicated by 260# Generates an installable version of the specification indicated by
245# the metadata distributed by the gem itself. This is similar to how 261# the metadata distributed by the gem itself. This is similar to how
246# rubygems creates an installation from a .gem file. 262# rubygems creates an installation from a .gem file.
247ruby_fakegem_metadata_gemspec() { 263ruby_fakegem_metadata_gemspec() {
264 case ${RUBY} in
265 *jruby)
248 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1').read).to_ruby" > $2 266 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1').read).to_ruby" > $2
267 ;;
268 *)
269 ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1', :encoding => 'UTF-8').read).to_ruby" > $2
270 ;;
271 esac
249} 272}
250 273
251# @FUNCTION: ruby_fakegem_genspec 274# @FUNCTION: ruby_fakegem_genspec
252# @USAGE: output-gemspec 275# @USAGE: output-gemspec
253# @DESCRIPTION: 276# @DESCRIPTION:
271 # copies with different implementations; while for now we're using 294 # copies with different implementations; while for now we're using
272 # the same exact content, we might have differences in the future, 295 # the same exact content, we might have differences in the future,
273 # so better taking this into consideration. 296 # so better taking this into consideration.
274 local quoted_description=${DESCRIPTION//\"/\\\"} 297 local quoted_description=${DESCRIPTION//\"/\\\"}
275 cat - > $1 <<EOF 298 cat - > $1 <<EOF
276# generated by ruby-fakegem.eclass $Revision: 1.36 $ 299# generated by ruby-fakegem.eclass $Revision: 1.45 $
277Gem::Specification.new do |s| 300Gem::Specification.new do |s|
278 s.name = "${RUBY_FAKEGEM_NAME}" 301 s.name = "${RUBY_FAKEGEM_NAME}"
279 s.version = "${RUBY_FAKEGEM_VERSION}" 302 s.version = "${RUBY_FAKEGEM_VERSION}"
280 s.summary = "${quoted_description}" 303 s.summary = "${quoted_description}"
281 s.homepage = "${HOMEPAGE}" 304 s.homepage = "${HOMEPAGE}"
283end 306end
284EOF 307EOF
285} 308}
286 309
287# @FUNCTION: ruby_fakegem_binwrapper 310# @FUNCTION: ruby_fakegem_binwrapper
288# @USAGE: command [path] 311# @USAGE: command [path] [content]
289# @DESCRIPTION: 312# @DESCRIPTION:
290# Creates a new binary wrapper for a command installed by the RubyGem. 313# Creates a new binary wrapper for a command installed by the RubyGem.
291# path defaults to /usr/bin/$command 314# path defaults to /usr/bin/$command content is optional and can be used
315# to inject additional ruby code into the wrapper. This may be useful to
316# e.g. force a specific version using the gem command.
292ruby_fakegem_binwrapper() { 317ruby_fakegem_binwrapper() {
293 ( 318 (
294 local gembinary=$1 319 local gembinary=$1
295 local newbinary=${2:-/usr/bin/$gembinary} 320 local newbinary=${2:-/usr/bin/$gembinary}
321 local content=$3
296 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary} 322 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary}
297 local binpath=$(dirname $newbinary) 323 local binpath=$(dirname $newbinary)
298 [[ ${binpath} = . ]] && binpath=/usr/bin 324 [[ ${binpath} = . ]] && binpath=/usr/bin
299 325
300 # Try to find out whether the package is going to install for 326 # Try to find out whether the package is going to install for
321 347
322 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF 348 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF
323#!${rubycmd} 349#!${rubycmd}
324# This is a simplified version of the RubyGems wrapper 350# This is a simplified version of the RubyGems wrapper
325# 351#
326# Generated by ruby-fakegem.eclass $Revision: 1.36 $ 352# Generated by ruby-fakegem.eclass $Revision: 1.45 $
327 353
328require 'rubygems' 354require 'rubygems'
329 355
356${content}
330load Gem::default_path[-1] + "/gems/${relativegembinary}" 357load Gem::default_path[-1] + "/gems/${relativegembinary}"
331 358
332EOF 359EOF
333 360
334 exeinto ${binpath:-/usr/bin} 361 exeinto ${binpath:-/usr/bin}
346 rake) 373 rake)
347 rake ${RUBY_FAKEGEM_TASK_DOC} || die "failed to (re)build documentation" 374 rake ${RUBY_FAKEGEM_TASK_DOC} || die "failed to (re)build documentation"
348 ;; 375 ;;
349 rdoc) 376 rdoc)
350 rdoc ${RUBY_FAKEGEM_DOC_SOURCES} || die "failed to (re)build documentation" 377 rdoc ${RUBY_FAKEGEM_DOC_SOURCES} || die "failed to (re)build documentation"
378 ;;
379 yard)
380 yard doc ${RUBY_FAKEGEM_DOC_SOURCES} || die "failed to (re)build documentation"
351 ;; 381 ;;
352 esac 382 esac
353 fi 383 fi
354} 384}
355 385
366 # Make sure that we're not running unpack for more than 396 # Make sure that we're not running unpack for more than
367 # one .gem file, since we won't support that at all. 397 # one .gem file, since we won't support that at all.
368 [[ -d "${S}" ]] && die "Unable to unpack ${archive}, ${S} exists" 398 [[ -d "${S}" ]] && die "Unable to unpack ${archive}, ${S} exists"
369 399
370 ebegin "Unpacking .gem file..." 400 ebegin "Unpacking .gem file..."
371 tar -mxf ${DISTDIR}/${archive} || die 401 tar -mxf "${DISTDIR}"/${archive} || die
372 eend $? 402 eend $?
373 403
374 ebegin "Uncompressing metadata" 404 ebegin "Uncompressing metadata"
375 gunzip metadata.gz || die 405 gunzip metadata.gz || die
376 eend $? 406 eend $?
413 case ${RUBY_FAKEGEM_RECIPE_TEST} in 443 case ${RUBY_FAKEGEM_RECIPE_TEST} in
414 rake) 444 rake)
415 ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed" 445 ${RUBY} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
416 ;; 446 ;;
417 rspec) 447 rspec)
418 ruby-ng_rspec 448 RSPEC_VERSION=2 ruby-ng_rspec
449 ;;
450 rspec3)
451 RSPEC_VERSION=3 ruby-ng_rspec
419 ;; 452 ;;
420 cucumber) 453 cucumber)
421 ruby-ng_cucumber 454 ruby-ng_cucumber
422 ;; 455 ;;
423 none) 456 none)

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20