Class: Princely::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/princely/executable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Executable

Returns a new instance of Executable.



5
6
7
8
9
# File 'lib/princely/executable.rb', line 5

def initialize(path=nil)
  @path = path || default_executable_path

  check_for_executable
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/princely/executable.rb', line 3

def path
  @path
end

Instance Method Details

#check_for_executableObject



11
12
13
14
# File 'lib/princely/executable.rb', line 11

def check_for_executable
  raise "Cannot find prince command-line app in $PATH" if !@path || @path.length == 0
  raise "Cannot find prince command-line app at #{@exe_path}" unless File.executable?(@path)
end

#default_executable_pathObject



16
17
18
19
20
21
22
# File 'lib/princely/executable.rb', line 16

def default_executable_path
  if Princely.ruby_platform =~ /mswin32|minigw32/
    "C:/Program Files/Prince/Engine/bin/prince"
  else
    `which prince`.chomp
  end
end

#join(options) ⇒ Object



24
25
26
# File 'lib/princely/executable.rb', line 24

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