From f8fcd2ed8d42cbb1f8f1317a0a6269a8435d0520 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Sun, 30 Nov 2008 11:13:33 +0100 Subject: Last fixes --- README | 1 + Rakefile | 69 +++++++++++++++++++++++++++++------------------------- test/spec_bacon.rb | 2 +- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/README b/README index 0f6e8b0..17f6f67 100644 --- a/README +++ b/README @@ -6,6 +6,7 @@ Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. + == Whirl-wind tour require 'bacon' diff --git a/Rakefile b/Rakefile index 8c0bea2..b4b6594 100644 --- a/Rakefile +++ b/Rakefile @@ -11,43 +11,35 @@ task :predist => [:chmod, :changelog, :rdoc] desc "Make an archive as .tar.gz" -task :dist => :test do - sh "export DARCS_REPO=#{File.expand_path "."}; " + - "darcs dist -d bacon-#{get_darcs_tree_version}" +task :dist => [:test, :predist] do + sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar" + sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX ChangeLog doc" + sh "gzip -f -9 #{release}.tar" end -# Helper to retrieve the "revision number" of the darcs tree. -def get_darcs_tree_version - unless File.directory? "_darcs" +# Helper to retrieve the "revision number" of the git tree. +def git_tree_version + if File.directory?(".git") + @tree_version ||= `git describe`.strip.sub('-', '.') + @tree_version << ".0" unless @tree_version.count('.') == 2 + else $: << "lib" require 'bacon' - return Bacon::VERSION + @tree_version = Bacon::VERSION end + @tree_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 - } +def gem_version + git_tree_version.gsub(/-.*/, '') +end - tag + "." + count.to_s +def release + "bacon-#{git_tree_version}" end def manifest - `darcs query manifest 2>/dev/null`.split("\n").map { |f| f.gsub(/\A\.\//, '') } + `git ls-files`.split("\n") - [".gitignore"] end @@ -58,7 +50,20 @@ end desc "Generate a ChangeLog" task :changelog do - sh "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog" + File.open("ChangeLog", "w") { |out| + `git log -z`.split("\0").map { |chunk| + author = chunk[/Author: (.*)/, 1].strip + date = chunk[/Date: (.*)/, 1].strip + desc, detail = $'.strip.split("\n", 2) + detail ||= "" + detail = detail.gsub(/.*darcs-hash:.*/, '') + detail.rstrip! + out.puts "#{date} #{author}" + out.puts " * #{desc.strip}" + out.puts detail unless detail.empty? + out.puts + } + } end @@ -67,7 +72,7 @@ task "RDOX" do sh "bin/bacon -Ilib --automatic --specdox >RDOX" end -desc "Run all the fast tests" +desc "Run all the tests" task :test do ruby "bin/bacon -Ilib --automatic --quiet" end @@ -87,7 +92,7 @@ rescue LoadError else spec = Gem::Specification.new do |s| s.name = "bacon" - s.version = get_darcs_tree_version + s.version = gem_version s.platform = Gem::Platform::RUBY s.summary = "a small RSpec clone" @@ -95,10 +100,10 @@ else Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. -http://chneukirchen.org/repos/bacon +http://github.com/chneukirchen/bacon EOF - s.files = manifest + %w(RDOX) + s.files = manifest + %w(RDOX ChangeLog) s.bindir = 'bin' s.executables << 'bacon' s.require_path = 'lib' diff --git a/test/spec_bacon.rb b/test/spec_bacon.rb index a0eeffd..2d068bc 100644 --- a/test/spec_bacon.rb +++ b/test/spec_bacon.rb @@ -32,7 +32,7 @@ describe "Bacon" do lambda { should.satisfy { 1 == 1 } }.should succeed lambda { should.satisfy { 1 } }.should succeed - lambda { should.satisfy { 1 == 2 } }.should fail + lambda { should.satisfy { 1 != 1 } }.should fail lambda { should.satisfy { false } }.should fail lambda { should.satisfy { false } }.should fail -- cgit 1.4.1