summaryrefslogtreecommitdiffstats
path: root/rubygem-yajl-ruby.spec
blob: f275c47bb194f1a745c49450ec6466d734054107 (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
%global gem_name yajl-ruby

# EPEL6 lacks rubygems-devel package that provides these macros
%if %{?el6}0
%global gem_dir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
%global gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}
%global gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}
%global gem_libdir %{gem_instdir}/lib
%global gem_cache %{gem_dir}/cache/%{gem_name}-%{version}.gem
%global gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}.gemspec
%global ruby_sitearch %(ruby -rrbconfig -e 'puts Config::CONFIG["sitearchdir"]')
%endif

Summary: Ruby C bindings to the excellent Yajl JSON stream-based parser library
Name: rubygem-%{gem_name}
Version: 1.1.0
Release: 2%{?dist}
Group: Development/Languages
License: MIT
URL: https://github.com/brianmario/yajl-ruby
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
%if %{?el6}0
Requires: ruby(abi) = 1.8
%else
Requires: ruby
%endif
Requires: ruby(rubygems)
BuildRequires: ruby-devel
%{?el6:BuildRequires: ruby(abi) = 1.8}
%{!?el6:BuildRequires: rubygem(rspec)}
%{!?el6:BuildRequires: rubygems-devel}
Provides: rubygem(%{gem_name}) = %{version}

%description
Ruby C bindings to the excellent Yajl JSON stream-based parser library

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

%description doc
This package contains documentation for %{name}

%prep
gem unpack %{SOURCE0}

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

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

%build
gem build %{gem_name}.gemspec

%if 0%{?el6}
mkdir -p .%{gem_dir}
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
gem install --local \
  --install-dir $(pwd)%{gem_dir} \
  -V \
  --force --rdoc \
  %{gem_name}-%{version}.gem
%else
%gem_install
%endif


%install
mkdir -p %{buildroot}%{gem_dir}
cp -a .%{gem_dir}/* \
        %{buildroot}%{gem_dir}/
# Remove the binary extension sources and build leftovers.
rm -rf %{buildroot}%{gem_instdir}/ext
# Remove other cruft from the gem
rm %{buildroot}%{gem_instdir}/.gitignore \
   %{buildroot}%{gem_instdir}/.travis.yml
%if 0%{?el6}
  # %%{gem_extdir_mri} doesn't really work on EL 6
  mkdir -p %{buildroot}%{ruby_sitearch}/yajl
  # move the extension to ruby_sitearch
  mv %{buildroot}%{gem_libdir}/yajl/yajl.so %{buildroot}%{ruby_sitearch}/yajl
%else
  install -d -m0755 %{buildroot}%{gem_extdir_mri}/lib/yajl
  # move the extension to gem_extdir_mri
  mv %{buildroot}%{gem_libdir}/yajl/yajl.so %{buildroot}%{gem_extdir_mri}/lib/yajl
%endif

# Fix permissions
# https://github.com/brianmario/yajl-ruby/issues/103
chmod -x %{buildroot}%{gem_instdir}/benchmark/subjects/unicode.json

%check
%if %{?el6}0
# spec on EL6 is too old; need RSpec2
%else
pushd .%{gem_instdir}
rspec
popd
%endif

%files
%doc %{gem_instdir}/MIT-LICENSE
%dir %{gem_instdir}
%if 0%{?el6}
%{ruby_sitearch}/yajl/yajl.so
%else
%{gem_extdir_mri}/*
%endif
%{gem_libdir}
%{gem_spec}
# https://github.com/brianmario/yajl-ruby/issues/103
%exclude %{gem_instdir}/.rspec
%exclude %{gem_cache}

%files doc
%doc %{gem_docdir}
%{gem_instdir}/Gemfile
%{gem_instdir}/Rakefile
%{gem_instdir}/benchmark
%{gem_instdir}/examples
%{gem_instdir}/spec
%{gem_instdir}/tasks
%{gem_instdir}/CHANGELOG.md
%{gem_instdir}/README.md
%{gem_instdir}/%{gem_name}.gemspec

%changelog
* Tue Dec 25 2012 Julian C. Dunn <jdunn@aquezada.com> - 1.1.0-2
- Unify EPEL and Fedora builds. Correct defects from review, bz#823351

* Mon Apr 30 2012  <rpms@courteau.org> - 1.1.0-1
- Initial package