%global gem_name pdf-reader
Name:                rubygem-%{gem_name}
Version:             2.1.0
Release:             1
Summary:             A library for accessing the content of PDF files
License:             MIT
URL:                 https://github.com/yob/pdf-reader
Source0:             https://rubygems.org/gems/pdf-reader-%{version}.gem
Source1:             pdf-reader-%{version}-spec.tgz
BuildRequires:       ruby(release) rubygems-devel ruby >= 1.9.3 rubygem(Ascii85) rubygem(afm)
BuildRequires:       rubygem(hashery) rubygem(rspec) rubygem(ruby-rc4) rubygem(ttfunk)
BuildArch:           noarch
%description
The PDF::Reader library implements a PDF parser conforming as much as possible
to the PDF specification from Adobe.

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

%prep
gem unpack %{SOURCE0}
%setup -q -D -T -n  %{gem_name}-%{version} -b 1
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec

%build
gem build %{gem_name}.gemspec
%gem_install

%install
mkdir -p %{buildroot}%{gem_dir}
cp -a .%{gem_dir}/* \
        %{buildroot}%{gem_dir}/
mkdir -p %{buildroot}%{_bindir}
cp -a .%{_bindir}/* \
        %{buildroot}%{_bindir}/
find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x
chmod a+x %{buildroot}%{gem_instdir}/examples/*.rb

%check
pushd .%{gem_instdir}
ln -s %{_builddir}/spec spec
sed -i '/require.*bundler/ s/^/#/' spec/spec_helper.rb
sed -i '/Bundler.setup/ s/^/#/' spec/spec_helper.rb
rspec -r spec_helper spec
popd

%files
%dir %{gem_instdir}
%{_bindir}/pdf_*
%license %{gem_instdir}/MIT-LICENSE
%{gem_instdir}/bin
%{gem_libdir}
%exclude %{gem_cache}
%{gem_spec}

%files doc
%doc %{gem_docdir}
%doc %{gem_instdir}/TODO
%doc %{gem_instdir}/CHANGELOG
%doc %{gem_instdir}/README.md
%{gem_instdir}/Rakefile
%{gem_instdir}/examples

%changelog
* Wed Aug 5 2020 wangchong <wangchong56@huawei.com> - 2.1.0-1
- package init
