class LaunchdTools::LaunchdJob
Attributes
attributes[R]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/launchd_tools/launchd_job.rb, line 4 def initialize(attributes = {}) @attributes = attributes end
Public Instance Methods
environment_variables()
click to toggle source
# File lib/launchd_tools/launchd_job.rb, line 8 def environment_variables attributes.fetch('EnvironmentVariables', {}) end
program_arguments()
click to toggle source
# File lib/launchd_tools/launchd_job.rb, line 12 def program_arguments attributes.fetch('ProgramArguments', []) end
shellescape(str)
click to toggle source
from ruby's shellescape included here for ruby 1.8 compatibility
# File lib/launchd_tools/launchd_job.rb, line 23 def shellescape(str) str = str.to_s # An empty argument will be skipped, so return empty quotes. return "''" if str.empty? str = str.dup # Treat multibyte characters as is. It is caller's responsibility # to encode the string in the right encoding for the shell # environment. str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1") # A LF cannot be escaped with a backslash because a backslash + LF # combo is regarded as line continuation and simply ignored. str.gsub!(/\n/, "'\n'") return str end
to_s()
click to toggle source
# File lib/launchd_tools/launchd_job.rb, line 16 def to_s escaped_args = program_arguments.map {|arg| shellescape(arg) } puts (environment_variables + escaped_args).join(" ") end