Class: Awestruct::Deploy::RSyncDeploy
- Inherits:
-
Object
- Object
- Awestruct::Deploy::RSyncDeploy
- Defined in:
- lib/awestruct/deploy/rsync_deploy.rb
Instance Method Summary collapse
-
#initialize(site_config, deploy_config) ⇒ RSyncDeploy
constructor
A new instance of RSyncDeploy.
- #run ⇒ Object
Constructor Details
#initialize(site_config, deploy_config) ⇒ RSyncDeploy
Returns a new instance of RSyncDeploy.
9 10 11 12 13 |
# File 'lib/awestruct/deploy/rsync_deploy.rb', line 9 def initialize(site_config, deploy_config) @site_path = File.join( site_config.output_dir, '/' ) @host = deploy_config['host'] @path = File.join( deploy_config['path'], '/' ) end |
Instance Method Details
#run ⇒ Object
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 45 46 |
# File 'lib/awestruct/deploy/rsync_deploy.rb', line 15 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 |