#!/usr/bin/env ruby require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/gempackagetask' require 'rake/contrib/rubyforgepublisher' $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 desc 'Build all packages' task :package_all => ['masterview_complete:package', 'masterview:package', 'masterview_parser:package', 'masterview_generator:package', 'masterview_plugin_generator:package'] desc 'Re-build all packages' task :repackage_all => ['masterview_complete:repackage', 'masterview:repackage', 'masterview_parser:repackage', 'masterview_generator:repackage', 'masterview_plugin_generator:repackage'] namespace 'masterview_complete' do module MasterViewComplete PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_complete' 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/**/*", "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 # --- Ruby forge release manager by florian gross ------------------------------------------------- RUBY_FORGE_PACKAGEID = "1909" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 desc "Publish the masterview_complete release files to RubyForge." task :release => [:gem, :package] do files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } system("rubyforge login --username #{::RUBY_FORGE_USER}") files.each do |file| system("rubyforge add_release #{::RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}") 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[ "[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. Main gem which requires all others" s.has_rdoc = true s.files = PKG_FILES #s.require_path = 'lib' #s.autorequire = 'masterview' s.add_dependency 'masterview_parser' s.add_dependency 'masterview_generator' s.add_dependency '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 end # --- Ruby forge release manager by florian gross ------------------------------------------------- RUBY_FORGE_PACKAGEID = "1581" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 desc "Publish the masterview_complete release files to RubyForge." task :release => [:gem, :package] do files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } system("rubyforge login --username #{::RUBY_FORGE_USER}") files.each do |file| system("rubyforge add_release #{::RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}") end end end end namespace 'masterview_parser' do module MasterViewParser PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'masterview_parser' 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. Parser gem" 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 = false p.need_zip = false end # --- Ruby forge release manager by florian gross ------------------------------------------------- RUBY_FORGE_PACKAGEID = "1910" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 desc "Publish the masterview_parser release files to RubyForge." task :release => [:gem, :package] do files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } system("rubyforge login --username #{::RUBY_FORGE_USER}") files.each do |file| system("rubyforge add_release #{::RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}") 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}" PKG_FILES = FileList[ "generators/masterview/**/*", "[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 Generator for GEM" s.has_rdoc = false s.files = PKG_FILES s.require_path = 'generators/masterview' s.autorequire = 'masterview_generator' s.add_dependency 'masterview_parser' 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 # --- Ruby forge release manager by florian gross ------------------------------------------------- RUBY_FORGE_PACKAGEID = "1911" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 desc "Publish the masterview_generator release files to RubyForge." task :release => [:gem, :package] do files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } system("rubyforge login --username #{::RUBY_FORGE_USER}") files.each do |file| system("rubyforge add_release #{::RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}") 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/) 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 = 'generators/masterview_plugin' s.autorequire = 'masterview_plugin_generator' s.add_dependency 'masterview_parser' 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 # --- Ruby forge release manager by florian gross ------------------------------------------------- RUBY_FORGE_PACKAGEID = "1912" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 desc "Publish the masterview_plugin_generator release files to RubyForge." task :release => [:gem, :package] do files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" } system("rubyforge login --username #{::RUBY_FORGE_USER}") files.each do |file| system("rubyforge add_release #{::RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}") end end end end