require 'rake' require 'rake/clean' require 'rake/gempackagetask' require 'rake/rdoctask' require 'rake/testtask' require 'spec/rake/spectask' require 'code_statistics' require 'fileutils' require File.dirname(__FILE__)+'/tools/rakehelp' include FileUtils NAME = "merb" VERS = "0.0.8" CLEAN.include ['**/.*.sw?', '*.gem', '.config'] RDOC_OPTS = ['--quiet', '--title', "Merb Documentation", "--opname", "index.html", "--line-numbers", 'TODO', "--main", "README", "--inline-source"] setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc", ".config", "examples/sample_app/dist/public/files/**/*"] desc "Packages up Merb." task :default => [:package] task :package => [:really_clean, :clean, :rdoc] task :doc => [:rdoc] task :really_clean do rm_rf 'examples/sample_app/log/*' end Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'doc/rdoc' rdoc.options += RDOC_OPTS rdoc.main = "README" rdoc.title = "Merb Documentation" rdoc.rdoc_files.add ['README', 'LICENSE', 'TODO', 'lib/**/*.rb'] end spec = Gem::Specification.new do |s| s.name = NAME s.version = VERS s.platform = Gem::Platform::RUBY s.has_rdoc = true s.extra_rdoc_files = ["README", "LICENSE", 'TODO'] s.rdoc_options += RDOC_OPTS + ['--exclude', '^(app|uploads)'] s.summary = "Merb == Mongrel + Erb. Pocket rocket web framework." s.description = s.summary s.author = "Ezra Zygmuntowicz" s.email = 'ez@engineyard.com' s.homepage = 'http://merb.devjavu.com' s.executables = ['merb'] s.add_dependency('mongrel') s.add_dependency('erubis') s.add_dependency('json') s.add_dependency('mime-types') s.required_ruby_version = '>= 1.8.4' s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{app,bin,test,lib,examples}/**/*") s.require_path = "lib" s.bindir = "bin" end Rake::GemPackageTask.new(spec) do |p| p.need_tar = true p.gem_spec = spec end task :install do sh %{rake clean} sh %{rake package} sh %{sudo gem install pkg/#{NAME}-#{VERS}} end task :uninstall => [:clean] do sh %{sudo gem uninstall #{NAME}} end desc "rdoc to rubyforge" task :doc_rforge do sh %{rake doc} sh %{sudo chmod -R 755 doc/rdoc} sh %{scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb} end desc 'Run unit tests' Rake::TestTask.new('test_unit') do |t| t.libs << 'test' t.pattern = 'test/unit/*_test.rb' t.verbose = true end desc 'Run functional tests' Rake::TestTask.new('test_functional') do |t| t.libs << 'test' t.pattern = 'test/functional/*_test.rb' t.verbose = true end desc 'Run all tests' Rake::TestTask.new('test') do |t| t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Run all tests, specs and finish with rcov' task :aok do sh %{rake rcov} sh %{rake spec} end desc "Run all specs" Spec::Rake::SpecTask.new('specs') do |t| t.spec_opts = ["--format", "specdoc"] t.libs = ['lib', 'server/lib' ] t.spec_files = FileList['specs/**/*_spec.rb'] end desc "RCov" Spec::Rake::SpecTask.new('rcov') do |t| t.spec_files = FileList['specs/**/*_spec.rb'] t.libs = ['lib', 'server/lib' ] t.rcov = true end ############################################################################## # Statistics ############################################################################## STATS_DIRECTORIES = [ %w(Code lib/), %w(Unit\ tests test/unit), %w(Functional\ tests test/functional) ].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) } desc "Report code statistics (KLOCs, etc) from the application" task :stats do #require 'extra/stats' verbose = true CodeStatistics.new(*STATS_DIRECTORIES).to_s end ############################################################################## # SVN ############################################################################## desc "Add new files to subversion" task :svn_add do system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add" end