#!/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" 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 MASTERVIEW = MetaProject::Project::XForge::RubyForge.new('masterview') 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'] end 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 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[ "masterview_plugin_generator.rb", "templates/**/*", "[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. MasterView Plugin Generator for GEM" s.has_rdoc = false s.files = PKG_FILES s.require_path = '.' s.autorequire = 'masterview_plugin_generator' 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 p.package_dir = '../../pkg' 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