require "rake" require "rake/clean" require "rake/gempackagetask" require "rake/rdoctask" require "fileutils" include FileUtils ############################################################################## # Configuration ############################################################################## NAME = "sequel_core" VERS = "2.2.0" CLEAN.include ["**/.*.sw?", "pkg", ".config", "rdoc", "coverage"] RDOC_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', \ 'Sequel: The Database Toolkit for Ruby: Core Library and Adapters', \ '--main', 'README'] ############################################################################## # RDoc ############################################################################## Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = "rdoc" rdoc.options += RDOC_OPTS rdoc.rdoc_files.add ["README", "COPYING", "doc/*.rdoc", "lib/**/*.rb"] end ############################################################################## # Gem packaging ############################################################################## desc "Packages up Sequel." task :package => [:clean] spec = Gem::Specification.new do |s| s.name = NAME s.rubyforge_project = 'sequel' s.version = VERS s.platform = Gem::Platform::RUBY s.has_rdoc = true s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"] + Dir["doc/*.rdoc"] s.rdoc_options += RDOC_OPTS + ["--exclude", "^(examples|extras)\/"] s.summary = "The Database Toolkit for Ruby: Core Library and Adapters" s.description = s.summary s.author = "Jeremy Evans" s.email = "code@jeremyevans.net" s.homepage = "http://sequel.rubyforge.org" s.executables = ["sequel"] s.required_ruby_version = ">= 1.8.4" s.files = %w(COPYING README Rakefile) + Dir.glob("{bin,doc,spec,lib}/**/*") s.require_path = "lib" s.bindir = "bin" end Rake::GemPackageTask.new(spec) do |p| p.need_tar = true p.gem_spec = spec end ############################################################################## # installation & removal ############################################################################## desc "Install sequel_core gem" task :install do sh %{rake package} sh %{sudo gem install pkg/#{NAME}-#{VERS}} end desc "Install sequel_core gem without docs" task :install_no_docs do sh %{rake package} sh %{sudo gem install pkg/#{NAME}-#{VERS} --no-rdoc --no-ri} end desc "Uninstall sequel_core gem" task :uninstall => [:clean] do sh %{sudo gem uninstall #{NAME}} end ############################################################################## # gem and rdoc release ############################################################################## desc "Upload sequel_core gem to rubyforge" task :release => [:package] do sh %{rubyforge login} sh %{rubyforge add_release sequel #{NAME} #{VERS} pkg/#{NAME}-#{VERS}.tgz} sh %{rubyforge add_file sequel #{NAME} #{VERS} pkg/#{NAME}-#{VERS}.gem} end ############################################################################## # specs ############################################################################## require "spec/rake/spectask" desc "Run specs with coverage" Spec::Rake::SpecTask.new("spec") do |t| t.spec_files = FileList["spec/*_spec.rb"] t.spec_opts = File.read("spec/spec.opts").split("\n") t.rcov_opts = File.read("spec/rcov.opts").split("\n") t.rcov = true end desc "Run specs without coverage" task :default => [:spec_no_cov] Spec::Rake::SpecTask.new("spec_no_cov") do |t| t.spec_files = FileList["spec/*_spec.rb"] t.spec_opts = File.read("spec/spec.opts").split("\n") end desc "Run adapter specs without coverage" Spec::Rake::SpecTask.new("spec_adapters") do |t| t.spec_files = FileList["spec/adapters/*_spec.rb"] t.spec_opts = File.read("spec/spec.opts").split("\n") end %w'postgres sqlite mysql informix oracle'.each do |adapter| desc "Run #{adapter} specs without coverage" Spec::Rake::SpecTask.new("spec_#{adapter}") do |t| t.spec_files = "spec/adapters/#{adapter}_spec.rb" t.spec_opts = File.read("spec/spec.opts").split("\n") end end desc "Run all specs with coverage" Spec::Rake::SpecTask.new("spec_all") do |t| t.spec_files = FileList["spec/*_spec.rb", "spec/adapters/*_spec.rb"] t.rcov_opts = File.read("spec/rcov.opts").split("\n") t.spec_opts = File.read("spec/spec.opts").split("\n") t.rcov = true end desc "Run rcov only" Spec::Rake::SpecTask.new("rcov") do |t| t.rcov_opts = File.read("spec/rcov.opts").split("\n") t.spec_opts = File.read("spec/spec.opts").split("\n") t.spec_files = FileList["spec/*_spec.rb"] t.rcov = true end desc "check documentation coverage" task :dcov do sh "find lib -name '*.rb' | xargs dcov" end ############################################################################## # Statistics ############################################################################## STATS_DIRECTORIES = [ %w(Code lib/), %w(Spec spec/) ].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