Class: Docker_Sync::SyncProcess
- Inherits:
-
Object
- Object
- Docker_Sync::SyncProcess
- Includes:
- Thor::Shell
- Defined in:
- lib/docker-sync/sync_process.rb
Instance Method Summary collapse
- #clean ⇒ Object
- #get_host_ip ⇒ Object
-
#initialize(sync_name, options) ⇒ SyncProcess
constructor
noinspection RubyStringKeysInHashInspection.
- #run ⇒ Object
- #set_sync_strategy ⇒ Object
- #set_watch_strategy ⇒ Object
- #stop ⇒ Object
- #sync ⇒ Object
- #watch ⇒ Object
- #watch_fork ⇒ Object
- #watch_thread ⇒ Object
Constructor Details
#initialize(sync_name, options) ⇒ SyncProcess
noinspection RubyStringKeysInHashInspection
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/docker-sync/sync_process.rb', line 21 def initialize(sync_name, ) defaults = { 'verbose' => false, 'sync_host_ip' => get_host_ip } @sync_name = sync_name @options = defaults.merge() @sync_strategy = nil @watch_strategy = nil set_sync_strategy set_watch_strategy end |
Instance Method Details
#clean ⇒ Object
86 87 88 89 |
# File 'lib/docker-sync/sync_process.rb', line 86 def clean @sync_strategy.clean @watch_strategy.clean end |
#get_host_ip ⇒ Object
72 73 74 |
# File 'lib/docker-sync/sync_process.rb', line 72 def get_host_ip return '127.0.0.1' end |
#run ⇒ Object
76 77 78 79 |
# File 'lib/docker-sync/sync_process.rb', line 76 def run @sync_strategy.run @watch_strategy.run end |
#set_sync_strategy ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/docker-sync/sync_process.rb', line 34 def set_sync_strategy if @options.key?('sync_strategy') case @options['sync_strategy'] when 'rsync' @sync_strategy = Docker_Sync::SyncStrategy::Rsync.new(@sync_name, @options) when 'unison-onesided' @sync_strategy = Docker_Sync::SyncStrategy::Unison_Onesided.new(@sync_name, @options) when 'unison' @sync_strategy = Docker_Sync::SyncStrategy::Unison.new(@sync_name, @options) else @sync_strategy = Docker_Sync::SyncStrategy::Rsync.new(@sync_name, @options) end else @sync_strategy = Docker_Sync::SyncStrategy::Rsync.new(@sync_name, @options) end end |
#set_watch_strategy ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/docker-sync/sync_process.rb', line 51 def set_watch_strategy if @options.key?('watch_strategy') case @options['watch_strategy'] when 'fswatch' @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options) when 'disable','dummy' @watch_strategy = Docker_Sync::WatchStrategy::Dummy.new(@sync_name, @options) when 'unison' @watch_strategy = Docker_Sync::WatchStrategy::Unison.new(@sync_name, @options) else @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options) end else if @options['sync_strategy'] == 'unison' @watch_strategy = Docker_Sync::WatchStrategy::Unison.new(@sync_name, @options) else @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options) end end end |
#stop ⇒ Object
81 82 83 84 |
# File 'lib/docker-sync/sync_process.rb', line 81 def stop @sync_strategy.stop @watch_strategy.stop end |
#sync ⇒ Object
91 92 93 94 |
# File 'lib/docker-sync/sync_process.rb', line 91 def sync # TODO: probably use run here @sync_strategy.sync end |
#watch ⇒ Object
96 97 98 |
# File 'lib/docker-sync/sync_process.rb', line 96 def watch @watch_strategy.run end |
#watch_fork ⇒ Object
100 101 102 |
# File 'lib/docker-sync/sync_process.rb', line 100 def watch_fork return @watch_strategy.watch_fork end |
#watch_thread ⇒ Object
104 105 106 |
# File 'lib/docker-sync/sync_process.rb', line 104 def watch_thread return @watch_strategy.watch_thread end |