1 # rakefile for acts_as_ferret.
2 # use to create a gem or generate rdoc api documentation.
5 # rake release REL=x.y.z
8 require 'rake/rdoctask'
9 require 'rake/packagetask'
10 require 'rake/gempackagetask'
11 require 'rake/testtask'
12 require 'rake/contrib/rubyforgepublisher'
19 PKG_NAME = 'acts_as_ferret'
20 PKG_VERSION = ENV['REL']
21 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
22 RUBYFORGE_PROJECT = 'actsasferret'
23 RUBYFORGE_USER = 'jkraemer'
25 desc 'Default: run unit tests.'
26 task :default => :test
28 desc 'Test the acts_as_ferret plugin.'
29 Rake::TestTask.new(:test) do |t|
31 t.pattern = 'test/**/*_test.rb'
35 desc 'Generate documentation for the acts_as_ferret plugin.'
36 Rake::RDocTask.new(:rdoc) do |rdoc|
37 rdoc.rdoc_dir = 'html'
38 rdoc.title = "acts_as_ferret - Ferret based full text search for any ActiveRecord model"
39 rdoc.options << '--line-numbers' << '--inline-source'
40 rdoc.options << '--main' << 'README'
41 rdoc.rdoc_files.include('README', 'LICENSE')
42 rdoc.template = "#{ENV['template']}.rb" if ENV['template']
43 rdoc.rdoc_files.include('lib/**/*.rb')
46 desc "Publish the API documentation"
47 task :pdoc => [:rdoc] do
48 Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, RUBYFORGE_USER).upload
52 spec = Gem::Specification.new do |s|
54 s.version = PKG_VERSION
55 s.platform = Gem::Platform::RUBY
56 s.summary = "acts_as_ferret - Ferret based full text search for any ActiveRecord model"
57 s.files = Dir.glob('**/*', File::FNM_DOTMATCH).reject do |f|
58 [ /\.$/, /sqlite$/, /\.log$/, /^pkg/, /\.svn/, /\.\w+\.sw.$/,
59 /^html/, /\~$/, /\/\._/, /\/#/ ].any? {|regex| f =~ regex }
61 #s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG)
63 s.require_path = 'lib'
65 s.executables = ["aaf_install"]
66 s.default_executable = "aaf_install"
67 s.autorequire = 'acts_as_ferret'
69 # s.test_files = Dir['test/**/*_test.rb']
70 s.author = "Jens Kraemer"
71 s.email = "jk@jkraemer.net"
72 s.homepage = "http://projects.jkraemer.net/acts_as_ferret"
75 package_task = Rake::GemPackageTask.new(spec) do |pkg|
79 # Validate that everything is ready to go for a release.
82 announce "**************************************************************"
83 announce "* Making RubyGem Release #{PKG_VERSION}"
84 announce "**************************************************************"
86 # Are all source files checked in?
88 announce "Release Task Testing, skipping checked-in file test"
90 announce "Pulling in svn..."
92 announce "Checking for unchecked-in files..."
95 fail "SVK status is not clean ... do you have unchecked-in files?"
97 announce "No outstanding checkins found ... OK"
98 # announce "Pushing to svn..."
104 desc "tag the new release"
105 task :tag => [ :prerelease ] do
106 reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
107 reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
108 announce "Tagging with [#{PKG_VERSION}]"
110 announce "Release Task Testing, skipping tagging"
112 `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}`
113 `svn del -m 'remove old stable' svn://projects.jkraemer.net/acts_as_ferret/tags/stable`
114 `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`
118 # Upload release to rubyforge
119 desc "Upload release to rubyforge"
120 task :prel => [ :tag, :prerelease, :package ] do
122 release_command = "rubyforge add_release #{RUBYFORGE_PROJECT} #{PKG_NAME} '#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.gem"
124 system(release_command)
125 `rubyforge config #{RUBYFORGE_PROJECT}`
126 release_command = "rubyforge add_file #{RUBYFORGE_PROJECT} #{PKG_NAME} '#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.tgz"
128 system(release_command)
131 desc 'Publish the gem and API docs'
132 task :release => [:pdoc, :prel ]