summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--History.txt90
-rw-r--r--Manifest.txt7
-rw-r--r--README.txt88
-rw-r--r--Rakefile13
-rwxr-xr-xbin/sow71
-rw-r--r--lib/hoe.rb440
-rw-r--r--test/test_hoe.rb26
7 files changed, 735 insertions, 0 deletions
diff --git a/History.txt b/History.txt
new file mode 100644
index 0000000..1d92921
--- /dev/null
+++ b/History.txt
@@ -0,0 +1,90 @@
+= 1.1.7
+
+* Bug #7193 fix spelling of 'synopsys'. Submitted by Jacob Atzen.
+
+= 1.1.6 2006-11-29
+
+* Fix release to work correctly with need_zip and need_tar.
+
+= 1.1.5 2006-11-29
+
+* Reduced check_manifest dependencies to just diff for windows.
+* Don't use default author in summary, description or changes.
+
+= 1.1.4 2006-11-12
+
+* Added need_tar and need_zip to customize package requirements. Stupid windoze.
+* Extended spec_extras to take procs as values. Passes in named parameter.
+* Removed test from require_paths. I thought I already parameterized this. :/
+
+= 1.1.3 2006-11-09
+
+* Added test_deps, now you can automatically discover test dependency ommisions.
+* Added ext support! Build C extensions with hoe!
+* Gemspec uses test_all.rb or result of test_globs. Tweak those tests.
+* Now uses https to login to rubyforge. Rubyforge crackers beware!
+* Fixed doco and automated updating of it.
+* Added rdoc_pattern. Go doco go!
+
+= 1.1.2 2006-10-22
+
+* Added -d and -t flags to sow to make dev or trunk subdirs for p4 and svn projects.
+* Added install_gem to further test gem builds.
+* Added test_globs to customize your test file list.
+* Removed demo.rb from clean_globs. I'm torn on this one.
+* Fixed bug in install rule.
+
+= 1.1.1 2006-10-11
+
+* Fixed minor problem with subject of email.
+* Fixed problem in test.
+
+= 1.1.0 2006-10-04
+
+* Added sow, a command-line tool for quickly creating new projects.
+* Added check_manifest task
+
+= 1.0.5 2006-10-03
+
+* Doco cleanup.
+* Removed Manifest.txt from rdoc and added title.
+* Added changeset support.
+* Added spec_extras for easy gemspec attribute setting.
+* Added release_notes, changeset setting for releases.
+* Added paragraphs_of utility method.
+* Added email and rubyforge news announcement tasks.
+* Url attribute may now be an array of urls.
+
+= 1.0.4 2006-09-23
+
+* Damnit... I messed up. There is no rubygems gem to be dependent upon. Duh.
+
+= 1.0.3 2006-09-23
+
+* Added debug_gem rule.
+* Added lots of doco.
+* Added proper deps to hoe for other's gems, and rake/rubyforge/rubygems for hoe.
+* Added ridocs to generate ri locally for testing.
+* Added support for multiple authors.
+* Fixed include paths.
+* Rdoc now includes any top level .txt files.
+* Renamed deploy to release.
+* Renamed upload to publish_docs.
+* publish_docs is now smart about subprojects and missing subdirectories.
+
+= 1.0.2 2006-09-20
+
+* Wee little tests.
+* Fixed up gemspec's require_paths.
+
+= 1.0.1 2006-09-20
+
+* Finally got deployment straightened out. Maybe. Some might be on rubyforge.org.
+* Added default description and summary.
+* Added dependency mechanism.
+* Improved gemspec debugging.
+* Swapped gem with tgz in deploy... we'd rather screw up on tgz
+
+= 1.0.0 2006-09-19
+
+* Birthday!
diff --git a/Manifest.txt b/Manifest.txt
new file mode 100644
index 0000000..5893d70
--- /dev/null
+++ b/Manifest.txt
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/sow
+lib/hoe.rb
+test/test_hoe.rb
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..9081b67
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,88 @@
+Hoe
+ http://rubyforge.org/projects/seattlerb/
+ http://seattlerb.rubyforge.org/hoe/
+ ryand-ruby@zenspider.com
+
+== DESCRIPTION:
+
+Hoe is a simple rake/rubygems helper for project Rakefiles. It
+generates all the usual tasks for projects including rdoc generation,
+testing, packaging, and deployment.
+
+Tasks Provided:
+
+* announce - Generate email announcement file and post to rubyforge.
+* audit - Run ZenTest against the package
+* check_manifest - Verify the manifest
+* clean - Clean up all the extras
+* debug_gem - Show information about the gem.
+* default - Run the default tasks
+* docs - Build the docs HTML Files
+* email - Generate email announcement file.
+* install - Install the package. Uses PREFIX and RUBYLIB
+* install_gem - Install the package as a gem
+* multi - Run the test suite using multiruby
+* package - Build all the packages
+* post_news - Post announcement to rubyforge.
+* publish_docs - Publish RDoc to RubyForge
+* release - Package and upload the release to rubyforge.
+* ridocs - Generate ri locally for testing
+* test - Run the test suite. Use FILTER to add to the command line.
+* test_deps - Show which test files fail when run alone.
+* uninstall - Uninstall the package.
+
+See class rdoc for help. Hint: ri Hoe
+
+== FEATURES/PROBLEMS:
+
+* Provides 'sow' for quick project directory creation.
+* Make making and maintaining Rakefiles fun and easy.
+
+== SYNOPSIS:
+
+ % sow [group] project
+
+or
+
+ require 'hoe'
+
+ Hoe.new(projectname, version) do |p|
+ # ... project specific data ...
+ end
+
+ # ... project specific tasks ...
+
+== REQUIREMENTS:
+
+* rake
+* rubyforge
+* rubygems
+
+== INSTALL:
+
+* sudo gem install hoe
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2006 Ryan Davis, Zen Spider Software
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..bf7d6b9
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,13 @@
+# -*- ruby -*-
+
+require './lib/hoe.rb'
+
+Hoe.new("hoe", Hoe::VERSION) do |p|
+ p.rubyforge_name = "seattlerb"
+ p.summary = "Hoe is a way to write Rakefiles much easier and cleaner."
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+end
+
+# vim: syntax=Ruby
diff --git a/bin/sow b/bin/sow
new file mode 100755
index 0000000..99f8d63
--- /dev/null
+++ b/bin/sow
@@ -0,0 +1,71 @@
+#!/usr/bin/env ruby -ws
+
+$t ||= false
+$d ||= false
+
+if defined? $h then
+ puts "usage: #{File.dirname($0)} [-d|-t] [group] project"
+ puts " -t = add project to subdir under 'trunk'"
+ puts " -d = add project to subdir under 'dev'"
+end
+
+abort "You must specify only one of -t or -d" if $t and $d
+
+group = ARGV.shift
+project = ARGV.shift
+
+project ||= group
+
+# prevents false positives on my tag reporter
+X = 'FI' + 'X'
+
+abort "You must supply a project name on the commandline" unless project
+abort "Project #{project} seems to exist" if test ?d, project
+puts "creating project #{project}"
+
+case project
+when /_/ then
+ file_name = project
+ project = project.capitalize.gsub(/_([a-z])/) {$1.upcase}
+ klass = project
+else
+ file_name = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
+ klass = project.capitalize.gsub(/_([a-z])/) {$1.upcase}
+end
+
+Dir.mkdir project
+Dir.chdir project do
+
+ if $d then
+ Dir.mkdir "dev"
+ Dir.chdir "dev"
+ elsif $t then
+ Dir.mkdir "trunk"
+ Dir.chdir "trunk"
+ end
+
+ %w(bin lib test).each do |path|
+ Dir.mkdir path
+ end
+
+ files = {
+ "History.txt" => "== 1.0.0 / #{Time.new.strftime("%Y-%m-%d")}\n\n* 1 major enhancement\n * Birthday!\n\n",
+ "README.txt" => "#{project}\n by #{X} (your name)\n #{X} (url)\n\n== DESCRIPTION:\n \n#{X} (describe your package)\n\n== FEATURES/PROBLEMS:\n \n* #{X} (list of features or problems)\n\n== SYNOPSIS:\n\n #{X} (code sample of usage)\n\n== REQUIREMENTS:\n\n* #{X} (list of requirements)\n\n== INSTALL:\n\n* #{X} (sudo gem install, anything else)\n\n== LICENSE:\n\n(The MIT License)\n\nCopyright (c) #{Time.new.strftime("%Y")} #{X}\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
+ "Manifest.txt" => "",
+ "bin/#{file_name}" => "",
+ "lib/#{file_name}.rb" => "class #{klass}\n VERSION = '1.0.0'\nend",
+ "test/test_#{file_name}.rb" => "",
+ "Rakefile" => "# -*- ruby -*-\n\nrequire 'rubygems'\nrequire 'hoe'\nrequire './lib/#{file_name}.rb'\n\nHoe.new('#{project}', #{klass}::VERSION) do |p|\n p.rubyforge_name = \'#{group}\'\n # p.summary = '#{X}'\n # p.description = p.paragraphs_of('README.txt', 2..5).join(\"\\n\\n\")\n # p.url = p.paragraphs_of('README.txt', 0).first.split(/\\n/)[1..-1]\n p.changes = p.paragraphs_of('History.txt', 0..1).join(\"\\n\\n\")\nend\n\n# vim: syntax=Ruby\n"
+ }
+
+ files["Manifest.txt"] = files.keys.sort.join("\n")
+
+ files.each do |file, content|
+ File.open(file, "w") do |f|
+ f.write content
+ end
+ end
+end
+
+puts "... done, now go fix all occurances of '#{X}'"
+puts `find #{project} -type f | xargs grep -n #{X}`.gsub(/\A|\n/, "\n ")
diff --git a/lib/hoe.rb b/lib/hoe.rb
new file mode 100644
index 0000000..f8a05c9
--- /dev/null
+++ b/lib/hoe.rb
@@ -0,0 +1,440 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'rake'
+require 'rake/contrib/sshpublisher'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/testtask'
+require 'rbconfig'
+
+##
+# hoe - a tool to help rake
+#
+# Hoe is a simple rake/rubygems helper for project Rakefiles. It
+# generates all the usual tasks for projects including rdoc generation,
+# testing, packaging, and deployment.
+#
+# == Using Hoe
+#
+# === Basics
+#
+# Use this as a minimal starting point:
+#
+# require 'hoe'
+#
+# Hoe.new("project_name", '1.0.0') do |p|
+# p.rubyforge_name = "rf_project"
+# # add other details here
+# end
+#
+# # add other tasks here
+#
+# === Tasks Provided:
+#
+# * announce - Generate email announcement file and post to rubyforge.
+# * audit - Run ZenTest against the package
+# * check_manifest - Verify the manifest
+# * clean - Clean up all the extras
+# * debug_gem - Show information about the gem.
+# * default - Run the default tasks
+# * docs - Build the docs HTML Files
+# * email - Generate email announcement file.
+# * install - Install the package. Uses PREFIX and RUBYLIB
+# * install_gem - Install the package as a gem
+# * multi - Run the test suite using multiruby
+# * package - Build all the packages
+# * post_news - Post announcement to rubyforge.
+# * publish_docs - Publish RDoc to RubyForge
+# * release - Package and upload the release to rubyforge.
+# * ridocs - Generate ri locally for testing
+# * test - Run the test suite. Use FILTER to add to the command line.
+# * test_deps - Show which test files fail when run alone.
+# * uninstall - Uninstall the package.
+#
+# === Attributes
+#
+# The attributes that you can provide inside the new block above are:
+#
+# ==== Mandatory
+#
+# * name - The name of the release.
+# * version - The version. Don't hardcode! use a constant in the project.
+#
+# ==== Damn Good to Set
+#
+# * author - The author of the package. (can be array of authors)
+# * changes - A description of the release's latest changes.
+# * description - A description of the project.
+# * email - The author's email address. (can be array of urls)
+# * summary - A short summary of the project.
+# * url - The url of the project.
+#
+# ==== Optional
+#
+# * clean_globs - An array of file patterns to delete on clean.
+# * extra_deps - An array of rubygem dependencies.
+# * need_tar - Should package create a tarball? [default: true]
+# * need_zip - Should package create a zipfile? [default: false]
+# * rdoc_pattern - A regexp to match documentation files against the manifest.
+# * rubyforge_name - The name of the rubyforge project. [default: name.downcase]
+# * spec_extras - A hash of extra values to set in the gemspec.
+# * test_globs - An array of test file patterns [default: test/**/test_*.rb]
+#
+# === Environment Variables
+#
+# * FILTER - Used to add flags to test_unit (e.g., -n test_borked)
+# * PREFIX - Used to specify a custom install location (for rake install).
+# * RUBY_DEBUG - Used to add extra flags to RUBY_FLAGS.
+# * RUBY_FLAGS - Used to specify flags to ruby [has smart default].
+
+class Hoe
+ VERSION = '1.1.6'
+
+ rubyprefix = Config::CONFIG['prefix']
+ sitelibdir = Config::CONFIG['sitelibdir']
+
+ PREFIX = ENV['PREFIX'] || rubyprefix
+ RUBYLIB = if PREFIX == rubyprefix then
+ sitelibdir
+ else
+ File.join(PREFIX, sitelibdir[rubyprefix.size..-1])
+ end
+ RUBY_DEBUG = ENV['RUBY_DEBUG']
+ RUBY_FLAGS = ENV['RUBY_FLAGS'] ||
+ "-w -I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}" +
+ (RUBY_DEBUG ? " #{RUBY_DEBUG}" : '')
+ FILTER = ENV['FILTER'] # for tests (eg FILTER="-n test_blah")
+
+ attr_accessor :author, :bin_files, :changes, :clean_globs, :description, :email, :extra_deps, :lib_files, :name, :need_tar, :need_zip, :rdoc_pattern, :rubyforge_name, :spec, :spec_extras, :summary, :test_files, :test_globs, :url, :version
+
+ def initialize(name, version)
+ self.name = name
+ self.version = version
+
+ # Defaults
+ self.rubyforge_name = name.downcase
+ self.url = "http://www.zenspider.com/ZSS/Products/#{name}/"
+ self.author = "Ryan Davis"
+ self.email = "ryand-ruby@zenspider.com"
+ self.clean_globs = %w(diff diff.txt email.txt ri *.gem **/*~)
+ self.test_globs = ['test/**/test_*.rb']
+ self.changes = "The author was too lazy to write a changeset"
+ self.description = "The author was too lazy to write a description"
+ self.summary = "The author was too lazy to write a summary"
+ self.rdoc_pattern = /^(lib|bin)|txt$/
+ self.extra_deps = []
+ self.spec_extras = {}
+ self.need_tar = true
+ self.need_zip = false
+
+ if name == 'hoe' then
+ extra_deps << ['rake']
+ extra_deps << ['rubyforge', '>= 0.3.1']
+ else
+ extra_deps << ['hoe', ">= #{VERSION}"]
+ end
+
+ yield self if block_given?
+
+ define_tasks
+ end
+
+ def define_tasks
+ desc 'Run the default tasks'
+ task :default => :test
+
+ desc 'Run the test suite. Use FILTER to add to the command line.'
+ task :test do
+ run_tests
+ end
+
+ desc 'Show which test files fail when run alone.'
+ task :test_deps do
+ tests = Dir["test/**/test_*.rb"] + Dir["test/**/*_test.rb"]
+
+ tests.each do |test|
+ if not system "ruby -Ibin:lib:test #{test} &> /dev/null" then
+ puts "Dependency Issues: #{test}"
+ end
+ end
+ end
+
+ desc 'Run the test suite using multiruby'
+ task :multi do
+ run_tests :multi
+ end
+
+ ############################################################
+ # Packaging and Installing
+
+ self.spec = Gem::Specification.new do |s|
+ s.name = name
+ s.version = version
+ s.summary = summary
+ case author
+ when Array
+ s.authors = author
+ else
+ s.author = author
+ end
+ s.email = email
+ s.homepage = Array(url).first
+ s.rubyforge_project = rubyforge_name
+
+ s.description = description
+
+ extra_deps.each do |dep|
+ s.add_dependency(*dep)
+ end
+
+ s.files = File.read("Manifest.txt").split
+ s.executables = s.files.grep(/bin/) { |f| File.basename(f) }
+
+ s.bindir = "bin"
+ dirs = Dir['{lib,ext}']
+ s.require_paths = dirs unless dirs.empty?
+ s.has_rdoc = true
+
+ if test ?f, "test/test_all.rb" then
+ s.test_file = "test/test_all.rb"
+ else
+ s.test_files = Dir[*test_globs]
+ end
+
+ # Do any extra stuff the user wants
+ spec_extras.each do |msg, val|
+ case val
+ when Proc
+ val.call(s.send(msg))
+ else
+ s.send "#{msg}=", val
+ end
+ end
+ end
+
+ desc 'Show information about the gem.'
+ task :debug_gem do
+ puts spec.to_ruby
+ end
+
+ self.lib_files = spec.files.grep(/^lib/)
+ self.bin_files = spec.files.grep(/^bin/)
+ self.test_files = spec.files.grep(/^test/)
+
+ Rake::GemPackageTask.new spec do |pkg|
+ pkg.need_tar = @need_tar
+ pkg.need_zip = @need_zip
+ end
+
+ desc 'Install the package. Uses PREFIX and RUBYLIB'
+ task :install do
+ [
+ [lib_files + test_files, RUBYLIB, 0444],
+ [bin_files, File.join(PREFIX, 'bin'), 0555]
+ ].each do |files, dest, mode|
+ FileUtils.mkdir_p dest unless test ?d, dest
+ files.each do |file|
+ install file, dest, :mode => mode
+ end
+ end
+ end
+
+ desc 'Install the package as a gem'
+ task :install_gem => [:clean, :package] do
+ sh "sudo gem install pkg/*.gem"
+ end
+
+ desc 'Uninstall the package.'
+ task :uninstall do
+ Dir.chdir RUBYLIB do
+ rm_f((lib_files + test_files).map { |f| File.basename f })
+ end
+ Dir.chdir File.join(PREFIX, 'bin') do
+ rm_f bin_files.map { |f| File.basename f }
+ end
+ end
+
+ desc 'Package and upload the release to rubyforge.'
+ task :release => [:clean, :package] do |t|
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
+ abort "Versions don't match #{v} vs #{version}" if v != version
+ require 'rubyforge'
+ pkg = "pkg/#{name}-#{version}"
+
+ if $DEBUG then
+ puts "release_id = rf.add_release #{rubyforge_name.inspect}, #{name.inspect}, #{version.inspect}, \"#{pkg}.tgz\""
+ puts "rf.add_file #{rubyforge_name.inspect}, #{name.inspect}, release_id, \"#{pkg}.gem\""
+ end
+
+ rf = RubyForge.new
+ puts "Logging in"
+ rf.login
+
+ c = rf.config
+ c["release_notes"] = description if description
+ c["release_changes"] = changes if changes
+ c["preformatted"] = true
+
+ files = [(@need_tar ? "#{pkg}.tgz" : nil),
+ (@need_zip ? "#{pkg}.zip" : nil),
+ "#{pkg}.gem"].compact
+
+ puts "Releasing #{name} v. #{version}"
+ rf.add_release rubyforge_name, name, version, *files
+ end
+
+ ############################################################
+ # Doco
+
+ Rake::RDocTask.new(:docs) do |rd|
+ rd.main = "README.txt"
+ rd.options << '-d' if RUBY_PLATFORM !~ /win32/ and `which dot` =~ /\/dot/
+ rd.rdoc_dir = 'doc'
+ files = spec.files.grep(rdoc_pattern)
+ files -= ['Manifest.txt']
+ rd.rdoc_files.push(*files)
+
+ title = "#{name}-#{version} Documentation"
+ title = "#{rubyforge_name}'s " + title if rubyforge_name != title
+
+ rd.options << "-t #{title}"
+ end
+
+ desc "Generate ri locally for testing"
+ task :ridocs => :clean do
+ sh %q{ rdoc --ri -o ri . }
+ end
+
+ desc 'Publish RDoc to RubyForge'
+ task :publish_docs => [:clean, :docs] do
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/config.yml")))
+ user = "#{config["username"]}@rubyforge.org"
+ project = "/var/www/gforge-projects/#{rubyforge_name}"
+ project += "/#{name}" if rubyforge_name != name
+ local_dir = 'doc'
+ pub = Rake::SshDirPublisher.new user, project, local_dir
+ if rubyforge_name != name then
+ def pub.upload
+ begin
+ super
+ rescue
+ # project directory probably doesn't exist, transfer as a whole
+ sh %{scp -qr #{local_dir} #{host}:#{remote_dir}}
+ end
+ end
+ end
+ pub.upload
+ end
+
+ ############################################################
+ # Misc/Maintenance:
+
+ desc 'Run ZenTest against the package'
+ task :audit do
+ libs = %w(lib test).join(File::PATH_SEPARATOR)
+ sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}"
+ end
+
+ desc 'Clean up all the extras'
+ task :clean => [ :clobber_docs, :clobber_package ] do
+ clean_globs.each do |pattern|
+ files = Dir[pattern]
+ rm_rf files unless files.empty?
+ end
+ end
+
+ desc 'Generate email announcement file.'
+ task :email do
+ require 'rubyforge'
+ subject, title, body, urls = announcement
+
+ File.open("email.txt", "w") do |mail|
+ 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 email.txt"
+ end
+
+ desc 'Post announcement to rubyforge.'
+ task :post_news do
+ require 'rubyforge'
+ subject, title, body, urls = announcement
+
+ rf = RubyForge.new
+ rf.login
+ rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}")
+ puts "Posted to rubyforge"
+ end
+
+ desc 'Generate email announcement file and post to rubyforge.'
+ task :announce => [:email, :post_news]
+
+ desc "Verify the manifest"
+ task :check_manifest => :clean do
+ f = "Manifest.tmp"
+ require 'find'
+ files = []
+ Find.find '.' do |path|
+ next unless File.file? path
+ next if path =~ /svn|tmp$/
+ files << path[2..-1]
+ end
+ files = files.sort.join "\n"
+ File.open f, 'w' do |fp| fp.puts files end
+ system "diff -du Manifest.txt #{f}"
+ rm f
+ end
+
+ end # end define
+
+ def announcement
+ urls = " " + Array(url).map {|s| s.strip}.join("\n ")
+
+ subject = "#{name} #{version} Released"
+ title = "#{name} version #{version} has been released!"
+ body = "#{description}\n\nChanges:\n\n#{changes}"
+
+ return subject, title, body, urls
+ end
+
+ def run_tests(multi=false) # :nodoc:
+ msg = multi ? :sh : :ruby
+ cmd = if test ?f, 'test/test_all.rb' then
+ "#{RUBY_FLAGS} test/test_all.rb #{FILTER}"
+ else
+ tests = test_globs.map { |g| Dir.glob(g) }.flatten << 'test/unit'
+ tests.map! {|f| %Q(require "#{f}")}
+ "#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
+ end
+ cmd = "multiruby #{cmd}" if multi
+ send msg, cmd
+ end
+
+ ##
+ # Reads a file at +path+ and spits out an array of the +paragraphs+ specified
+ #
+ # changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ # summary, *description = p.paragraphs_of('Readme.txt', 3, 3..8)
+
+ def paragraphs_of(path, *paragraphs)
+ file = File.read(path)
+ file.split(/\n\n+/).values_at(*paragraphs)
+ end
+end
+
+class ::Rake::SshDirPublisher # :nodoc:
+ attr_reader :host, :remote_dir, :local_dir
+end
+
+if $0 == __FILE__ then
+ out = `rake -T | egrep -v "redocs|repackage|clobber|trunk"`
+ puts out.gsub(/\#/, '-').gsub(/^rake /, '# * ')
+end
diff --git a/test/test_hoe.rb b/test/test_hoe.rb
new file mode 100644
index 0000000..8746e8c
--- /dev/null
+++ b/test/test_hoe.rb
@@ -0,0 +1,26 @@
+
+require 'test/unit/testcase'
+require 'hoe'
+
+$rakefile = nil # shuts up a warning in rdoctask.rb
+
+class TestHoe < Test::Unit::TestCase
+ def setup
+ Rake.application.clear
+ end
+
+ ##
+ # Yes, these tests suck, but it is damn hard to test this since
+ # everything is forked out.
+
+ def test_basics
+ boring = %w(clobber clobber_docs clobber_package doc doc/index.html pkg pkg/blah-1.0.0 pkg/blah-1.0.0.gem pkg/blah-1.0.0.tgz redocs repackage)
+ expected = %w(audit announce check_manifest clean debug_gem default docs email gem install install_gem multi package post_news publish_docs release ridocs test test_deps uninstall)
+ expected += boring
+
+ Hoe.new('blah', '1.0.0')
+ tasks = Rake.application.tasks.map { |t| t.name }.sort
+
+ assert_equal expected.sort, tasks
+ end
+end