begin require 'rubygems' rescue LoadError nil # optional end $:.unshift('lib') require 'rake/gempackagetask' require 'rake/contrib/rubyforgepublisher' require 'rake/clean' require 'rake/testtask' require 'rake/rdoctask' require 'dokkit/render_task_factory' PKG_NAME = "dokkit-model-simpledocument" PKG_VERSION = "0.1.0" PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_FILES = FileList.new( ['lib/**/*', 'model/**/*', '[A-Z]*'] ) do |fl| fl.exclude(/TEMPLATE\./).to_a end task :default => [:gem] # Create a task that will package the dokkit model into distributable # tar, zip and gem files. spec = Gem::Specification.new do |s| # Basic information. s.name = PKG_NAME s.version = PKG_VERSION s.summary = "dokkit simple document model" s.description = <<-EOF This is a simple document model for dokkit. You can use this model as a base to create simple documents like tutorials, howtos, guides, technical reports. EOF s.files = PKG_FILES.to_a s.require_path = 'lib' s.autorequire = 'dokkit' s.add_dependency('dokkit', '>= 0.2.0') #### Documentation and testing. #### Author and project details. s.author = "Andrea Fazzi" s.email = "andrea.fazzi@alca.le.it" s.homepage = "http://dokkit.rubyforge.org/" s.rubyforge_project = "dokkit" end desc "Build Gem" Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = true pkg.need_tar = true end # Support Tasks ------------------------------------------------------ desc "Look for TODO and FIXME tags in the code" task :todo do Pathname.new(File.dirname(__FILE__)).egrep(/#.*(FIXME|TODO|TBD|DEPRECATED)/) do |match| puts match end end task :release => [:verify_env_vars, :release_files, :publish_doc, :publish_news] task :verify_env_vars do raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER'] raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD'] end desc "Release files on RubyForge" task :release_files => [:gem] do require 'meta_project' require 'rake/contrib/xforge' release_files = FileList[ "pkg/#{PKG_FILE_NAME}.gem" ] Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('dokkit')) do |release| # Never hardcode user name and password in the Rakefile! release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = "#{PKG_NAME} #{PKG_VERSION}" # The rest of the options are defaults (among others, release_notes and release_changes, parsed from CHANGES) end end desc "Publish news on RubyForge" task :publish_news => [:gem] do require 'rake/meta_project' require 'rake/contrib/xforge' release_files = FileList[ "pkg/#{PKG_FILE_NAME}.gem" ] Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new('dokkit')) do |news| # Never hardcode user name and password in the Rakefile! news.user_name = ENV['RUBYFORGE_USER'] news.password = ENV['RUBYFORGE_PASSWORD'] end end desc "Delete output and intermediate files" task :clean_output do OUTPUT_FL.each { |file| sh "rm -rf #{file}"} end factory = Dokkit::RenderTaskFactory.instance factory.create_render_text(:render_readme) do |task| task.output_dir = 'lib/model/' task.layout_dir = 'lib/doc/layouts' task.config_dir = 'lib/model/doc/config' task.pages.dir = 'lib/model/doc/pages' end desc "Generate README file from a deplate source" task :readme => [:render_readme] do File.move('lib/model/simpledocument.text', 'lib/model/README') end desc "Tag the working tree and copy it to dokkit-models/simpledocument/tags/REL_X_Y_Z on RubyForge" task :tag do reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}" puts "Tagging current head with [#{reltag}]" sh "svn copy ./ svn+ssh://#{ENV['RUBYFORGE_USER']}@rubyforge.org/var/svn/dokkit/dokkit-models/simpledocument/tags/#{reltag}/ -m \"tag #{reltag}\"" if ENV['RUBYFORGE_USER'] end