class Boxen::Service

Attributes

name[R]

Public Class Methods

list() click to toggle source
# File lib/boxen/service.rb, line 7
def self.list
  files.collect do |service|
    new(human_name(service))
  end
end
list_enabled() click to toggle source
# File lib/boxen/service.rb, line 13
def self.list_enabled
  prefix = /^dev\./
  enabled = capture_output("sudo /bin/launchctl list").split("\n").map { |l| l.split(/\s/) }.map(&:last)
  names = enabled.grep(prefix).map { |name| name.sub(prefix, "") }.compact
  names.map { |name| new(name) }
end
new(name) click to toggle source
# File lib/boxen/service.rb, line 20
def initialize(name)
  @name = name
end

Private Class Methods

capture_output(command) click to toggle source
# File lib/boxen/service.rb, line 38
def self.capture_output(command)
  `#{command}`
end
files() click to toggle source
# File lib/boxen/service.rb, line 50
def self.files
  Dir["#{location}/dev.*.plist"]
end
human_name(service) click to toggle source
# File lib/boxen/service.rb, line 54
def self.human_name(service)
  service.match(/dev\.(.+)\.plist$/)[1]
end
location() click to toggle source
# File lib/boxen/service.rb, line 46
def self.location
  "/Library/LaunchDaemons"
end

Public Instance Methods

disable() click to toggle source
# File lib/boxen/service.rb, line 32
def disable
  Boxen::Util.sudo('/bin/launchctl', 'unload', '-w', location)
end
enable() click to toggle source
# File lib/boxen/service.rb, line 28
def enable
  Boxen::Util.sudo('/bin/launchctl', 'load', '-w', location)
end
to_s() click to toggle source
# File lib/boxen/service.rb, line 24
def to_s
  name
end

Private Instance Methods

location() click to toggle source
# File lib/boxen/service.rb, line 42
def location
  "#{self.class.location}/dev.#{name}.plist"
end