#!/usr/bin/env ruby require 'reap/task' # ___ _ _ _ _ _____ _ # | _ \_ _| |__| (_)__| |_ |_ _|_ _ __| |__ # | _/ || | '_ \ | (_-< ' \ | |/ _` (_-< / / # |_| \_,_|_.__/_|_/__/_||_| |_|\__,_/__/_\_\ # # = Publish Task class Reap::Publish < Reap::Task section_required true task_desc "Publish documents to the web." task_help %{ reap publish Publish documents to hosting service. Currently only supports web publishing to Rubyforge. Working on generalizing this more in future. dir Directory of files to publish. exclude Files not to include from directory. project Project name. username Username for host. } #attr_accessor :host, :type, :dir, :project, :username #attr_accessor :exclude # not using yet task_attr :pub # Setup the publishing task. def init pub.type ||= 'www' pub.host ||= 'rubyforge.org' pub.project ||= master.rubyforge.project || master.name pub.username ||= master.rubyforge.username pub.exclude ||= [] end # Run the publishing task. def run cmd = ''; skip = false case pub.host when 'rubyforge', 'rubyforge.org' case pub.type when 'www', 'web' cmd = %{scp -r #{pub.dir}/* #{pub.username}@rubyforge.org:/var/www/gforge-projects/#{pub.project}/} else puts %{Unrecognized publishing kind '#{pub.type}' for host '#{pub.host}'. Skipped.} skip = true end else puts %{Unrecognized publishing host '#{pub.host}'. Skipped.} skip = true end unless skip puts "Reap is shelling out publishing work..." sh(cmd) unless $PRETEND end end end