Rakefile in Syd-sinatra-0.3.2 vs Rakefile in Syd-sinatra-0.9.0.2

- old
+ new

@@ -6,19 +6,25 @@ # SPECS =============================================================== desc 'Run specs with story style output' task :spec do - sh 'specrb --specdox -Ilib:test test/*_test.rb' + pattern = ENV['TEST'] || '.*' + sh "specrb --testcase '#{pattern}' --specdox -Ilib:test test/*_test.rb" end desc 'Run specs with unit test style output' -task :test => FileList['test/*_test.rb'] do |t| - suite = t.prerequisites.map{|f| "-r#{f.chomp('.rb')}"}.join(' ') - sh "ruby -Ilib:test #{suite} -e ''", :verbose => false +task :test do |t| + sh "specrb -Ilib:test test/*_test.rb" end +desc 'Run compatibility specs' +task :compat do |t| + pattern = ENV['TEST'] || '.*' + sh "specrb --testcase '#{pattern}' -Ilib:test compat/*_test.rb" +end + # PACKAGING ============================================================ # Load the gemspec using the same limitations as github def spec @spec ||= @@ -49,20 +55,26 @@ sh "gem build sinatra.gemspec" mv File.basename(f.name), f.name end file package('.tar.gz') => %w[dist/] + spec.files do |f| - sh "git archive --format=tar HEAD | gzip > #{f.name}" + sh <<-SH + git archive \ + --prefix=sinatra-#{source_version}/ \ + --format=tar \ + HEAD | gzip > #{f.name} + SH end # Rubyforge Release / Publish Tasks ================================== desc 'Publish website to rubyforge' task 'publish:doc' => 'doc/api/index.html' do sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/sinatra/' end +desc 'Publish gem and tarball to rubyforge' task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t| sh <<-end rubyforge add_release sinatra sinatra #{spec.version} #{package('.gem')} && rubyforge add_file sinatra sinatra #{spec.version} #{package('.tar.gz')} end @@ -139,24 +151,36 @@ desc 'Build the Sinatra book' task 'doc:book' => ['book/output/sinatra-book.html'] # Gemspec Helpers ==================================================== -file 'sinatra.gemspec' => FileList['{lib,test,images}/**','Rakefile'] do |f| +def source_version + line = File.read('lib/sinatra/base.rb')[/^\s*VERSION = .*/] + line.match(/.*VERSION = '(.*)'/)[1] +end + +project_files = + FileList[ + '{lib,test,compat,images}/**', + 'Rakefile', 'CHANGES', 'README.rdoc' + ] +file 'sinatra.gemspec' => project_files do |f| # read spec file and split out manifest section spec = File.read(f.name) - parts = spec.split(" # = MANIFEST =\n") - fail 'bad spec' if parts.length != 3 + head, manifest, tail = spec.split(" # = MANIFEST =\n") + # replace version and date + head.sub!(/\.version = '.*'/, ".version = '#{source_version}'") + head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'") # determine file list from git ls-files files = `git ls-files`. split("\n"). sort. reject{ |file| file =~ /^\./ }. reject { |file| file =~ /^doc/ }. map{ |file| " #{file}" }. join("\n") # piece file back together and write... - parts[1] = " s.files = %w[\n#{files}\n ]\n" - spec = parts.join(" # = MANIFEST =\n") + manifest = " s.files = %w[\n#{files}\n ]\n" + spec = [head,manifest,tail].join(" # = MANIFEST =\n") File.open(f.name, 'w') { |io| io.write(spec) } puts "updated #{f.name}" end