Sha256: 0c797948eadcc20a8b0db8b202414f3dcfb698a7ff7222671f2063e249945389

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

module SimpleProvision
  class SCP
    FILENAME = "fss.tar.gz"

    def initialize(server, opts)
      @server, @opts = server, opts
    end

    def to_server
      create_local_archive
      scp_files_to_server
      extract_remote_archive
      remove_local_archive
    end

    private

    def create_local_archive
      files = @opts[:files] || []
      scripts = @opts[:scripts] || []
      includes = files + scripts

      if includes.empty?
        raise "Both files and scripts are empty. You should provide some"
      end

      `tar -czf #{FILENAME} #{includes.join(" ")}`
    end

    def scp_files_to_server
      @server.scp(FILENAME, ".")
    end

    def extract_remote_archive
      @server.ssh("tar -xzf #{FILENAME}")
    end

    def remove_local_archive
      `rm -f #{FILENAME}`
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_provision-0.99.4 lib/simple_provision/scp.rb
simple_provision-0.99.2 lib/simple_provision/scp.rb