Class: Aric::ScriptRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/aric/script_runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ ScriptRunner



11
12
13
# File 'lib/aric/script_runner.rb', line 11

def initialize(file_name)
  @file_name = file_name.to_s
end

Class Method Details

.run(file_name, args = []) ⇒ Object



6
7
8
# File 'lib/aric/script_runner.rb', line 6

def run(file_name, args = [])
  new(file_name).run(args)
end

Instance Method Details

#run(args = []) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/aric/script_runner.rb', line 15

def run(args = [])
  args = Array(args).join(' ')
  stdout, stderr, status = Open3.capture3("osascript -l JavaScript #{script_file_path} #{args}")
  puts nil, '<============================================================ DEBUG OUTPUT START HERE'
  p stdout, stderr, status
  puts '<============================================================ DEBUG OUTPUT CLOSE HERE', nil
  raise stderr unless status.success?
  stdout.strip
end