Class: Watcher::LaunchAgentManager
- Inherits:
-
LaunchAgentManager
- Object
- LaunchAgentManager
- Watcher::LaunchAgentManager
- Defined in:
- lib/kanseishitsu/watch.rb
Overview
Define class LaunchAgentManager
Constant Summary
Constants included from LaunchAgentManagerConstants
LaunchAgentManagerConstants::BOOTOUT_TEMPLATE, LaunchAgentManagerConstants::INTERVALS, LaunchAgentManagerConstants::LABEL_NAMESPACE, LaunchAgentManagerConstants::LAUNCHCTL_TEMPLATE, LaunchAgentManagerConstants::LAUNCH_AGENTS_DIR_PATH, LaunchAgentManagerConstants::REMOVE_TEMPLATE, LaunchAgentManagerConstants::SCHEDULE_PARTS_COUNT, LaunchAgentManagerConstants::SUCCESS_MESSAGE, LaunchAgentManagerConstants::VERSION
Constants included from XMLHelperInstanceMethods
XMLHelperInstanceMethods::CDATA_PATTERN, XMLHelperInstanceMethods::KEYS_REQUIRING_CDATA
Constants included from LaunchAgentConstants
LaunchAgentConstants::BOOTOUT_TEMPLATE, LaunchAgentConstants::CDATA_PATTERN, LaunchAgentConstants::DEFAULT_ENCODING, LaunchAgentConstants::DOCTYPES, LaunchAgentConstants::DOCTYPE_ELEMENT, LaunchAgentConstants::INTERVALS, LaunchAgentConstants::INTERVAL_XPATH_TEMPLATE, LaunchAgentConstants::KEYS_REQUIRING_CDATA, LaunchAgentConstants::LABEL_NAMESPACE, LaunchAgentConstants::LABEL_XPATH, LaunchAgentConstants::LAUNCHCTL_TEMPLATE, LaunchAgentConstants::LAUNCH_AGENTS_DIR_PATH, LaunchAgentConstants::LOCAL_STRING_XPATH, LaunchAgentConstants::ON_LOGIN, LaunchAgentConstants::PROGRAM_ARGUMENTS_XPATH, LaunchAgentConstants::REMOVE_TEMPLATE, LaunchAgentConstants::SCHEDULE_PARTS_COUNT, LaunchAgentConstants::SCHEDULE_XPATH_TEMPLATE, LaunchAgentConstants::START_CALENDAR_INTERVAL_XPATH, LaunchAgentConstants::SUCCESS_MESSAGE, LaunchAgentConstants::WATCH_PATHS_XPATH
Instance Attribute Summary
Attributes inherited from LaunchAgentManager
Instance Method Summary collapse
-
#define_plist_contents(label, args, *watch_paths) ⇒ Object
Define the plist contents rubocop: disable Metrics/MethodLength.
-
#launch_agent_labels ⇒ Object
Return a list of all user launch agent labels.
Methods inherited from LaunchAgentManager
Methods included from LaunchAgentManagerInstanceMethods
#create_launchd_job, #derive_calendar_interval, #derive_job_label_from_executable, #executable?, #execute, #explicit_which, #extract_program_path, #find_executable_in_path, #list_launch_agent_labels, #load_launchd_job, #portable_which, #remove_cron_job, #save_plist, #show_all_cron_jobs
Methods included from XMLHelperInstanceMethods
Methods included from LaunchAgentManagementInstanceMethods
#create_launch_agent, #define_calendar_interval, #derive_job_label_from_file_path, #doctype, #execute, #extract_program_path, #generate_plist_xml, #list_launch_agent_labels, #load_launchd_job, #parse_plist, #parse_schedule, #remove_launch_agent, #save_plist, #show_all_launch_agents
Methods included from Which
#executable?, #explicit_which, #find_executable_in_path, #portable_which
Constructor Details
This class inherits a constructor from LaunchAgentManager
Instance Method Details
#define_plist_contents(label, args, *watch_paths) ⇒ Object
Define the plist contents rubocop: disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kanseishitsu/watch.rb', line 33 def define_plist_contents(label, args, *watch_paths) definition = {} definition['Label'] = label definition['WatchPaths'] = watch_paths unless (system_path = ENV.fetch('PATH', nil)).nil? || system_path.empty? definition['EnvironmentVariables'] = {} definition['EnvironmentVariables']['PATH'] = system_path end if args.length == 1 definition['Program'] = args.first else definition['ProgramArguments'] = args end definition end |
#launch_agent_labels ⇒ Object
Return a list of all user launch agent labels
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kanseishitsu/watch.rb', line 51 def launch_agent_labels labels = [] Dir.glob(File.join(LAUNCH_AGENTS_DIR_PATH, '*.plist')).each do |file_path| doc = File.open(file_path) { |file| Nokogiri::XML(file) } watch_paths = doc.xpath(WATCH_PATHS_XPATH) next if watch_paths.nil? || watch_paths.empty? label_node = doc.xpath(LABEL_XPATH) labels << label_node.text unless label_node.empty? end labels end |