Merge remote-tracking branch 'github/pr/107'
[gentoo.git] / dev-ruby / gherkin / gherkin-2.12.2.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 USE_RUBY="ruby19 ruby20 ruby21 ruby22"
7
8 RUBY_FAKEGEM_TASK_DOC=""
9 RUBY_FAKEGEM_TASK_TEST=""
10
11 RUBY_FAKEGEM_DOCDIR="rdoc"
12 RUBY_FAKEGEM_EXTRADOC="History.md README.md"
13
14 inherit ruby-fakegem
15
16 DESCRIPTION="Fast Gherkin lexer and parser based on Ragel"
17 HOMEPAGE="https://github.com/cucumber/gherkin"
18 LICENSE="MIT"
19 SRC_URI="https://github.com/cucumber/gherkin/archive/v${PV}.tar.gz -> ${P}-git.tgz"
20
21 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc64 ~x86"
22 SLOT="0"
23 IUSE="doc test"
24
25 DEPEND="${DEPEND} dev-util/ragel"
26 RDEPEND="${RDEPEND}"
27
28 ruby_add_bdepend "
29         dev-ruby/rake-compiler
30         dev-ruby/ruby-beautify
31         test? (
32                 >=dev-ruby/builder-2.1.2
33                 >=dev-util/cucumber-1.1.3
34                 >=dev-ruby/rspec-2.6.0
35                 >=dev-ruby/term-ansicolor-1.0.5
36         )
37         doc? ( >=dev-ruby/yard-0.8.3 )"
38
39 ruby_add_rdepend ">=dev-ruby/multi_json-1.3"
40
41 RUBY_PATCHES=( ${P}-ruby21.patch )
42
43 all_ruby_prepare() {
44         # Remove Bundler-related things.
45         sed -i -e '/[Bb]undler/d' Rakefile spec/spec_helper.rb features/support/env.rb || die
46         rm Gemfile || die
47
48         # Don't use compile dependencies to avoid building again for specs.
49         sed -i -e '/:compile/d' Rakefile
50
51         # Keep this hardcoded -O0 optimization level since
52         # https://github.com/cucumber/gherkin/issues/182#issuecomment-6945009
53         # hints at the fact that removing it might cause the mysterious
54         # Lexer errors that hapen intermittently.
55         # sed -ie -e 's/-O0//' tasks/compile.rake || die
56
57         # Remove feature that depends on direct access to the cucumber
58         # source. We could probably set this up by downloading the source
59         # and unpacking it, but skipping this now in the interest of time.
60         rm features/pretty_formatter.feature || die
61
62         # We need to remove these tasks during bootstrapping since it tries
63         # to load cucumber already but we can be sure it isn't installed
64         # yet. Also remove other rake tasks for which we may not yet have
65         # dependencies.
66         if ! use test ; then
67                 rm tasks/cucumber.rake tasks/rspec.rake || die "Unable to remove rake tasks."
68         fi
69
70         # Avoid dependency on yard if USE=-doc
71         if ! use doc ; then
72                 rm tasks/apidoc.rake || die
73         fi
74
75         # Avoid implicit dependency on git
76         sed -i -e 's/git ls-files/echo/' gherkin.gemspec || die
77 }
78
79 all_ruby_compile() {
80         all_fakegem_compile
81
82         if use doc ; then
83                 yard || die
84         fi
85 }
86
87 each_ruby_compile() {
88         ${RUBY} -I lib -S rake -rrake/clean -f tasks/compile.rake compile || die
89 }
90
91 each_ruby_test() {
92         ${RUBY} -I lib -S rspec-2 spec || die "Specs failed"
93         CUCUMBER_HOME="${HOME}" RUBYLIB=lib ${RUBY} -S cucumber features || die "Cucumber features failed"
94 }