Class: Dauphin::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/dauphin/runtime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exepath = nil) ⇒ Runtime

Returns a new instance of Runtime.



7
8
9
10
11
12
13
# File 'lib/dauphin/runtime.rb', line 7

def initialize(exepath=nil)
  puts "Making new Runtime(#{self.inspect}), path: #{exepath.inspect}"
  @path = exepath || default_executable_path
  puts "default_executable_path: #{path}"
  puts "Path: #{@path}"
  check_for_binary
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/dauphin/runtime.rb', line 5

def path
  @path
end

Instance Method Details

#check_for_binaryObject



15
16
17
18
# File 'lib/dauphin/runtime.rb', line 15

def check_for_binary
  raise 'Cannot find prince command-line app in $PATH' if !path || path.length == 0
  raise "Cannot run executable at #{path}" unless File.executable? path
end

#default_executable_pathObject



20
21
22
23
24
25
26
27
# File 'lib/dauphin/runtime.rb', line 20

def default_executable_path
  if Platform.windows?
    return 'C:/Program Files/Prince/Engine/bin/prince'
  end
  if Platform.linux?
    `which prince`.chomp
  end
end

#join(options) ⇒ Object



29
30
31
# File 'lib/dauphin/runtime.rb', line 29

def join(options)
  ([@path] + Array(options)).join(' ')
end