Class: Opal::CliRunners::Applescript

Inherits:
Object
  • Object
show all
Defined in:
lib/opal/cli_runners/applescript.rb

Defined Under Namespace

Classes: MissingAppleScript, MissingJavaScriptSupport

Class Method Summary collapse

Class Method Details

.call(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/opal/cli_runners/applescript.rb', line 8

def self.call(data)
  unless system('which osalang > /dev/null')
    raise MissingJavaScriptSupport, 'JavaScript Automation is only supported by OS X Yosemite and above.'
  end

  SystemRunner.call(data) do |tempfile|
    tempfile.puts "'';" # OSAScript will output the last thing
    ['osascript', '-l', 'JavaScript', tempfile.path, *data[:argv]]
  end
rescue Errno::ENOENT
  raise MissingAppleScript, 'AppleScript is only available on Mac OS X.'
end