Rakefile in masterview_gem_pack-0.1.5 vs Rakefile in masterview_gem_pack-0.2.0

- old
+ new

@@ -8,12 +8,10 @@ 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') ) @@ -23,81 +21,166 @@ RUBY_FORGE_USER = "jeffbski" RUBY_FORGE_GROUPID = "1290" Main_dir = Dir.getwd -desc "Default Task" +desc "Default Task: run all tests" task :default => [ :test ] -desc "Delete tar.gz / zip / rdoc" -task :cleanup => [ :rm_packages, :clobber_rdoc ] +task :install => [:package] do + `gem install pkg/#{PKG_FILE_NAME}.gem` +end -# Run the unit tests -Rake::TestTask.new(:test) do |t| +desc "Delete tar.gz / zip / gem / rdoc / tmp" +task :cleanup => [ :rm_packages, 'doc:clobber_rdoc', 'dev:cleanup', 'test:cleanup' ] + + +#============================================================================== +# Test tasks +#============================================================================== + +desc 'Run all tests' +task :test do + Rake::Task["test:units"].invoke rescue got_error = true + #Rake::Task["test:functionals"].invoke rescue got_error = true + #??Rake::Task["test:cleanup"].invoke rescue got_error = true + raise "Test failures" if got_error +end + +# Run all unit tests +namespace 'test' do +Rake::TestTask.new(:units) do |t| t.libs << "lib" t.libs << "test" - t.pattern = 'test/*_test.rb' + t.pattern = 'test/unit/*_test.rb' t.verbose = false end +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 +desc 'Clean up tmp files from running tests' +namespace 'test' do +task :cleanup do + FileUtils.remove_dir('test/tmp', true) end +end -task :install => [:package] do - `gem install pkg/#{PKG_FILE_NAME}.gem` +#============================================================================== +# Documentation Tasks +#============================================================================== + +# Generate the RDoc documentation +namespace 'doc' do +Rake::RDocTask.new { |rdoc| + rdoc.rdoc_dir = 'doc/api' + rdoc.title = "MasterView Template Engine" + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('RELEASE_NOTES') + rdoc.rdoc_files.include('lib/**/*.rb') +} end -task :syntax do - filelist = Dir.glob('**/*.rb') +#============================================================================== +# Development Utilities Tasks +#============================================================================== + +desc 'Install MasterView gems locally from pkg dir' +namespace 'dev' do +task :install_local_gems do + pkg_build = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' + pkg_version = MasterView::VERSION::STRING + pkg_build + `gem install pkg/masterview-#{pkg_version}.gem --local -f` + `gem install pkg/masterview_generator-#{pkg_version}.gem --local -f` + `gem install pkg/masterview_plugin_generator-#{pkg_version}.gem --local -f` + `gem install pkg/masterview_gem_pack-#{pkg_version}.gem --local -f` +end +end + +desc 'Uninstall all MasterView gems' +namespace 'dev' do +task :uninstall_gems do + `gem uninstall masterview -a -x -i` +end +end + + +desc 'Run parser on masterview html templates in examples' +namespace 'dev' do +task :mvparse_examples do + template_mio_tree = MasterView::FileMIOTree.new('examples', '.html', :logging => true ) + output_mio_tree = MasterView::FileMIOTree.new('tmp/views', '.rhtml', :logging => true ) + template_mio_tree.find(:pattern => '*.html') do |mio| + MasterView::Parser.parse_mio( mio, output_mio_tree ) + end +end +end + +# Run syntax check on all ruby code files +desc 'Run syntax check on all ruby code files' +namespace 'dev' do +task :check_syntax do + #WAS: filelist = Dir.glob('**/*.rb') + #skip: generators - erb-ized code templates confuse the parser + filelist = [ 'init.rb', 'lib/masterview.rb' ] + filelist.concat Dir.glob('lib/**/*.rb') + filelist.concat Dir.glob('test/**/*.rb') filelist.each do |file| output = `ruby -c #{file}` unless output =~ /Syntax OK/ puts "#{file}:" puts " #{output}" return end end + puts "#{filelist.length} files checked" puts 'Syntax OK' end +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('RELEASE_NOTES') - rdoc.rdoc_files.include('lib/**/*.rb') -} - -task :lines do +# Count LOC in plugin lib +desc 'Count LOC' +namespace 'dev' do +task :count_loc do + files = 0 lines = 0 codelines = 0 - Dir.foreach("lib") { |file_name| - next unless file_name =~ /.*rb/ + + #VER1 WAS: Dir.foreach("lib") { |file_name| + #VER1 WAS: next unless file_name =~ /.*rb/ + #VER1 WAS: f = File.open("lib/" + file_name) + filelist = [ 'init.rb', 'lib/masterview.rb' ] + filelist.concat Dir.glob('lib/**/*.rb') + #filelist.concat Dir.glob('test**/*.rb') + filelist.each { |file_name| - f = File.open("lib/" + file_name) + f = File.open(file_name) + files += 1 while line = f.gets lines += 1 next if line =~ /^\s*$/ next if line =~ /^\s*#/ codelines += 1 end } - puts "Lines #{lines}, LOC #{codelines}" + puts "Lines #{lines}, LOC #{codelines} in #{files} files" end +end +desc 'Remove tmp files from running dev utilities' +namespace 'dev' do +task :cleanup do + FileUtils.remove_dir('tmp', true) +end +end + +#============================================================================== +# Build/Release Tasks +#============================================================================== + # 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 @@ -117,50 +200,107 @@ 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 +def copy_if_different(src,dst) + return if File.exist?(src) and File.exist?(dst) and File.read(src) == File.read(dst) + FileUtils.cp src, dst +end +desc 'Copy duplicated files - copy files that are duplicated between packages' +task :copy_duplicated_files do + copy_if_different 'init.rb', 'generators/masterview_plugin/templates/init.rb' + copy_if_different 'tasks/masterview.rake', 'generators/masterview_plugin/templates/masterview.rake' + copy_if_different 'lib/masterview/extras/app/views/masterview/admin/empty.rhtml', 'generators/masterview_plugin/templates/empty.rhtml' + copy_if_different 'examples/rails_app_config/masterview/settings.rb', 'generators/masterview_plugin/templates/settings.rb' + copy_if_different 'examples/rails_app_config/masterview/environment/development.rb', 'generators/masterview_plugin/templates/development.rb' + copy_if_different 'examples/rails_app_config/masterview/environment/production.rb', 'generators/masterview_plugin/templates/production.rb' +end + desc 'Build all packages' -task :package => ['masterview_plugin:package', - 'masterview:package', - 'masterview_generator:package', - 'masterview_plugin_generator:package', - 'masterview_gem_pack:package'] +task :package => [ + :copy_duplicated_files, + # gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver) + 'masterview:package', + 'masterview_generator:package', + 'masterview_plugin_generator:package', + 'masterview_gem_pack:package', + # zip/gzip of full masterview + 'masterview_plugin:package' + ] desc 'Re-build all packages' -task :repackage => ['masterview_plugin:repackage', - 'masterview:repackage', - 'masterview_generator:repackage', - 'masterview_plugin_generator:repackage', - 'masterview_gem_pack:repackage'] +task :repackage => [ + :copy_duplicated_files, + # gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver) + 'masterview:repackage', + 'masterview_generator:repackage', + 'masterview_plugin_generator:repackage', + 'masterview_gem_pack:repackage', + # zip/gzip of full masterview + 'masterview_plugin: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'] +task :release_files => [ + # gems (runtime, mv generator, mv plugin generator, 3-in-1 supersaver) + 'masterview:release_files', + 'masterview_generator:release_files', + 'masterview_plugin_generator:release_files', + 'masterview_gem_pack:release_files', + # zip/gzip of full masterview + 'masterview_plugin:release_files' + ] +desc 'Remove all tar.gz / zip / gem build pkg files' +task :rm_packages do + FileUtils.remove_dir('pkg', true) +end + +#### +#ISSUE: jeff - we don't include that top-level index.html in any of the packages?! +#### +PKG_FILES_RELEASE_DOCS = [ + "[A-Z]*" # README, RELEASE_NOTES, CHANGELOG, MIT_LICENSE, TODO + ] + +PKG_FILES_RUNTIME = [ + "lib/**/*", + "directives/**/*", #SHOULD THIS GO AWAY (??) + "Rakefile", + "init.rb" + ] +PKG_FILES_MV_GENERATOR = [ + "generators/masterview/**/*" # generator for creating app template scaffold + ] +PKG_FILES_MV_PLUGIN_GENERATOR = [ + "generators/masterview_plugin/**/*" # generator for creating vendor/plugins stub for gem install + ] + +PKG_FILES_DOCS = [ # docs and examples, actually + "doc/*", + "doc/stylesheets/*", + "examples/**/*" + ] +PKG_FILES_TESTS = [ + "test/**/*" + ] +PKG_FILES_EXCLUDE_PATTERN = /\bCVS\b|~$|\.svn|semantic.cache/ + +RAKE_PROCESSOR = RUBY_PLATFORM =~ /mswin32/ ? 'rake.cmd' : 'rake' # sigh + 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/) + PKG_INCLUDES = PKG_FILES_RUNTIME + PKG_FILES_MV_GENERATOR + PKG_FILES_DOCS + PKG_FILES_TESTS + PKG_FILES_RELEASE_DOCS + PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN ) 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." @@ -224,13 +364,12 @@ 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/) + PKG_INCLUDES = PKG_FILES_RELEASE_DOCS + PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN ) 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" @@ -297,19 +436,12 @@ 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/) + PKG_INCLUDES = PKG_FILES_RUNTIME + PKG_FILES_DOCS + PKG_FILES_TESTS + PKG_FILES_RELEASE_DOCS + PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN ) 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. " @@ -376,24 +508,26 @@ 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_INCLUDES = PKG_FILES_MV_GENERATOR + #PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN ) + desc "Package masterview_generator" task :package do work_dir = Dir.getwd Dir.chdir 'generators/masterview' - system( "rake package" ) + system( "#{RAKE_PROCESSOR} package" ) Dir.chdir work_dir end desc "Repackage masterview_generator" task :repackage do work_dir = Dir.getwd Dir.chdir 'generators/masterview' - system( "rake repackage" ) + system( "#{RAKE_PROCESSOR} repackage" ) Dir.chdir work_dir end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do @@ -440,28 +574,26 @@ 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/) + PKG_INCLUDES = PKG_FILES_MV_PLUGIN_GENERATOR + PKG_FILES_RELEASE_DOCS + PKG_FILES = FileList.new( PKG_INCLUDES ).exclude( PKG_FILES_EXCLUDE_PATTERN ) desc "Package masterview_generator" task :package do work_dir = Dir.getwd Dir.chdir 'generators/masterview_plugin' - system( "rake package" ) + system( "#{RAKE_PROCESSOR} 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" ) + system( "#{RAKE_PROCESSOR} repackage" ) Dir.chdir work_dir end desc "Release files on RubyForge." task :release_files => [ :verify_rubyforge ] do @@ -500,12 +632,10 @@ 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'] @@ -525,14 +655,13 @@ end desc "Post a release announcement via GMail." #task :email_announcement => [ :verify_gmail, :tar, :gem, :demotar] do task :email_announcement => [ :verify_gmail ] do + require 'gmailer' 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 - - +end