Sha256: bd65ff790a105f6cfe864165fdb20494be9043a4123be370323b614c1b305932

Contents?: true

Size: 1.2 KB

Versions: 218

Compression:

Stored size: 1.2 KB

Contents

require 'rake/dsl_definition'
require 'rake/contrib/compositepublisher'

module Rake

  # Publish an entire directory to an existing remote directory using
  # SSH.
  class SshDirPublisher
    include Rake::DSL

    def initialize(host, remote_dir, local_dir)
      @host = host
      @remote_dir = remote_dir
      @local_dir = local_dir
    end

    def upload
      sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
    end
  end

  # Publish an entire directory to a fresh remote directory using SSH.
  class SshFreshDirPublisher < SshDirPublisher
    def upload
      sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
      sh %{ssh #{@host} mkdir #{@remote_dir}}
      super
    end
  end

  # Publish a list of files to an existing remote directory.
  class SshFilePublisher
    include Rake::DSL

    # Create a publisher using the give host information.
    def initialize(host, remote_dir, local_dir, *files)
      @host = host
      @remote_dir = remote_dir
      @local_dir = local_dir
      @files = files
    end

    # Upload the local directory to the remote directory.
    def upload
      @files.each do |fn|
        sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
      end
    end
  end
end

Version data entries

218 entries across 184 versions & 48 rubygems

Version Path
challah-1.0.0.beta3 vendor/bundle/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
rake-10.1.0.beta.3 lib/rake/contrib/sshpublisher.rb
rake-10.1.0.beta.2 lib/rake/contrib/sshpublisher.rb
rake-10.1.0.beta.1 lib/rake/contrib/sshpublisher.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
challah-1.0.0.beta2 vendor/bundle/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
challah-1.0.0.beta vendor/bundle/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
challah-1.0.0.beta vendor/bundle/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/contrib/sshpublisher.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
rake-10.0.4 lib/rake/contrib/sshpublisher.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
torquebox-console-0.2.4 vendor/bundle/jruby/1.9/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb
torquebox-console-0.2.4 vendor/bundle/ruby/1.8/gems/rake-10.0.3/lib/rake/contrib/sshpublisher.rb