summaryrefslogtreecommitdiff
path: root/new/lib/crys/deployer.rb
blob: 501ea046d0a6ba3ca57db41a64f0c0387513cee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require 'rsync'

module Crys
  class Deployer
    DEST_PREFIX = '/usr/local/sites/'

    def initialize(dest:, source:)
      @dest = dest
      @source = source

      Rsync.configure do |config|
        config.host = 'mms@10.0.7.0'
      end
    end

    def run
      puts "source: #{source}"
      full_dest = DEST_PREFIX + dest
      puts "dest: #{full_dest}"

      Rsync.run(source, full_dest, ['-rtz']) do |result|
        if result.success?
          result.changes.each do |change|
            puts "#{change.filename} (#{change.summary})"
          end
        else
          puts result.error
        end
      end
    end

    private

    attr_reader :dest, :source
  end
end