require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/packagetask' require 'rake/gempackagetask' require 'rake/contrib/rubyforgepublisher' PKG_NAME = 'feedtools' PKG_VERSION = '0.2.14' PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" RELEASE_NAME = "REL #{PKG_VERSION}" RUBY_FORGE_PROJECT = "feedtools" RUBY_FORGE_USER = "vacindak" PKG_FILES = FileList[ "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "db/**/*", "[A-Z]*", "install.rb", "rakefile" ].exclude(/\bCVS\b|~$/).exclude(/database\.yml/) desc "Default Task" task :default => [ :test_all ] # Run the unit tests Rake::TestTask.new("test_all") { |t| t.libs << "test" t.pattern = 'test/*_test.rb' t.verbose = true } # Generate the RDoc documentation Rake::RDocTask.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Feed Tools -- caching system for xml news feeds" rdoc.options << '--line-numbers --inline-source --accessor cattr_accessor=object' rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.rdoc_files.include('README', 'CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('db/**/*.sql') } # Create compressed packages dist_dirs = [ "lib", "test", "db" ] spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = "Parsing, generation, and caching system for xml news feeds." s.description = "Implements a simple system for handling xml news feeds with caching." s.files = [ "rakefile", "install.rb", "README", "CHANGELOG" ] dist_dirs.each do |dir| s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if do |item| item.include?( "\.svn" ) || item.include?( "database\.yml" ) end end s.add_dependency('activerecord', '>= 1.10.1') s.add_dependency('uuidtools', '>= 0.1.2') s.require_path = 'lib' s.autorequire = 'feed_tools' s.has_rdoc = true s.extra_rdoc_files = %w( README ) s.rdoc_options.concat ['--main', 'README'] s.author = "Bob Aman" s.email = "bob@sporkmonger.com" s.homepage = "http://sporkmonger.com/projects/feedtools" s.rubyforge_project = "feedtools" end Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true end task :lines do lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 for file_name in FileList["lib/**/*.rb"] f = File.open(file_name) while line = f.gets lines += 1 next if line =~ /^\s*$/ next if line =~ /^\s*#/ codelines += 1 end puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" total_lines += lines total_codelines += codelines lines, codelines = 0, 0 end puts "Total: Lines #{total_lines}, LOC #{total_codelines}" end # Publishing ------------------------------------------------------ desc "Publish the API documentation" task :pdoc => [:rdoc] do Rake::SshDirPublisher.new("vacindak@sporkmonger.com", "public_html/projects/feedtools/api", "doc").upload end