%global	ruby_sitelib	%(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
%global	gemdir		%(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
%global	gemname	rake
%global	geminstdir	%{gemdir}/gems/%{gemname}-%{version}

%global	rubyabi	1.8

Summary:	Ruby based make-like utility
Summary(ja):     Ruby ベースの make のようなユーティリティ
Name:		rubygem-%{gemname}

Version:	0.8.7
Release:        1%{?_dist_release}
Group:		Development/Languages
License:	MIT
URL:		http://rake.rubyforge.org
Source0:	http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem

Requires:	ruby
BuildRequires:	rubygems
BuildRequires:	ruby
BuildArch:	noarch

%description
Rake is a Make-like program implemented in Ruby. Tasks and dependencies are
specified in standard Ruby syntax.

%package	doc
Summary:	Documentation for %{name}
Group:		Documentation
# Directory ownership issue
Requires:	%{name} = %{version}-%{release}

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


%prep
%setup -q -c -T

%build
mkdir -p .%{gemdir}
gem install -V \
	--local \
	--install-dir $(pwd)/%{gemdir} \
	--force \
	--rdoc \
	%{SOURCE0}

%install
mkdir -p %{buildroot}%{gemdir}
cp -a .%{gemdir}/* %{buildroot}%{gemdir}
mkdir -p %{buildroot}%{_bindir}
ln -sf %{gemdir}/bin/rake %{buildroot}/%{_bindir}/rake

# rpmlint issue
find %{buildroot}%{geminstdir}/{lib,test} -type f | \
	xargs sed -i -e '\@^#!/usr.*ruby@d'
find %{buildroot}%{geminstdir}/{doc,lib,test} -type f | xargs chmod 0644

%files
%defattr(-,root,root,-)
%{_bindir}/rake
%dir %{geminstdir}
%doc %{geminstdir}/MIT-LICENSE
%doc %{geminstdir}/TODO
%doc %{geminstdir}/CHANGES
%{gemdir}/bin
%{geminstdir}/bin
%{geminstdir}/lib
%{gemdir}/cache/%{gemname}-%{version}.gem
%{gemdir}/specifications/%{gemname}-%{version}.gemspec

%files	doc
%defattr(-,root,root,-)
%{geminstdir}/Rakefile
%{geminstdir}/install.rb
%{geminstdir}/doc
%{geminstdir}/test/
%{gemdir}/doc/%{gemname}-%{version}/


%changelog
* Thu May 12 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 0.8.7-1
- initial build for Vine Linux
