Sha256: 33cb9c3d557a8bcc49f229bb83e106ddf22801c135318116173a39469083bd84

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reap-0.6.1 lib/reap/publish-task.rb