# rakefile for acts_as_ferret. # use to create a gem or generate rdoc api documentation. # # RELEASE creation: # rake release REL=x.y.z require 'rake' require 'rake/rdoctask' require 'rake/packagetask' require 'rake/gempackagetask' require 'rake/testtask' require 'rake/contrib/rubyforgepublisher' def announce(msg='') STDERR.puts msg end PKG_NAME = 'acts_as_ferret' PKG_VERSION = ENV['REL'] PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" RUBYFORGE_PROJECT = 'actsasferret' RUBYFORGE_USER = 'jkraemer' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_ferret plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_ferret plugin.' Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'html' rdoc.title = "acts_as_ferret - Ferret based full text search for any ActiveRecord model" rdoc.options << '--line-numbers' << '--inline-source' rdoc.options << '--main' << 'README' rdoc.rdoc_files.include('README', 'LICENSE') rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.rdoc_files.include('lib/**/*.rb') end desc "Publish the API documentation" task :pdoc => [:rdoc] do Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, RUBYFORGE_USER).upload end if PKG_VERSION spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.platform = Gem::Platform::RUBY s.summary = "acts_as_ferret - Ferret based full text search for any ActiveRecord model" s.files = Dir.glob('**/*', File::FNM_DOTMATCH).reject do |f| [ /\.$/, /sqlite$/, /\.log$/, /^pkg/, /\.svn/, /\.\w+\.sw.$/, /^html/, /\~$/, /\/\._/, /\/#/ ].any? {|regex| f =~ regex } end #s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG) # s.files.delete ... s.require_path = 'lib' s.bindir = "bin" s.executables = ["aaf_install"] s.default_executable = "aaf_install" s.autorequire = 'acts_as_ferret' s.has_rdoc = true # s.test_files = Dir['test/**/*_test.rb'] s.author = "Jens Kraemer" s.email = "jk@jkraemer.net" s.homepage = "http://projects.jkraemer.net/acts_as_ferret" end package_task = Rake::GemPackageTask.new(spec) do |pkg| pkg.need_tar = true end # Validate that everything is ready to go for a release. task :prerelease do announce announce "**************************************************************" announce "* Making RubyGem Release #{PKG_VERSION}" announce "**************************************************************" announce # Are all source files checked in? if ENV['RELTEST'] announce "Release Task Testing, skipping checked-in file test" else announce "Pulling in svn..." `svk pull .` announce "Checking for unchecked-in files..." data = `svk st` unless data =~ /^$/ fail "SVK status is not clean ... do you have unchecked-in files?" end announce "No outstanding checkins found ... OK" # announce "Pushing to svn..." # `svk push .` end end desc "tag the new release" task :tag => [ :prerelease ] do reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}" reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE'] announce "Tagging with [#{PKG_VERSION}]" if ENV['RELTEST'] announce "Release Task Testing, skipping tagging" else `svn copy -m 'tagging version #{PKG_VERSION}' svn://projects.jkraemer.net/acts_as_ferret/trunk/plugin svn://projects.jkraemer.net/acts_as_ferret/tags/#{PKG_VERSION}` `svn del -m 'remove old stable' svn://projects.jkraemer.net/acts_as_ferret/tags/stable` `svn copy -m 'tagging version #{PKG_VERSION} as stable' svn://projects.jkraemer.net/acts_as_ferret/tags/#{PKG_VERSION} svn://projects.jkraemer.net/acts_as_ferret/tags/stable` end end # Upload release to rubyforge desc "Upload release to rubyforge" task :prel => [ :tag, :prerelease, :package ] do `rubyforge login` release_command = "rubyforge add_release #{RUBYFORGE_PROJECT} #{PKG_NAME} '#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.gem" puts release_command system(release_command) `rubyforge config #{RUBYFORGE_PROJECT}` release_command = "rubyforge add_file #{RUBYFORGE_PROJECT} #{PKG_NAME} '#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.tgz" puts release_command system(release_command) end desc 'Publish the gem and API docs' task :release => [:pdoc, :prel ] end