Class: Boxen::Service
- Inherits:
-
Object
- Object
- Boxen::Service
- Defined in:
- lib/boxen/service.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(name) ⇒ Service
constructor
A new instance of Service.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Service
Returns a new instance of Service.
20 21 22 |
# File 'lib/boxen/service.rb', line 20 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/boxen/service.rb', line 5 def name @name end |
Class Method Details
.list ⇒ Object
7 8 9 10 11 |
# File 'lib/boxen/service.rb', line 7 def self.list files.collect do |service| new(human_name(service)) end end |
.list_enabled ⇒ Object
13 14 15 16 17 18 |
# 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 |
Instance Method Details
#disable ⇒ Object
32 33 34 |
# File 'lib/boxen/service.rb', line 32 def disable Boxen::Util.sudo('/bin/launchctl', 'unload', '-w', location) end |
#enable ⇒ Object
28 29 30 |
# File 'lib/boxen/service.rb', line 28 def enable Boxen::Util.sudo('/bin/launchctl', 'load', '-w', location) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/boxen/service.rb', line 24 def to_s name end |