summaryrefslogtreecommitdiffstats
path: root/rubygem-github-markup.spec
blob: 4061c3a42d65ee8a2d826d8f5faceea85720aa8e (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
%global gem_name github-markup

# Some tests do string comparisons on sample data. This data can be tightly
# coupled with the exact versions of the interpreter dependencies. Sometimes
# the test data upstream will not match what our software versions in Fedora
# generate. In those cases, we need to regenerate the test data during the RPM
# build process.
%global _regenerate_asciidoc 0
%global _regenerate_lhs 1
%global _regenerate_mediawiki 1
%global _regenerate_pod 1

Name: rubygem-%{gem_name}
Version: 1.0.0
Release: 1%{?dist}
Summary: The code GitHub uses to render README.markup
Group: Development/Languages
License: MIT
URL: https://github.com/github/markup
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# Fix for newer RDoc: https://github.com/github/markup/pull/214
Patch0: rubygem-github-markup-1.0.0-rdoc.patch
# TODO: patch out "/usr/bin/env perl" in lib/github/markups.rb
Requires: ruby(release)
Requires: ruby(rubygems)
Requires: rubygem(github-markdown)
Requires: rubygem(redcarpet)
Requires: rubygem(rdiscount)
Requires: rubygem(maruku)
Requires: rubygem(kramdown)
# The bluecloth interpreter is not yet in Fedora. Comment out for now.
# https://bugzilla.redhat.com/771297
#Requires: rubygem(bluecloth)
Requires: rubygem(RedCloth)
Requires: rubygem(org-ruby)
Requires: rubygem(creole)
Requires: rubygem(wikicloth)
Requires: rubygem(literati)
Requires: rubygem(asciidoctor) >= 0.1.4
Requires: perl(Pod::Simple::HTML)
# The python-creole is not yet in Fedora. Comment out for now.
#Requires: python-creole
BuildRequires: ruby(release)
BuildRequires: rubygems-devel
BuildRequires: rubygem(minitest)
BuildRequires: rubygem(github-markdown)
BuildRequires: rubygem(redcarpet)
BuildRequires: rubygem(rdiscount)
BuildRequires: rubygem(maruku)
BuildRequires: rubygem(kramdown)
#BuildRequires: rubygem(bluecloth)
BuildRequires: rubygem(RedCloth)
BuildRequires: rubygem(org-ruby)
BuildRequires: rubygem(creole)
BuildRequires: rubygem(wikicloth)
BuildRequires: rubygem(literati)
BuildRequires: rubygem(asciidoctor) >= 0.1.4
BuildRequires: perl(Pod::Simple::HTML)
#BuildRequires: python-creole

BuildArch: noarch
Provides: rubygem(%{gem_name}) = %{version}

%description
This gem is used by GitHub to render any fancy markup such as
Markdown, Textile, Org-Mode, etc.


%package doc
Summary: Documentation for %{name}
Group: Documentation
Requires: %{name} = %{version}-%{release}
BuildArch: noarch

%description doc
Documentation for %{name}

%prep
gem unpack %{SOURCE0}

%setup -q -D -T -n  %{gem_name}-%{version}

gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec

# Remove developer-only files.
for f in Gemfile Rakefile script/bootstrap script/cibuild; do
  rm $f
  sed -i "s|\"$f\",||g" %{gem_name}.gemspec
done
rm -r script

# Fix for newer RDoc. https://github.com/github/markup/pull/214
%patch0 -p1

%if 0%{?_regenerate_asciidoc}
  # Regenerate Asciidoc sample to satisfy tests with our particular version of
  # Asciidoctor.
  pushd test/markups
    # Note: In asciidoctor v0.1.3, the asciidoctor command-line
    # utility will write slightly different output than the equivalent library
    # call!
    # https://github.com/github/markup/pull/235
    # https://bugzilla.redhat.com/1047362
    asciidoctor README.asciidoc
  popd
%endif

%if 0%{?_regenerate_lhs}
  # Regenerate lhs sample to satisfy tests with our particular version of
  # rubygem-literati.
  literati test/markups/README.lhs > test/markups/README.lhs.html
%endif

%if 0%{?_regenerate_mediawiki}
  # Regenerate Mediawiki sample to satisfy tests with our particular version of
  # Wikicloth.
  pushd test/markups
    ruby -rwikicloth -e \
    "puts WikiCloth::Parser.new(:data => IO.read('README.mediawiki')).to_html(:noedit => true)" \
    > README.mediawiki.html
  popd
%endif

%if 0%{?_regenerate_pod}
  # Regenerate POD sample to satisfy tests with our particular version of
  # Pod::Simple::HTML.
  perl -MPod::Simple::HTML -e Pod::Simple::HTML::go test/markups/README.pod \
    | sed  '0,/<!-- start doc -->/d' \
    | sed -n '/<!-- end doc -->/q;p' \
    > test/markups/README.pod.html
%endif

%if 0%{?_regenerate_rst}
  # Regenerate rst sample to satisfy tests with our particular version of
  # rest2html.
  rest2html test/markups/README.rst > test/markups/README.rst.html
  rest2html test/markups/README.rst.txt > test/markups/README.rst.txt.html
%endif

# Some of the test data files just don't line up with what we have in Fedora.
# Skip them entirely.
# litcoffee is totally broken, might be broken upstream as well.
# rst and rst.txt require python-creole, which is not in Fedora.
for f in litcoffee rst rst.txt; do
  rm test/markups/README.$f
  sed -i "s|\"test/markups/README.$f\",||g" %{gem_name}.gemspec
done

%build
# Create the gem as gem install only works on a gem file
gem build %{gem_name}.gemspec

%gem_install

# Remove unnecessary gemspec
rm .%{gem_instdir}/%{gem_name}.gemspec

%install
mkdir -p %{buildroot}%{gem_dir}
cp -pa .%{gem_dir}/* \
        %{buildroot}%{gem_dir}/

mkdir -p %{buildroot}%{_bindir}
cp -pa .%{_bindir}/* \
        %{buildroot}%{_bindir}/

find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x

%check
pushd .%{gem_instdir}
  testrb -Ilib test/markup_test.rb
popd

%files
%dir %{gem_instdir}
%doc %{gem_instdir}/README.md
%doc %{gem_instdir}/LICENSE
%{_bindir}/github-markup
%{gem_instdir}/bin
%{gem_libdir}
%exclude %{gem_cache}
%{gem_spec}

%files doc
%doc %{gem_docdir}
%doc %{gem_instdir}/HISTORY.md
%exclude %{gem_instdir}/test

%changelog
* Sat Dec 28 2013 Ken Dreyer <ktdreyer@ktdreyer.com> - 1.0.0-1
- Initial package