summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2007-12-05 14:43:26 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2007-12-05 14:43:26 +0100
commitaac404414f5414d402482baa69b641a03b424251 (patch)
tree47f1776948b63f3030b96ae04b7f4d627943e44e
parent190bdcaf1b3ee1eb7704bd2f40754e9523d7dddb (diff)
downloadbacon-aac404414f5414d402482baa69b641a03b424251.tar.gz
bacon-aac404414f5414d402482baa69b641a03b424251.tar.xz
bacon-aac404414f5414d402482baa69b641a03b424251.zip
Add Rakefile
darcs-hash:20071205134326-4fc50-9e879883f22b9ff53943ab693c43266c0d1bc0e7.gz
-rw-r--r--Rakefile133
1 files changed, 133 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..8291340
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,133 @@
+# Rakefile for Bacon.  -*-ruby-*-
+require 'rake/rdoctask'
+require 'rake/testtask'
+
+
+desc "Run all the tests"
+task :default => [:test]
+
+desc "Do predistribution stuff"
+task :predist => [:chmod, :changelog, :rdoc]
+
+
+desc "Make an archive as .tar.gz"
+task :dist => :fulltest do
+  sh "export DARCS_REPO=#{File.expand_path "."}; " +
+     "darcs dist -d bacon-#{get_darcs_tree_version}"
+end
+
+# Helper to retrieve the "revision number" of the darcs tree.
+def get_darcs_tree_version
+  unless File.directory? "_darcs"
+    $: << "lib"
+    require 'bacon'
+    return Bacon::VERSION
+  end
+
+  changes = `darcs changes`
+  count = 0
+  tag = "0.0"
+
+  changes.each("\n\n") { |change|
+    head, title, desc = change.split("\n", 3)
+
+    if title =~ /^  \*/
+      # Normal change.
+      count += 1
+    elsif title =~ /tagged (.*)/
+      # Tag.  We look for these.
+      tag = $1
+      break
+    else
+      warn "Unparsable change: #{change}"
+    end
+  }
+
+  tag + "." + count.to_s
+end
+
+def manifest
+  `darcs query manifest`.split("\n").map { |f| f.gsub(/\A\.\//, '') }
+end
+
+
+desc "Make binaries executable"
+task :chmod do
+  Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
+end
+
+desc "Generate a ChangeLog"
+task :changelog do
+  sh "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
+end
+
+
+desc "Generate RDox"
+task "RDOX" do
+  sh "bin/bacon -Ilib --automatic --specdox >RDOX"
+end
+
+desc "Run all the fast tests"
+task :test do
+  sh "bin/bacon -Ilib --automatic --quiet"
+end
+
+
+begin
+  $" << "sources"  if defined? FromSrc
+  require 'rubygems'
+
+  require 'rake'
+  require 'rake/clean'
+  require 'rake/packagetask'
+  require 'rake/gempackagetask'
+  require 'fileutils'
+rescue LoadError
+  # Too bad.
+else
+  spec = Gem::Specification.new do |s|
+    s.name            = "rack"
+    s.version         = get_darcs_tree_version
+    s.platform        = Gem::Platform::RUBY
+    s.summary         = "a small RSpec clone"
+
+    s.description = <<-EOF
+Bacon is a small RSpec clone weighing less than 300 LoC but
+nevertheless providing all essential features.
+
+http://chneukirchen.org/repos/bacon
+    EOF
+
+    s.files           = manifest + %w(RDOX)
+    s.bindir          = 'bin'
+    s.executables     << 'bacon'
+    s.require_path    = 'lib'
+    s.has_rdoc        = true
+    s.extra_rdoc_files = ['README', 'RDOX']
+    s.test_files      = []
+
+    s.author          = 'Christian Neukirchen'
+    s.email           = 'chneukirchen@gmail.com'
+    s.homepage        = 'http://chneukirchen.org/repos/bacon'
+  end
+
+  Rake::GemPackageTask.new(spec) do |p|
+    p.gem_spec = spec
+    p.need_tar = false
+    p.need_zip = false
+  end
+end
+
+desc "Generate RDoc documentation"
+Rake::RDocTask.new(:rdoc) do |rdoc|
+  rdoc.options << '--line-numbers' << '--inline-source' <<
+    '--main' << 'README' <<
+    '--title' << 'Rack Documentation' <<
+    '--charset' << 'utf-8'
+  rdoc.rdoc_dir = "doc"
+  rdoc.rdoc_files.include 'README'
+  rdoc.rdoc_files.include 'COPYING'
+  rdoc.rdoc_files.include 'RDOX'
+  rdoc.rdoc_files.include('lib/bacon.rb')
+end
+task :rdoc => ["RDOX"]