# rakefile for acts_as_ferret. # use to create a gem or generate rdoc api documentation. # # RELEASE creation: # rake release REL=x.y.z require 'pathname' require 'yaml' 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 # FIXME 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.dup s.platform = Gem::Platform::RUBY s.rubyforge_project = 'acts_as_ferret' s.summary = "acts_as_ferret - Ferret based full text search for any ActiveRecord model" s.description = "Rails plugin that adds powerful full text search capabilities to ActiveRecord models." s.files = Dir.glob('**/*', File::FNM_DOTMATCH).reject do |f| [ /\.$/, /sqlite$/, /\.log$/, /^pkg/, /\.svn/, /\.git/, /\.\w+\.sw.$/, /^html/, /\~$/, /\/\._/, /\/#/, /\._/, /tmp\// ].any? {|regex| f =~ regex } end #s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG) s.add_dependency 'ferret' 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://github.com/jkraemer/acts_as_ferret" end desc "Update the gemspec for GitHub's gem server" task :gemspec do Pathname("#{spec.name}.gemspec").open('w') {|f| f << YAML.dump(spec) } end desc 'build the gem' task :package => :gemspec do `gem build acts_as_ferret.gemspec` `mv #{PKG_FILE_NAME}.gem pkg/#{PKG_FILE_NAME}.gem` end desc 'publish to rubygems.org' task :push => [ :package, :tag ] do if ENV['RELTEST'] announce "Release Task Testing, not pushing to rubygems.org" else `gem push pkg/#{PKG_FILE_NAME}.gem` end end desc "tag the new release" task :tag do reltag = "rel_#{PKG_VERSION.gsub(/\./, '_')}" announce "Tagging with [#{PKG_VERSION}]" if ENV['RELTEST'] announce "Release Task Testing, skipping tagging" else `git tag -m 'tagging release #{reltag}' -s #{reltag} HEAD` `git tag -d stable` `git tag -m 'tagging HEAD as stable' -s stable HEAD` end end desc 'Publish the gem and API docs' task :release => [:pdoc, :push ] end