diff --git a/Rakefile b/Rakefile index 0e3286b..5595d6c 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,13 @@ $: << File.join(File.dirname(__FILE__),"lib") require 'heel' -task :default => :spec +# load all the extra tasks for the project +TASK_DIR = File.join(File.dirname(__FILE__),"tasks") +FileList[File.join(TASK_DIR,"*.rb")].each do |tasklib| + require "tasks/#{File.basename(tasklib)}" +end + +task :default => 'test:default' #----------------------------------------------------------------------- # Documentation @@ -27,38 +33,17 @@ namespace :doc do show_files Heel::SPEC.local_rdoc_dir end - # TODO: factor this out into rubyforge namespace - desc "Deploy the RDoc documentation to rubyforge" - task :rdoc => :rerdoc do - sh "rsync -zav --delete doc/ #{Heel::SPEC.rubyforge_rdoc_dest}" - end - end -#----------------------------------------------------------------------- -# Testing - TODO factor this out into a separate taslklib -#----------------------------------------------------------------------- -namespace :test do - - Spec::Rake::SpecTask.new do |r| - r.rcov = true - r.rcov_dir = Heel::SPEC.local_coverage_dir - r.libs = Heel::SPEC.require_paths - r.spec_opts = %w(--format specdoc) - end - - task :coverage => [:spec] do - show_files Heel::SPEC.local_coverage_dir - end - -end #----------------------------------------------------------------------- -# Packaging +# Packaging and Distribution #----------------------------------------------------------------------- namespace :dist do + + GEM_SPEC = eval(Heel::SPEC.to_ruby) - Rake::GemPackageTask.new(Heel::SPEC) do |pkg| + Rake::GemPackageTask.new(GEM_SPEC) do |pkg| pkg.need_tar = Heel::SPEC.need_tar pkg.need_zip = Heel::SPEC.need_zip end @@ -82,40 +67,23 @@ namespace :dist do desc "reinstall gem" task :reinstall => [:install, :uninstall] - # TODO: factor this out into separate tasklib - desc "Release files to rubyforge" - task :release => [:clean, :package] do - rubyforge = RubyForge.new - rubyforge.login + desc "distribute copiously" + task :copious => [:package] do + Rake::SshFilePublisher.new('jeremy@copiousfreetime.org', + '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems', + 'pkg',"#{Heel::SPEC.full_name}.gem").upload + sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile" end end -#----------------------------------------------------------------------- -# Distribution -#----------------------------------------------------------------------- -namespace :dist do - -end - #----------------------------------------------------------------------- -# TODO: factor website out into its own tasklib -# Website maintenance +# update the top level clobber task to depend on all possible sub-level +# tasks that have a name like ':clobber' in other namespaces #----------------------------------------------------------------------- -namespace :site do - - desc "Build the public website" - task :build do - end - - desc "Update the website on rubyforge" - task :deploy => :build do - sh "rsync -zav --delete #{Heel::SPEC.local_site_dir} #{Heel::SPEC.remote_site_location}" +Rake.application.tasks.each do |t| + if t.name =~ /:clobber/ then + task :clobber => [t.name] end - - desc "View the website locally" - task :view => :build do - end - end diff --git a/bin/heel b/bin/heel index 829bddb..8be18e5 100644 --- a/bin/heel +++ b/bin/heel @@ -6,6 +6,5 @@ require 'rubygems' require 'mongrel' require 'heel' -server = Heel::Server.new(ARGV) -server.run +Heel::Server.new(ARGV).run diff --git a/lib/heel/gemspec.rb b/lib/heel/gemspec.rb index 8ec2fe9..4877b00 100644 --- a/lib/heel/gemspec.rb +++ b/lib/heel/gemspec.rb @@ -5,20 +5,20 @@ module Heel SPEC = Heel::Specification.new do |spec| - spec.name = "heel" + spec.name = "Heel" spec.version = Heel::VERSION spec.rubyforge_project = "copiousfreetime" spec.author = "Jeremy Hinegardner" spec.email = "jeremy@hinegardner.org" - spec.homepage = "http://#{spec.rubyforge_project}.rubyforge.org/#{spec.name}/" + spec.homepage = "http://copiousfreetime.rubyforge.org/heel/" - spec.summary = "A mongrel based webserver." + spec.summary = "A mongrel based static file webserver." spec.description = <<-DESC Heel is a mongrel based webserver to quickly and easily - serve up the contents of a directory as a webpages. + serve up the contents of a directory as webpages. DESC - spec.extra_rdoc_files = %w[LICENSE README CHANGES] + spec.extra_rdoc_files = FileList["CHANGES", "LICENSE", "README"] spec.has_rdoc = true spec.rdoc_main = "README" spec.rdoc_options = [ "--line-numbers" , "--inline-source" ] @@ -29,15 +29,19 @@ module Heel FileList["lib/**/*.rb", "resources/**/*"] spec.add_dependency("mongrel", ">= 1.0.1") + spec.add_dependency("launchy", ">= 0.1.1") + + spec.required_ruby_version = ">= 1.8.5" - spec.platform = Gem::Platform::RUBY + spec.platform = Gem::Platform::RUBY + spec.remote_user = "jjh" spec.local_rdoc_dir = "doc/rdoc" - spec.remote_rdoc_dir = "#{spec.name}/rdoc" + spec.remote_rdoc_dir = "" spec.local_coverage_dir = "doc/coverage" - spec.remote_coverage_dir= "#{spec.name}/coverage" spec.remote_site_dir = "#{spec.name}/" + end end diff --git a/lib/heel/specification.rb b/lib/heel/specification.rb index f6ed1c2..be43038 100644 --- a/lib/heel/specification.rb +++ b/lib/heel/specification.rb @@ -93,7 +93,7 @@ def remote_root # rdoc files is the same as what would be generated during gem # installation. That is, everything in the require paths plus - # the rdoc_extra_files + # the extra_rdoc_files # def rdoc_files flist = extra_rdoc_files.dup diff --git a/lib/heel/version.rb b/lib/heel/version.rb index db0fb6d..23d12c0 100644 --- a/lib/heel/version.rb +++ b/lib/heel/version.rb @@ -4,11 +4,11 @@ module Heel class Version MAJOR = 0 MINOR = 1 - TINY = 0 + BUILD = 0 class << self def to_a - [MAJOR, MINOR, TINY] + [MAJOR, MINOR, BUILD] end def to_s diff --git a/tasks/rspec..rb b/tasks/rspec..rb new file mode 100644 index 0000000..8e60bf2 --- /dev/null +++ b/tasks/rspec..rb @@ -0,0 +1,19 @@ +require 'spec/rake/spectask' +#----------------------------------------------------------------------- +# Testing - this is either test or spec, include the appropriate one +#----------------------------------------------------------------------- +namespace :test do + + task :default => :spec + + Spec::Rake::SpecTask.new do |r| + r.rcov = true + r.rcov_dir = Heel::SPEC.local_coverage_dir + r.libs = Heel::SPEC.require_paths + r.spec_opts = %w(--format specdoc) + end + + task :coverage => [:spec] do + show_files Heel::SPEC.local_coverage_dir + end +end \ No newline at end of file diff --git a/tasks/rubyforge.rb b/tasks/rubyforge.rb index c56a4b0..9832003 100644 --- a/tasks/rubyforge.rb +++ b/tasks/rubyforge.rb @@ -1,38 +1,47 @@ +require 'rubyforge' + #----------------------------------------------------------------------- -# create the website for use on rubyforge -# -# The website includes the rdoc and the coverage report. -# -# Ripped from the guts of hoe +# Documentation - pushing documentation to rubyforge #----------------------------------------------------------------------- -require 'webgen/rake/webgentask' -Webgen::Rake::WebgenTask.new - -# generate the content for the website -task :publish_docs => [:webgen, :rdoc, :spec] - -# push the website and all documentation to rubyforge -require 'yaml' -desc "Sync #{PKG_INFO.publish_dir} with rubyforge site" -task :sync_rubyforge do |rf| - rf_config = YAML::load(File.read(File.join(ENV["HOME"],".rubyforge","user-config.yml"))) - dest_host = "#{rf_config['username']}@rubyforge.org" - dest_dir = "/var/www/gforge-projects/#{PKG_INFO.rubyforge_name}" - - # trailing slash on source, none on destination - sh "rsync -zav --delete #{PKG_INFO.publish_dir}/ #{dest_host}:#{dest_dir}" +namespace :doc do + desc "Deploy the RDoc documentation to rubyforge" + task :deploy => :rerdoc do + sh "rsync -zav --delete #{Heel::SPEC.local_rdoc_dir}/ #{Heel::SPEC.remote_rdoc_location}" + end end -desc "Remove all content from the rubyforge site" -task :clean_rubyforge => [:clobber, :sync_rubyforge] - -desc "Push the published docs to rubyforge" -task :publish_rubyforge => [:publish_docs, :sync_rubyforge] +#----------------------------------------------------------------------- +# Packaging and Distribution - push to rubyforge +#----------------------------------------------------------------------- +namespace :dist do + desc "Release files to rubyforge" + task :release => [:clean, :package] do + + rubyforge = RubyForge.new + + # make sure this release doesn't already exist + releases = rubyforge.autoconfig['release_ids'] + if releases.has_key?(Heel::SPEC.name) and releases[Heel::SPEC.name][Heel::VERSION] then + abort("ERROR: Release #{Heel::VERSION} already exists! Unable to release.") + end + + config = rubyforge.userconfig + config["release_notes"] = Heel::SPEC.description + config["release_changes"] = last_changeset + config["Prefomatted"] = true + + + puts "Uploading to rubyforge..." + files = FileList[File.join("pkg","#{Heel::SPEC.name}-#{Heel::VERSION}.*")].to_a + rubyforge.login + rubyforge.add_release(Heel::SPEC.rubyforge_project, Heel::SPEC.name, Heel::VERSION, *files) + puts "done." + end +end #----------------------------------------------------------------------- -# Create an announcement text file, and post news to rubyforge +# Announcements - Create an email text file, and post news to rubyforge #----------------------------------------------------------------------- -require 'rubyforge' def changes change_file = File.expand_path(File.join(File.basename(__FILE__),"..","CHANGES")) sections = File.read(change_file).split(/^(?===)/) @@ -42,13 +51,13 @@ def last_changeset end def announcement - urls = " #{PKG_INFO.url}" - subject = "#{PKG_INFO.name} #{PKG_INFO.version} Released" - title = "#{PKG_INFO.name} version #{PKG_INFO.version} has been released." + urls = " #{Heel::SPEC.homepage}" + subject = "#{Heel::SPEC.name} #{Heel::VERSION} Released" + title = "#{Heel::SPEC.name} version #{Heel::VERSION} has been released." body = <" - mail.puts "To: ruby-talk@ruby-lang.org" - mail.puts "Date: #{Time.now.rfc2822}" - mail.puts "Subject: [ANN] #{subject}" - mail.puts - mail.puts title - mail.puts - mail.puts urls - mail.puts - mail.puts body - mail.puts - mail.puts urls +namespace :announce do + desc "create email for ruby-talk" + task :email do + subject, title, body, urls = announcement + + File.open("email.txt", "w") do |mail| + mail.puts "From: #{Heel::SPEC.author} <#{Heel::SPEC.email}>" + mail.puts "To: ruby-talk@ruby-lang.org" + mail.puts "Date: #{Time.now.rfc2822}" + mail.puts "Subject: [ANN] #{subject}" + mail.puts + mail.puts title + mail.puts + mail.puts urls + mail.puts + mail.puts body + mail.puts + mail.puts urls + end + puts "Created the following as email.txt:" + puts "-" * 72 + puts File.read("email.txt") + puts "-" * 72 + end + + CLOBBER << "email.txt" + + desc "Post news of #{Heel::SPEC.name} to #{Heel::SPEC.rubyforge_project} on rubyforge" + task :post_news do + subject, title, body, urls = announcement + rubyforge = RubyForge.new + rubyforge.login + rubyforge.post_news(Heel::SPEC.rubyforge_project, subject, "#{title}\n\n#{urls}\n\n#{body}") + puts "Posted to rubyforge" end - puts "Created the following as email.txt:" - puts "-" * 72 - puts File.read("email.txt") - puts "-" * 72 -end -CLOBBER << "email.txt" - -desc "Post news to your project on rubyforge" -task :post_news do - subject, title, body, urls = announcement - rf = RubyForge.new - rf.login - rf.post_news(PKG_INFO.rubyforge_name, subject, "#{title}\n\n#{urls}\n\n#{body}") - puts "Posted to rubyforge" -end - -#----------------------------------------------------------------------- -# post the packaged files to rubyforge, again, a modified version of -# what ships with hoe. -#----------------------------------------------------------------------- -desc "Release files to rubyforge" -task :release_rubyforge => [:clean, :package] do - rf = RubyForge.new - rf.login - - config = rf.userconfig - config["release_notes"] = PKG_INFO.description - config["release_changes"] = last_changeset - config["Prefomatted"] = true - files = FileList["pkg/#{PKG_INFO.rubyforge_name}-#{PKG_INFO.version}.*"].to_a - puts "Uploading to rubyforge..." - rf.add_release(PKG_INFO.rubyforge_name, PKG_INFO.name, PKG_INFO.version, *files) - puts "done." end -