Module: PDFKit::OS

Defined in:
lib/pdfkit/os.rb

Class Method Summary collapse

Class Method Details

.host_is_windows?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/pdfkit/os.rb', line 5

def self.host_is_windows?
  !(RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince/).nil?
end

.shell_escape_for_os(args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/pdfkit/os.rb', line 9

def self.shell_escape_for_os(args)
  if (host_is_windows?)
    # Windows reserved shell characters are: & | ( ) < > ^
    # See http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120
    args.map { |arg| arg.gsub(/([&|()<>^])/,'^\1') }.join(" ")
  else
    args.shelljoin
  end
end