Sha256: 2743bf682c34e0873d330a231fac037ea59f6ad437dd8facae71c4fe73dd7051

Contents?: true

Size: 1.89 KB

Versions: 6

Compression:

Stored size: 1.89 KB

Contents

module Reap

  class Project

    # Publish website to rubyforge.
    #
    # This task publishes the source dir (deafult 'doc')
    # to a rubyforge website.
    #
    # Uses RSync to upload files to webserver.
    #
    # TODO: Add FTP/SFTP support.

    def publish(options=nil)
      options = configure_options(options, 'publish', 'rubyforge')

      project  = options['project']  || metadata.project
      webdir   = options['webdir']
      source   = options['source']
      username = options['username'] || ENV['RUBYFORGE_USERNAME']
      clear    = options['clear']
      protect  = options['protect']
      exclude  = options['exclude']

      source   ||= "doc"
      username ||= ENV['RUBYFORGE_USERNAME']

      if clear
        protect   = protect().to_a
        exclude   = exclude().to_a
      else
        protect   = %w{usage statcvs statsvn robot.txt wiki} + [protect].flatten
        exclude   = %w{.svn} + [exclude].flatten
      end

      abort "No project name." unless project
      abort "No username." unless username

      if webdir and webdir != '.'
        destination = File.join(project, webdir)
      else
        destination = project
      end

      dir = source.chomp('/') + '/'
      url = "#{username}@rubyforge.org:/var/www/gforge-projects/#{destination}"

      op = ['-rLvz', '--delete-after']  # maybe -p ?

      # Using commandline filter options didn't seem
      # to work, so I opted for creating an .rsync_filter file for
      # all cases.

      unless protect.empty? && exclude.empty?
        rsync_file = File.join(source,'.rsync-filter')
        unless file?(rsync_file)
          File.open(rsync_file, 'w') do |f|
            exclude.each{|e| f << "- #{e}\n"}
            protect.each{|e| f << "P #{e}\n"}
          end
        end
        op << "--filter='dir-merge #{rsync_file}'"
      end

      args = op + [dir, url]

      sh "rsync #{args.to_params}"
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reap-9.3.0 lib/reap/project/publish.rb
reap-9.3.1 lib/reap/project/publish.rb
reap-9.3.5 lib/reap/project/publish.rb
reap-9.4.0 lib/reap/project/publish.rb
reap-9.3.4 lib/reap/project/publish.rb
reap-9.3.3 lib/reap/project/publish.rb