class ZoomSlack::ProcessDetector::Mac

Constants

COMPILED_SCRIPT
SCRIPT

Attributes

open[RW]

Public Class Methods

new(open: Open3) click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 12
def initialize(open: Open3)
  self.open = open
end

Public Instance Methods

clean() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 21
def clean
  FileUtils.remove_dir(compiled_path) if Dir.exist?(compiled_path)
end
running?() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 16
def running?
  compile
  process_running?
end

Private Instance Methods

compile() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 29
def compile
  return if Dir.exist?(compiled_path)

  out, _err, _st = open.capture3("osacompile", "-o", compiled_path, source_path)
  out
end
compiled_path() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 41
def compiled_path
  @bin_path ||= File.join(Dir.tmpdir, COMPILED_SCRIPT)
end
process_running?() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 36
def process_running?
  out, _err, _st = open.capture3("osascript", compiled_path)
  out.chomp == "true"
end
source_path() click to toggle source
# File lib/zoom_slack/process_detector/mac.rb, line 45
def source_path
  @source_path ||= File.join(File.dirname(__FILE__), "source", SCRIPT)
end