Class: DockerSync::Preconditions::Osx
- Inherits:
-
Object
- Object
- DockerSync::Preconditions::Osx
- Defined in:
- lib/docker-sync/preconditions/preconditions_osx.rb
Instance Method Summary collapse
- #check_all_preconditions(config) ⇒ Object
- #docker_available ⇒ Object
- #docker_running ⇒ Object
- #fswatch_available ⇒ Object
- #is_driver_docker_for_mac? ⇒ Boolean
- #is_driver_docker_toolbox? ⇒ Boolean
- #rsync_available ⇒ Object
- #unison_available ⇒ Object
Instance Method Details
#check_all_preconditions(config) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 5 def check_all_preconditions(config) return unless should_run_precondition? docker_available docker_running if config.unison_required? unison_available end if config.rsync_required? rsync_available fswatch_available end end |
#docker_available ⇒ Object
21 22 23 24 25 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 21 def docker_available if (find_executable0 'docker').nil? raise('Could not find docker binary in path. Please install it, e.g. using "brew install docker" or install docker-for-mac') end end |
#docker_running ⇒ Object
27 28 29 30 31 32 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 27 def docker_running `docker ps` if $?.exitstatus > 0 raise('No docker daemon seems to be running. Did you start your docker-for-mac / docker-machine?') end end |
#fswatch_available ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 60 def fswatch_available if should_run_precondition? if (find_executable0 'fswatch').nil? cmd1 = 'brew install fswatch' Thor::Shell::Basic.new.say_status 'warning', 'No fswatch available. Install it by "brew install fswatch Trying to install now', :red if Thor::Shell::Basic.new.yes?('I will install fswatch using brew for you? (y/N)') system cmd1 else raise('Please install it yourself using: brew install fswatch') end end end end |
#is_driver_docker_for_mac? ⇒ Boolean
76 77 78 79 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 76 def is_driver_docker_for_mac? `docker info | grep 'Docker Root Dir: /var/lib/docker' && docker info | grep 'Operating System: Alpine Linux'` $?.success? end |
#is_driver_docker_toolbox? ⇒ Boolean
81 82 83 84 85 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 81 def is_driver_docker_toolbox? return false unless find_executable0('docker-machine') `docker info | grep 'Operating System: Boot2Docker'` $?.success? end |
#rsync_available ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 34 def rsync_available if should_run_precondition? if (find_executable0 'rsync').nil? raise('Could not find rsync binary in path. Please install it, e.g. using "brew install rsync"') end end end |
#unison_available ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/docker-sync/preconditions/preconditions_osx.rb', line 42 def unison_available if should_run_precondition? if (find_executable0 'unison').nil? cmd1 = 'brew install unison' Thor::Shell::Basic.new.say_status 'warning', 'Could not find unison binary in $PATH. Trying to install now', :red Thor::Shell::Basic.new.say_status 'command', cmd1, :white if Thor::Shell::Basic.new.yes?('I will install unison using brew for you? (y/N)') system cmd1 else raise('Please install it yourself using: brew install unison') end end unox_available end end |