#!/usr/bin/env ruby require 'rubygems' require 'meta_project' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/gempackagetask' require 'rake/contrib/rubyforgepublisher' require 'rake/contrib/xforge' require 'rake/clean' require 'gmailer' #require 'archive/tar/minitar' #require 'zlib' $LOAD_PATH.unshift( File.join( File.dirname(__FILE__), 'lib') ) require 'masterview' RUBY_FORGE_PROJECT = "masterview" RUBY_FORGE_USER = "jeffbski" RUBY_FORGE_GROUPID = "1290" Main_dir = Dir.getwd desc "Default Task" task :default => [ :test ] desc "Delete tar.gz / zip / rdoc" task :cleanup => [ :rm_packages, :clobber_rdoc ] # Run the unit tests Rake::TestTask.new(:test) do |t| t.libs << "lib" t.libs << "test" t.pattern = 'test/*_test.rb' t.verbose = false end # Run parser on masterview html files desc "Run parser on masterview html files" task :mvparse do TmpOutputDir = 'tmp/views' filelist = Dir.glob('examples/**/*.html') filelist.each do |file| MasterView::Parser.parse_file( file, TmpOutputDir, :tidy => true ) end end task :install => [:package] do `gem install pkg/#{PKG_FILE_NAME}.gem` end task :syntax do filelist = Dir.glob('**/*.rb') filelist.each do |file| output = `ruby -c #{file}` unless output =~ /Syntax OK/ puts "#{file}:" puts " #{output}" return end end puts 'Syntax OK' end # Genereate the RDoc documentation Rake::RDocTask.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "MasterView Template Engine" rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') rdoc.rdoc_files.include('lib/**/*.rb') } task :lines do lines = 0 codelines = 0 Dir.foreach("lib") { |file_name| next unless file_name =~ /.*rb/ f = File.open("lib/" + file_name) while line = f.gets lines += 1 next if line =~ /^\s*$/ next if line =~ /^\s*#/ codelines += 1 end } puts "Lines #{lines}, LOC #{codelines}" end # Publish beta gem #desc "Publish the gem" #task :publish => [:rdoc, :package] do # Rake::SshFilePublisher.new("foobar.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.zip").upload # Rake::SshFilePublisher.new("foobar.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.tgz").upload # Rake::SshFilePublisher.new("foobar.com", "dist/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload # # Rake::SshDirPublisher.new("foobar.com", "dist/api/#{PKG_NAME}", "doc").upload #end desc 'Verify RUBYFORGE_USER and RUBYFORGE_PASSWORD' task :verify_rubyforge do raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER'] raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD'] MASTERVIEW = MetaProject::Project::XForge::RubyForge.new('masterview') end desc 'Verify GMAIL_USER GMAIL_PASSWORD' task :verify_gmail do raise "GMAIL_USER environment variable not set!" unless ENV['GMAIL_USER'] raise "GMAIL_PASSWORD environment variable not set!" unless ENV['GMAIL_PASSWORD'] end desc 'Build all packages' task :package => ['masterview_plugin:package', 'masterview:package', 'masterview_generator:package', 'masterview_plugin_generator:package', 'masterview_gem_pack:package'] desc 'Re-build all packages' task :repackage => ['masterview_plugin:repackage', 'masterview:repackage', 'masterview_generator:repackage', 'masterview_plugin_generator:repackage', 'masterview_gem_pack:repackage'] desc 'Release all files' task :release_files => ['masterview_plugin:release_files', 'masterview:release_files', 'masterview_generator:release_files', 'masterview_plugin_generator:release_files', 'masterview_gem_pack:release_files'] namespace 'masterview_plugin' do module MasterViewComplete PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_plugin' PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" RELEASE_NAME = "REL #{PKG_VERSION}" PKG_FILES = FileList[ "lib/**/*", "generators/masterview/**/*", #exclude the masterview_plugin generator, not needed for non-gem install "directives/**/*", "test/**/*", "example/**/*", "[A-Z]*", "Rakefile", "init.rb" ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/) spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. This is the plugin version which contains everything for installation, does not require any gems." s.has_rdoc = true s.files = PKG_FILES s.require_path = 'lib' s.autorequire = 'masterview' s.author = "Jeff Barczewski" s.email = "jeff.barczewski@gmail.com" s.homepage = "http://masterview.org/" end # Create Rubygem package Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do release_files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } Rake::XForge::Release.new(MASTERVIEW) do |release| release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = RELEASE_NAME release.package_name = PKG_NAME notes = [] File.open("RELEASE_NOTES") do |file| file.each do |line| line.chomp! line.gsub!(/^#.*$/, '') and next notes << line end end release.release_notes = notes.join("\n") changes = [] File.open("CHANGELOG") do |file| current = true file.each do |line| line.chomp! current = false if current and line =~ /^==/ break if line.empty? and not current changes << line end end release.release_changes = changes.join("\n") end end end end namespace 'masterview_gem_pack' do module MasterViewGemPack PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_gem_pack' PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" RELEASE_NAME = "REL #{PKG_VERSION}" PKG_FILES = FileList[ "[A-Z]*", ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/) spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. This gem package includes the other masterview gems for easy installation" s.has_rdoc = true s.files = PKG_FILES s.require_path = '.' s.extra_rdoc_files = ['README'] s.add_dependency( 'masterview', ">= #{PKG_VERSION}" ) s.add_dependency( 'masterview_generator', ">= #{PKG_VERSION}" ) s.add_dependency( 'masterview_plugin_generator', ">= #{PKG_VERSION}" ) s.author = "Jeff Barczewski" s.email = "jeff.barczewski@gmail.com" s.homepage = "http://masterview.org/" end # Create Rubygem package Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = false p.need_zip = false end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do release_files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } Rake::XForge::Release.new(MASTERVIEW) do |release| release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = RELEASE_NAME release.package_name = PKG_NAME notes = [] File.open("RELEASE_NOTES") do |file| file.each do |line| line.chomp! line.gsub!(/^#.*$/, '') and next notes << line end end release.release_notes = notes.join("\n") changes = [] File.open("CHANGELOG") do |file| current = true file.each do |line| line.chomp! current = false if current and line =~ /^==/ break if line.empty? and not current changes << line end end release.release_changes = changes.join("\n") end end end end namespace 'masterview' do module MasterViewGem PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview' PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" RELEASE_NAME = "REL #{PKG_VERSION}" PKG_FILES = FileList[ "lib/**/*", "directives/**/*", "test/**/*", "example/**/*", "[A-Z]*", "Rakefile", "init.rb" ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/) spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. " s.has_rdoc = true s.files = PKG_FILES s.require_path = 'lib' s.autorequire = 'masterview' s.extra_rdoc_files = ['README'] s.author = "Jeff Barczewski" s.email = "jeff.barczewski@gmail.com" s.homepage = "http://masterview.org/" end # Create Rubygem package Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = false p.need_zip = false end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do release_files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } Rake::XForge::Release.new(MASTERVIEW) do |release| release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = RELEASE_NAME release.package_name = PKG_NAME notes = [] File.open("RELEASE_NOTES") do |file| file.each do |line| line.chomp! line.gsub!(/^#.*$/, '') and next notes << line end end release.release_notes = notes.join("\n") changes = [] File.open("CHANGELOG") do |file| current = true file.each do |line| line.chomp! current = false if current and line =~ /^==/ break if line.empty? and not current changes << line end end release.release_changes = changes.join("\n") end end end end namespace 'masterview_generator' do module MasterViewGenerator PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_generator' PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" RELEASE_NAME = "REL #{PKG_VERSION}" desc "Package masterview_generator" task :package do work_dir = Dir.getwd Dir.chdir 'generators/masterview' system( "rake package" ) Dir.chdir work_dir end desc "Repackage masterview_generator" task :repackage do work_dir = Dir.getwd Dir.chdir 'generators/masterview' system( "rake repackage" ) Dir.chdir work_dir end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do release_files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } Rake::XForge::Release.new(MASTERVIEW) do |release| release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = RELEASE_NAME release.package_name = PKG_NAME notes = [] File.open("RELEASE_NOTES") do |file| file.each do |line| line.chomp! line.gsub!(/^#.*$/, '') and next notes << line end end release.release_notes = notes.join("\n") changes = [] File.open("CHANGELOG") do |file| current = true file.each do |line| line.chomp! current = false if current and line =~ /^==/ break if line.empty? and not current changes << line end end release.release_changes = changes.join("\n") end end end end namespace 'masterview_plugin_generator' do module MasterViewGemPluginGenerator PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_plugin_generator' PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" RELEASE_NAME = "REL #{PKG_VERSION}" PKG_FILES = FileList[ "generators/masterview_plugin/**/*", "[A-Z]*" ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/) desc "Package masterview_generator" task :package do work_dir = Dir.getwd Dir.chdir 'generators/masterview_plugin' system( "rake package" ) Dir.chdir work_dir end desc "Repackage masterview_generator" task :repackage do work_dir = Dir.getwd Dir.chdir 'generators/masterview_plugin' system( "rake repackage" ) Dir.chdir work_dir end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do release_files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } Rake::XForge::Release.new(MASTERVIEW) do |release| release.user_name = ENV['RUBYFORGE_USER'] release.password = ENV['RUBYFORGE_PASSWORD'] release.files = release_files.to_a release.release_name = RELEASE_NAME release.package_name = PKG_NAME notes = [] File.open("RELEASE_NOTES") do |file| file.each do |line| line.chomp! line.gsub!(/^#.*$/, '') and next notes << line end end release.release_notes = notes.join("\n") changes = [] File.open("CHANGELOG") do |file| current = true file.each do |line| line.chomp! current = false if current and line =~ /^==/ break if line.empty? and not current changes << line end end release.release_changes = changes.join("\n") end end end end desc "Publish news on RubyForge" task :publish_news => [ :verify_rubyforge, :tar, :gem, :demotar] do Rake::XForge::NewsPublisher.new(Ruby_PDF) do |news| news.user_name = ENV['RUBYFORGE_USER'] news.password = ENV['RUBYFORGE_PASSWORD'] news.subject = "PDF::Writer #{PDF::Writer::VERSION} Released" news.changes_file = nil details = [] File.open("Release-Announcement") do |file| file.each do |line| line.chomp! break if line =~ /^=/ details << line end end news.details = details.join("\n") end end desc "Post a release announcement via GMail." #task :email_announcement => [ :verify_gmail, :tar, :gem, :demotar] do task :email_announcement => [ :verify_gmail ] do GMailer.connect(ENV["GMAIL_USER"], ENV["GMAIL_PASSWORD"]) do |gmail| gmail.send :to => "ruby-talk@ruby-lang.org", :subject => "[ANN] PDF::Writer #{PDF::Writer::VERSION}", :body => File.read("Release-Announcement") end end