blob: 6307b5c5169a8a22701a0b9a11f7c971ccc20f38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
USE_RUBY="ruby31 ruby32"
RUBY_FAKEGEM_RECIPE_TEST="rspec3"
RUBY_FAKEGEM_EXTRADOC="CHANGELOG.adoc LICENSE.txt README.adoc"
RUBY_FAKEGEM_GEMSPEC="${PN}.gemspec"
inherit ruby-fakegem
DESCRIPTION="A set of Asciidoctor extensions that enable you to add diagrams"
HOMEPAGE="https://github.com/asciidoctor/asciidoctor-diagram"
SRC_URI="https://github.com/asciidoctor/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
# Supported backends dictionary: <backend-name> <dependencies> <removal-function>
# backend-name: The name of the USE flag, a gem spec file in ./spec, a
# directory in ./lib/asciidoctor-diagram/, and a require directive in
# ./lib/asciidoctor.rb which will be removed if the former is unset.
# dependencies: Dependencies for RDEPEND if the USE flag is set, and for
# DEPEND if the "test" USE flag is set.
# removal-function: Additional commands to evaluate, if the USE flag is unset.
#
# NB: Do not implicitly use functions following a naming scheme instead
# of an explicit <removal-function> to prevent accidental or malicious
# injection from functions exported in the parent environment.
backend_dict_stride=3
backends=(
"barcode" "dev-ruby/rqrcode dev-ruby/barby" ""
"ditaa" "media-gfx/ditaa" "remove_ditaa"
"gnuplot" "sci-visualization/gnuplot" ""
"graphviz" "media-gfx/graphviz" ""
"lilypond" "media-sound/lilypond" ""
"meme" "media-gfx/imagemagick[png]" ""
"mscgen" "media-gfx/mscgen[png]" ""
"plantuml" "media-gfx/plantuml" "remove_plantuml"
"tikz" "dev-tex/pgf" ""
)
remove_plantuml() {
rm -f "spec/salt.rb"
sed -i "/\\/salt'/d" "lib/asciidoctor-diagram.rb"
sed -i "/plantuml/d" "asciidoctor-diagram.gemspec"
}
remove_ditaa() {
sed -i "/ditaa/d" "asciidoctor-diagram.gemspec"
}
IUSE=""
DEPEND+="test? ("
i=0
while (( i < ${#backends[@]} ))
do
backend="${backends[i]}"
deps="${backends[i+1]}"
IUSE+=" $backend"
RDEPEND+=" $backend? ( $deps )"
DEPEND+=" $deps"
((i+=backend_dict_stride))
done
DEPEND+=" )"
ruby_add_rdepend ">=dev-ruby/asciidoctor-1.5.7 <dev-ruby/asciidoctor-3 dev-ruby/rexml"
all_ruby_prepare() {
rm Gemfile || die
sed -e '/c.formatter/ s:^:#:' \
-e '/logger.*DEBUG/ s:^:#:' \
-i spec/test_helper_methods.rb || die
# Delete everything related to unsupported backends. Obtain list of backends from spec/
for spec in spec/*_spec.rb
do
backend="${spec##spec/}"
backend="${backend%%_spec.rb}"
backend_index=0
get_backend_index() {
local i=0
while (( i < ${#backends[@]} ))
do
if [[ "${backends[i]}" == "$backend" ]]
then
echo "$i"
return 1
fi
((i+=backend_dict_stride))
done
}
if backend_index="$(get_backend_index)" || ! use "$backend"
then
rm -f "spec/${backend}_spec.rb"
rm -Rf "lib/asciidoctor-diagram/"{"$backend.rb","$backend"}
sed -i "/\\/$backend'/d" "lib/asciidoctor-diagram.rb"
removal="${backends[backend_index+2]}"
if [[ "$removal" ]]
then
"$removal"
fi
fi
done
}
all_ruby_install() {
all_fakegem_install
}
|