Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Clean up the retarded Rakefile, use the Bundler gem helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Oct 16, 2010
1 parent f0ebe8c commit 0dd7343
Showing 1 changed file with 53 additions and 87 deletions.
140 changes: 53 additions & 87 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# -*- encoding: utf-8 -*-
$:.unshift File.expand_path("../lib", __FILE__)

require 'rubygems'
require 'rubygems/specification'
require 'bundler'

def gemspec
@gemspec ||= begin
file = File.expand_path('../bundler.gemspec', __FILE__)
eval(File.read(file), binding, file)
end
end
require 'bundler/gem_helper'
Bundler::GemHelper.install_tasks

def sudo?
ENV['BUNDLER_SUDO_TESTS']
Expand All @@ -32,7 +23,7 @@ begin
task :spec => :build

namespace :spec do
task :sudo do
task :set_sudo do
ENV['BUNDLER_SUDO_TESTS'] = '1'
end

Expand All @@ -44,52 +35,58 @@ begin
end
end

desc "Run the full spec suite including SUDO tests"
task :full => ["sudo", "clean", "spec"]
end

# Rubygems 1.3.5, 1.3.6, and HEAD specs
rubyopt = ENV["RUBYOPT"]
%w(master REL_1_3_5 REL_1_3_6).each do |rg|
desc "Run specs with Rubygems #{rg}"
RSpec::Core::RakeTask.new("spec_gems_#{rg}") do |t|
t.rspec_opts = %w(-fs --color)
t.ruby_opts = %w(-w)
end

task "rubygems_#{rg}" do
unless File.directory?("tmp/rubygems_#{rg}")
system("git clone git://github.com/jbarnette/rubygems.git tmp/rubygems_#{rg} && cd tmp/rubygems_#{rg} && git reset --hard #{rg}")
desc "Run the spec suite with the sudo tests"
task :sudo => ["set_sudo", "clean", "spec"]

namespace :rubygems do
# Rubygems 1.3.5, 1.3.6, and HEAD specs
rubyopt = ENV["RUBYOPT"]
%w(master REL_1_3_5 REL_1_3_6).each do |rg|
desc "Run specs with Rubygems #{rg}"
RSpec::Core::RakeTask.new(rg) do |t|
t.rspec_opts = %w(-fs --color)
t.ruby_opts = %w(-w)
end

task "clone_rubygems_#{rg}" do
unless File.directory?("tmp/rubygems_#{rg}")
system("git clone git://github.com/jbarnette/rubygems.git tmp/rubygems_#{rg} && cd tmp/rubygems_#{rg} && git reset --hard #{rg}")
end
ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems_#{rg}/lib")} #{rubyopt}"
end

task rg => "clone_rubygems_#{rg}"
task "rubygems:all" => rg
end
ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems_#{rg}/lib")} #{rubyopt}"
end

task "spec_gems_#{rg}" => "rubygems_#{rg}"
task :ci => "spec_gems_#{rg}"
end
namespace :ruby do
# Ruby 1.8.6, 1.8.7, and 1.9.2 specs
task "ensure_rvm" do
raise "RVM is not available" unless File.exist?(File.expand_path("~/.rvm/scripts/rvm"))
end

# Ruby 1.8.6, 1.8.7, and 1.9.2 specs
task "ensure_rvm" do
raise "RVM is not available" unless File.exist?(File.expand_path("~/.rvm/scripts/rvm"))
end
%w(1.8.6-p399 1.8.7-p302 1.9.2-p0).each do |ruby|
ruby_cmd = File.expand_path("~/.rvm/bin/ruby-#{ruby}")

%w(1.8.6-p399 1.8.7-p249 1.9.2-head).each do |ruby|
ruby_cmd = File.expand_path("~/.rvm/bin/ruby-#{ruby}")
desc "Run specs on Ruby #{ruby}"
RSpec::Core::RakeTask.new(ruby) do |t|
t.rspec_opts = %w(-fs --color)
t.ruby_opts = %w(-w)
end

desc "Run specs on Ruby #{ruby}"
RSpec::Core::RakeTask.new("spec_ruby_#{ruby}") do |t|
t.rspec_opts = %w(-fs --color)
t.ruby_opts = %w(-w)
end
task "ensure_ruby_#{ruby}" do
raise "Could not find Ruby #{ruby} at #{ruby_cmd}" unless File.exist?(ruby_cmd)
end

task "ensure_ruby_#{ruby}" do
raise "Could not find Ruby #{ruby} at #{ruby_cmd}" unless File.exist?(ruby_cmd)
task "ensure_ruby_#{ruby}" => "ensure_rvm"
task ruby => "ensure_ruby_#{ruby}"
task "ruby:all" => ruby
end
end

task "ensure_ruby_#{ruby}" => "ensure_rvm"
task "spec_ruby_#{ruby}" => "ensure_ruby_#{ruby}"
task :ci => "spec_ruby_#{ruby}"
end

rescue LoadError
task :spec do
abort "Run `gem install rspec --pre` to be able to run specs"
Expand All @@ -111,16 +108,16 @@ namespace :man do
sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
end

task :build => "#{roff}.txt"
task :build_pages => "#{roff}.txt"
end
end

desc "Build the man pages"
task :build => "man:build"
desc "Build the man pages"
task :build => "man:build_pages"

desc "Clean up from the built man pages"
task :clean do
rm_rf "lib/bundler/man"
desc "Clean up from the built man pages"
task :clean do
rm_rf "lib/bundler/man"
end
end

namespace :vendor do
Expand All @@ -137,37 +134,6 @@ namespace :vendor do
end
end

begin
require 'rake/gempackagetask'
rescue LoadError
task(:gem) { $stderr.puts '`gem install rake` to package gems' }
else
Rake::GemPackageTask.new(gemspec) do |pkg|
pkg.gem_spec = gemspec
end
task :gem => [:build, :gemspec]
end

desc "install the gem locally"
task :install => :package do
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
end

desc "validate the gemspec"
task :gemspec do
gemspec.validate
end

desc "Build the gem"
task :gem => [:gemspec, :build] do
mkdir_p "pkg"
sh "gem build bundler.gemspec"
mv "#{gemspec.full_name}.gem", "pkg"
end

desc "Install bundler"
task :install => :gem do
sh "gem install pkg/#{gemspec.full_name}.gem"
end
task :build => "man:build"

task :default => :spec

0 comments on commit 0dd7343

Please sign in to comment.