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/asproject/version' require 'lib/asproject_utils' AUTHOR = "lukebayes" # can also be an array of Authors EMAIL = "lbayes@patternpark.com" DESCRIPTION = "AsProject is a tool set that simplifies the process of beginning and growing a new ActionScript project. The gem includes an additional tool (asclass) for file creation and a set of cross-platform rake tasks that support mtasc, swfmill and mxmlc." GEM_NAME = "asproject" # what ppl will type to install your gem RUBYFORGE_PROJECT = "asproject" # The unix name for your project HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" SUMMARY = "AsProject" NAME = "asproject" RELEASE_TYPES = ["gem"] REV = nil VERS = (AsProject::VERSION::STRING + (REV ? ".#{REV}" : "")) CLEAN.include(['**/.*.sw?', '*.gem', 'pkg/*', 'pkg', '**/**/.crap_file']) CLEAN.include(File.dirname(AsProject.unique_tmpdir('AsProjectTest'))) RDOC_OPTS = ['--quiet', '--title', 'asproject 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/**/*', 'templates', 'templates/**/*', 'templates/**/.[a-z]*' ] PKG_LIST.exclude('.svn') PKG_LIST.each do |file| task :package => file end task :package => :add_crap_files spec = Gem::Specification.new do |s| s.name = 'asproject' s.version = VERS s.summary = "AsProject is a tool set that simplifies the process of beginning and growing a new ActionScript project." s.description = <<-EOF AsProject is a templating system for creating new projects and new classes (or files) within those projects. EOF 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 = ['asproject', 'asclass'] s.default_executable = 'asproject' s.author = "Luke Bayes" s.email = "lbayes@patternpark.com" s.homepage = "http://www.patternpark.com" s.rubyforge_project = "asproject" 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, :increment_revision] do 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 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}") 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 crap_files = Array.new file crap_files def crap_file_message return <> Creating Crap file with: ' + dir + '/.crap_file' File.open(dir + '/.crap_file', 'w') do |file| file.write(crap_file_message) end end end add_crap('templates') desc "Add crap files to templates" task :add_crap_files => crap_files