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

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

  ViewVC Help
Powered by ViewVC 1.1.20