module DockerSync::Dependencies::Unox

Constants

FAILED_TO_REMOVE_LEGACY_UNOX
LEGACY_UNOX_WARNING
UNSUPPORTED_FSMONITOR

Public Class Methods

available?() click to toggle source
# File lib/docker-sync/dependencies/unox.rb, line 15
def self.available?
  # should never have been called anyway - fix the call that it should check for the OS
  raise 'Unox cannot be available for other platforms then MacOS' unless Environment.mac?

  return true if brew_package_installed?('unox')
  return false unless brew_package_installed?('unison-fsmonitor')

  say_status 'warning', UNSUPPORTED_FSMONITOR, :yellow unless @unsupported_fsmonitor_warning_displayed
  @unsupported_fsmonitor_warning_displayed = true
  true
end
brew_package_installed?(name) click to toggle source
# File lib/docker-sync/dependencies/unox.rb, line 48
def self.brew_package_installed?(name)
  cmd = "brew list #{name} > /dev/null 2>&1"
  Environment.system(cmd)
end
cleanup_non_brew_version!() click to toggle source
# File lib/docker-sync/dependencies/unox.rb, line 35
def self.cleanup_non_brew_version!
  return unless non_brew_version_installed?
  uninstall_cmd = 'sudo rm -f /usr/local/bin/unison-fsmonitor'
  say_status 'warning', LEGACY_UNOX_WARNING, :yellow
  raise(FAILED_TO_REMOVE_LEGACY_UNOX) unless yes?('Uninstall legacy unison-fsmonitor (unox)? (y/N)')
  say_status 'command', uninstall_cmd, :white
  Environment.system(uninstall_cmd)
end
ensure!() click to toggle source
# File lib/docker-sync/dependencies/unox.rb, line 27
def self.ensure!
  return if available?
  raise 'Unox cannot be installed on other platforms then MacOS' unless Environment.mac?

  cleanup_non_brew_version!
  PackageManager.install_package('eugenmayer/dockersync/unox')
end
non_brew_version_installed?() click to toggle source
# File lib/docker-sync/dependencies/unox.rb, line 44
def self.non_brew_version_installed?
  !available? && File.exist?('/usr/local/bin/unison-fsmonitor')
end