%define gem_name <%= pkg.name %>

Summary: <%= pkg.summary %>
Name: <%= pkg.name %>
Version: <%= pkg.version %>
Release: 1
Source0: %{name}-%{version}.tar.gz
License: <%= pkg.license %>
Group: Development/Tools
Prefix: %{_prefix}
Vendor: <%= pkg.authors.first %> <<%= pkg.email.first %>>
Url: <%= pkg.homepage %>
BuildArch: noarch
BuildRequires: ruby, rubygems-devel, rubygem-rake, rubygem-bundler
Requires: ruby, rubygem-rake

%description
<%= pkg.description %>

%prep
%setup -n %{name}-%{version}

%build

%{__rm} -rf %{buildroot}
sed -i -e 's#spec.files\s*=.*#spec.files = Dir.glob("**/*")#' %{name}.gemspec
rake bundler:build
%gem_install -n pkg/%{name}-%{version}.gem

%install
cp -a usr %{buildroot}/usr

%clean
rm -rf $RPM_BUILD_ROOT

%files
%{gem_instdir}/
%exclude %{gem_cache}
%{gem_spec}
%{_bindir}/chake
%doc %{gem_docdir}
