Class: Awestruct::Commands::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/commands/deploy.rb

Instance Method Summary collapse

Constructor Details

#initialize(site_path, opts) ⇒ Deploy

Returns a new instance of Deploy.



7
8
9
10
11
# File 'lib/awestruct/commands/deploy.rb', line 7

def initialize(site_path, opts)
  @site_path = File.join( site_path, '/' )
  @host      = opts['host']
  @path      = File.join( opts['path'], '/' )
end

Instance Method Details

#runObject



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
39
40
41
42
43
44
# File 'lib/awestruct/commands/deploy.rb', line 13

def run
  cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+s,ug+w --delete #{@site_path} #{@host}:#{@path}"
  Open3.popen3( cmd ) do |stdin, stdout, stderr|
    stdin.close
    threads = []
    threads << Thread.new(stdout) do |i|
      while ( ! i.eof? )
        line = i.readline
        case line[0,9]
        when '<f.sT....'
          puts " updating #{line[10..-1]}"
        when 'cd+++++++'
          puts " creating #{line[10..-1]}"
        when '<f+++++++'
          puts " adding #{line[10..-1]}"
        when '<f..T....'
          # ignoring unchanged files
          # puts " no change to #{line[10..-1]}"
        else
          puts line
        end
      end
    end
    threads << Thread.new(stderr) do |i|
      while ( ! i.eof? )
        line = i.readline
        puts line
      end
    end
    threads.each{|t|t.join}
  end
end