#!/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' 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}" RUBY_FORGE_PROJECT = "masterview" RUBY_FORGE_USER = "jeffbski" RUBY_FORGE_GROUPID = "1290" RUBY_FORGE_PACKAGEID = "1581" #verify this from http://rubyforge.org/frs/admin/?group_id=1290 PKG_FILES = FileList[ "lib/**/*", "generators/**/*", "directives/**/*", "test/**/*", "example/**/*", "[A-Z]*", "Rakefile", "init.rb" ].exclude(/\bCVS\b|~$|\.svn/) 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 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.add_dependency 'facets' 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 ------------------------------------------------- desc "Publish the 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