Class: Docker_Sync::WatchStrategy::Fswatch
- Inherits:
-
Object
- Object
- Docker_Sync::WatchStrategy::Fswatch
- Includes:
- Execution, Thor::Shell
- Defined in:
- lib/docker-sync/watch_strategy/fswatch.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(sync_name, options) ⇒ Fswatch
constructor
A new instance of Fswatch.
- #run ⇒ Object
- #stop ⇒ Object
- #watch ⇒ Object
- #watch_options ⇒ Object
- #watch_thread ⇒ Object
Methods included from Execution
Constructor Details
#initialize(sync_name, options) ⇒ Fswatch
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 15 def initialize(sync_name, ) @sync_name = sync_name = begin Preconditions::fswatch_available rescue Exception => e say_status 'error', e., :red exit 1 end end |
Instance Method Details
#clean ⇒ Object
34 35 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 34 def clean end |
#run ⇒ Object
27 28 29 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 27 def run watch end |
#stop ⇒ Object
31 32 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 31 def stop end |
#watch ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 37 def watch args = say_status 'success', "Starting to watch #{@options['src']} - Press CTRL-C to stop", :green cmd = 'fswatch ' + args.join(' ') say_status 'command', cmd, :white if ['verbose'] # run a thread here, since it is blocking @watch_thread = threadexec(cmd, "Sync #{@sync_name}", :blue) end |
#watch_options ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 47 def args = [] unless ['watch_excludes'].nil? args = ['watch_excludes'].map { |pattern| "--exclude='#{pattern}'" } + args end args.push('-orIE') args.push(['watch_args']) if .key?('watch_args') args.push(['src']) sync_command = 'thor sync:sync' begin Preconditions::docker_sync_available sync_command = 'docker-sync sync' rescue Exception => e say_status 'warning', 'docker-sync not available, assuming dev mode, using thor', :yellow puts e. sync_command = 'thor sync:sync' end args.push(" | xargs -I -n1 #{sync_command} -n #{@sync_name} --config='#{@options['config_path']}'") end |
#watch_thread ⇒ Object
68 69 70 |
# File 'lib/docker-sync/watch_strategy/fswatch.rb', line 68 def watch_thread return @watch_thread end |