Class: Docksync::Rsync

Inherits:
Object
  • Object
show all
Defined in:
lib/docksync/rsync.rb,
lib/docksync/rsync/sync.rb,
lib/docksync/rsync/install.rb

Defined Under Namespace

Classes: Install, Sync

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Rsync

Returns a new instance of Rsync.



9
10
11
12
13
# File 'lib/docksync/rsync.rb', line 9

def initialize(options)
  @options = options
  @cid = @options[:cid]
  @cwd = @options[:cwd]
end

Instance Method Details

#checkObject



25
26
27
28
29
30
31
# File 'lib/docksync/rsync.rb', line 25

def check
  running = `docker inspect -f {{.State.Running}} #{@cid}`.strip == 'true'
  unless running
    puts "Container #{@cid} is not running".colorize(:red)
    exit 0
  end
end

#runObject



15
16
17
18
19
20
21
22
23
# File 'lib/docksync/rsync.rb', line 15

def run
  unless @options[:noop]
    check
    Install.new(@options).run unless @options[:skip_install]
    Sync.new(@options).run
  end
  msg = "Done rsyncing to container #{@cid}"
  @options[:mute] ? msg : puts(msg)
end