require 'reap/task' # # Publish Task # class Reap::PublishTask < Reap::Task section_name :publish attr_accessor :host, :type, :dir, :project, :username def init @host = (section['host'] || 'rubyforge').to_s.downcase @type = (section['type'] || 'www').to_s.downcase #@command = section['command'] @dir = section['dir'] #@exclude = section['exclude'] @project = section['project'] || master['rubyforge']['project'] || master['name'] @username = section['username'] || master['rubyforge']['username'] end def define desc "publish documents to the web *" task :publish do run_publish end end def run_publish cmd = ''; skip = false case @host when 'rubyforge' case @type when 'www', 'web' cmd = %{scp -r #{@dir}/* #{@username}@rubyforge.org:/var/www/gforge-projects/#{@project}/} else puts %{Unrecognized publishing type '#{@type}' for host '#{@host}'. Skipped.} skip = true end else puts %{Unrecognized publishing host '#{@host}'. Skipped.} skip = true end unless skip puts "Reap is shelling out publishing work..." puts cmd sh(cmd) unless $PRETEND end end end