require 'rubygems' require 'rake' require 'rake/clean' require 'rake/testtask' require 'rake/packagetask' require 'rake/gempackagetask' require 'rake/rdoctask' require 'rake/contrib/rubyforgepublisher' require 'fileutils' require 'lib/sprout/version' AUTHOR = "Luke Bayes" EMAIL = "lbayes@patternpark.com" HOMEPAGE = "http://www.patternpark.com" DESCRIPTION = "Sprouts take the tedium and frustration out of creating new programming projects by automatically installing and configuring external tools, libraries and build tasks." GEM_NAME = "sprout" RUBYFORGE_PROJECT = "sprout" HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" SUMMARY = "Sprouts is an open-source, cross-platform project generation and configuration tool." NAME = "sprout" RELEASE_TYPES = ["gem"] REV = nil VERS = (Sprout::VERSION::STRING + (REV ? ".#{REV}" : "")) CLEAN.include(['**/.*.sw?', '*.gem', 'pkg/*', 'pkg', 'test/user_home/osx/Library/Sprouts/cache/asunit3-library', 'test/user_home/osx/Library/Sprouts/cache/demo-library', 'test/user_home/osx/Library/Sprouts/cache/demo-tool', 'test/user_home/osx/Library/Sprouts/cache/demo-task', 'test/project/lib' ]) RDOC_OPTS = ['--quiet', '--title', 'sprout documentation', '--opname', 'index.html', '--line-numbers', '--main', 'README', '--inline-source'] Rake::TestTask.new('test') do |t| t.pattern = 'test/**/*_test.rb' t.warning = true end PKG_LIST = FileList['[a-zA-Z]*', 'bin/**/*', 'lib/**/*' ] PKG_LIST.exclude('.svn') PKG_LIST.each do |file| task :package => file end task :package => [:increment_revision] spec = Gem::Specification.new do |s| s.name = NAME s.version = VERS s.summary = SUMMARY s.description = DESCRIPTION s.add_dependency('rake', '>= 0.7.1') s.add_dependency('rubyzip', '>= 0.9.1') s.add_dependency('archive-tar-minitar', '>= 0.5.1') s.rdoc_options << '--exclude' << '.' s.has_rdoc = false s.files = PKG_LIST.to_a.delete_if {|f| f.include?('.svn')} s.require_path = 'lib' s.bindir = 'bin' # Use these for applications. s.executables = ['sprout'] s.default_executable = 'sprout' s.author = AUTHOR s.email = EMAIL s.homepage = HOMEPAGE s.rubyforge_project = RUBYFORGE_PROJECT end Rake::GemPackageTask.new(spec) do |pkg| end task :release_confirmation do puts <> The release task has been cancelled!\n\n") end end desc "Publish and release files to RubyForge." task :release => [:release_confirmation, :package] do system("svn commit -m 'Created release #{VERS}'") system("svn copy -m 'Created tag for release #{VERS}' https://asproject.googlecode.com/svn/trunk/ https://asproject.googlecode.com/svn/tags/#{VERS}") system('rubyforge login') for ext in RELEASE_TYPES release_command = "rubyforge add_release #{RUBYFORGE_PROJECT} #{NAME} 'pre-alpha #{VERS}' pkg/#{NAME}-#{VERS}.#{ext}" puts release_command system(release_command) end end desc "Increment the release revision" task :increment_revision do version_file = File.join('lib', NAME, 'version.rb') file = File.open(version_file, 'r+') lines = '' file.readlines.each do |line| if(line.match(/^\s+TINY/)) d = line.match(/\d+/) incr = d.to_s.to_i + 1 newline = line.gsub(/(\d+)/, incr.to_s) lines << newline puts "Incremented revision to #{incr.to_s}" next end lines << line end File.open(version_file, 'w') do |file| file.puts lines end end desc "Package and Reinstall the latest gem" task :reinstall_gem do system("rake package") system("gem uninstall asproject") system("gem install pkg/asproject-#{VERS}.gem") end