Sha256: 1c510cb56c0bd0087d7df70b8f7fadf1bb3581ef170dcfb6a330d3a034bc488b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Asset
  extend self

  def remote_to_local(cap)
    servers = Capistrano::Configuration.env.send(:servers)
    server = servers.detect { |s| s.roles.include?(:app) }
    port = server.netssh_options[:port] || 22
    user = server.netssh_options[:user] || server.properties.fetch(:user)
    [cap.fetch(:assets_dir)].flatten.each do |dir|
      system("rsync -a --del -L -K -vv --progress --rsh='ssh -p #{port}' #{user}@#{server}:#{cap.current_path}/#{dir} #{cap.fetch(:local_assets_dir)}")
    end
  end

  def local_to_remote(cap)
    servers = Capistrano::Configuration.env.send(:servers)
    server = servers.detect { |s| s.roles.include?(:app) }
    port = server.netssh_options[:port] || 22
    user = server.netssh_options[:user] || server.properties.fetch(:user)
    [cap.fetch(:assets_dir)].flatten.each do |dir|
      system("rsync -a --del -L -K -vv --progress --rsh='ssh -p #{port}' ./#{dir} #{user}@#{server}:#{cap.current_path}/#{cap.fetch(:local_assets_dir)}")
    end
  end

  def to_string(cap)
    [cap.fetch(:assets_dir)].flatten.join(" ")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-db-tasks.senya-0.4.1 lib/capistrano-db-tasks/asset.rb