Module: Preconditions
- Defined in:
- lib/docker-sync/preconditions.rb
Class Method Summary collapse
- .check_all_preconditions ⇒ Object
- .docker_available ⇒ Object
- .docker_running ⇒ Object
- .docker_sync_available ⇒ Object
- .fswatch_available ⇒ Object
- .rsync_available ⇒ Object
- .unison_available ⇒ Object
- .unox_available ⇒ Object
Class Method Details
.check_all_preconditions ⇒ Object
4 5 6 7 8 |
# File 'lib/docker-sync/preconditions.rb', line 4 def self.check_all_preconditions docker_available docker_running fswatch_available end |
.docker_available ⇒ Object
10 11 12 13 14 |
# File 'lib/docker-sync/preconditions.rb', line 10 def self.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
16 17 18 19 20 21 |
# File 'lib/docker-sync/preconditions.rb', line 16 def self.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 |
.docker_sync_available ⇒ Object
29 30 31 32 33 |
# File 'lib/docker-sync/preconditions.rb', line 29 def self.docker_sync_available if (find_executable0 'docker-sync').nil? raise('No docker-sync available. Install it by "gem install docker-sync"') end end |
.fswatch_available ⇒ Object
23 24 25 26 27 |
# File 'lib/docker-sync/preconditions.rb', line 23 def self.fswatch_available if (find_executable0 'fswatch').nil? raise('No fswatch available. Install it by "brew install fswatch"') end end |
.rsync_available ⇒ Object
35 36 37 38 39 |
# File 'lib/docker-sync/preconditions.rb', line 35 def self.rsync_available if (find_executable0 'rsync').nil? raise('Could not find rsync binary in path. Please install it, e.g. using "brew install rsync"') end end |
.unison_available ⇒ Object
41 42 43 44 45 |
# File 'lib/docker-sync/preconditions.rb', line 41 def self.unison_available if (find_executable0 'unison').nil? raise('Could not find unison binary in path. Please install it, e.g. using "brew install unison"') end end |
.unox_available ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/docker-sync/preconditions.rb', line 47 def self.unox_available if (find_executable0 'unison-fsmonitor').nil? cmd1 = 'curl "https://raw.githubusercontent.com/hnsl/unox/master/unox.py" -o "/usr/local/bin/unison-fsmonitor" \ && chmod +x /usr/local/bin/unison-fsmonitor' cmd2 = 'sudo easy_install pip && sudo pip install macfsevents' Thor::Shell::Basic.new.say_status 'warning', 'Could not find unison-fsmonitor (for file watching) binary in $PATH. Please install unox before you continue, see https://github.com/hnsl/unox.', :yellow if Thor::Shell::Basic.new.yes?('Shall I install unison-fsmonitor for you? ') system cmd1 if $?.exitstatus > 0 raise('Failed to install unison-fsmonitor, please file an issue with the output of the error') end Thor::Shell::Basic.new.say_status 'ok','install macfsevents using pip (This will ask for sudo, since we use the system python)', :yellow system cmd2 if $?.exitstatus > 0 raise('Failed to install macfsevents, please file an issue with the output of the error') end else raise("Please install it, see https://github.com/hnsl/unox, or simply run :\n #{cmd1} && #{cmd2}") end end end |