Sha256: 3ae0b3ef1280e23fdeb4397dd29979de10d03d4ec953ca6dcfd1aacf753e848b

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require "rake_deploy_lib/version"

# RakeDeployLib includes methodes for deploying und syncing files to a remote host.
# The Gem depends on rsync! The OS (Operating System) needs support for the rsync command (e.q. Linux, Unix, OS X).
# * deploy = transfare local (repository) files to remote server
# * sync = transfare remote server files to local (repository)
module RakeDeployLib

  # Deploys local (repository) files, excepts excludes, to the remote server.
  # Please be aware, that files will be deleted at remote host, if they don't exist local! With excludes you are able to prevent deletion.
  # * local (mendetory) - directory relative to the project root without / (slash) at the end.
  # * user (mendetory) - ssh user name at the remote server. Use of ssh certificate authentication is recommanded.
  # * host (mendetory) - server domain like example.com
  # * remote (mendetory) - absolute directory path without / (slash) at the end.
  # * excludes (optional) - an arrey of files or directories to exclude.
  #   * Files: e.g. "myfile.txt" or ".gitignore"
  #   * Directories: e.g. "mydirectory/" be aware of the trailing / (slash)
  def RakeDeployLib.deploy(local, user, host, remote, excludes)
    if (!local || !user || !host || !remote)
      return false
    end
    cmd_rsync = "rsync -rz --delete "
    cmd_exclude = ""

    if excludes
      excludes.each do |to_exclude|
        cmd_exclude = "#{cmd_exclude}--exclude=#{to_exclude} "
      end
      cmd_rsync = "#{cmd_rsync}#{cmd_exclude}"
    end

    if (system "#{cmd_rsync}#{local}/ #{user}@#{host}:#{remote}/")
      return true
    else
      return false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake_deploy_lib-0.1.3 lib/rake_deploy_lib.rb
rake_deploy_lib-0.1.2 lib/rake_deploy_lib.rb
rake_deploy_lib-0.1.0 lib/rake_deploy_lib.rb