# Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
%define rbname <%= spec.name %>
%define version <%= spec.version %>
%define release 1

Summary: <%= spec.summary %>
Name: ruby-gems-%{rbname}

Version: %{version}
Release: %{release}
Group: Development/Ruby
License: Distributable
URL: <%= spec.homepage %>
Source0: %{rbname}-%{version}.gem
# Make sure the spec template is included in the SRPM
Source1: ruby-gems-%{rbname}.spec.in
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: ruby <%= spec.required_ruby_version %>
Requires: ruby-gems >= <%= Gem::RubyGemsVersion %>
<% for d in spec.dependencies -%>
<% for req in d.requirement -%>
Requires: ruby-gems-<%= d.name %> <%= req %>
<% end -%>
<% end -%>
BuildRequires: ruby <%= spec.required_ruby_version %>
BuildRequires: ruby-gems >= <%= Gem::RubyGemsVersion %>
BuildArch: noarch
Provides: ruby(<%= spec.name.capitalize %>) = %{version}

%define gemdir <%= Gem.dir %>
%define gembuilddir %{buildroot}%{gemdir}

%description
<%= spec.description %>

%prep
%setup -T -c

%build

%install
%{__rm} -rf %{buildroot}
mkdir -p %{gembuilddir}
gem install --local --install-dir %{gembuilddir} --force %{SOURCE0}
<% if ! spec.executables.empty? -%>
mkdir -p %{buildroot}/%{_bindir}
mv %{gembuilddir}/bin/* %{buildroot}/%{_bindir}
rmdir %{gembuilddir}/bin
<% end -%>

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root)
<% for f in spec.executables -%>
%{_bindir}/<%= f %>
<% end -%>
<% package.spec.files.each do |entry, data| -%>
<%   path = entry['path'] -%>
<%   doc_prefix = spec.extra_rdoc_files.include?(path) ? "%doc " : "" -%>
<%= doc_prefix %>%{gemdir}/gems/<%= spec.name %>-<%= spec.version %>/<%= path %>
<% end %>

%doc %{gemdir}/doc/<%= spec.name %>-<%= spec.version %>
%{gemdir}/cache/<%= package.spec.file_name %>
%{gemdir}/specifications/<%= package.spec.file_name %>spec

%changelog
