Class: MacSetup::ServicesInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/mac_setup/services_installer.rb

Constant Summary collapse

LAUNCH_AGENTS_PATH =
File.expand_path("~/Library/LaunchAgents")
SERVICES_TAP =
"homebrew/services"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, status) ⇒ ServicesInstaller

Returns a new instance of ServicesInstaller.



16
17
18
19
20
# File 'lib/mac_setup/services_installer.rb', line 16

def initialize(config, status)
  @config = config
  @status = status
  @services = config.services
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/mac_setup/services_installer.rb', line 10

def config
  @config
end

#running_servicesObject (readonly)

Returns the value of attribute running_services.



10
11
12
# File 'lib/mac_setup/services_installer.rb', line 10

def running_services
  @running_services
end

#servicesObject (readonly)

Returns the value of attribute services.



10
11
12
# File 'lib/mac_setup/services_installer.rb', line 10

def services
  @services
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/mac_setup/services_installer.rb', line 10

def status
  @status
end

Class Method Details

.run(config, status) ⇒ Object



12
13
14
# File 'lib/mac_setup/services_installer.rb', line 12

def self.run(config, status)
  new(config, status).run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mac_setup/services_installer.rb', line 22

def run
  return if services.none?

  MacSetup.log "Installing services..."

  FileUtils.mkdir_p(LAUNCH_AGENTS_PATH)
  tap_services
  get_running_services

  services.each { |service| install_service(service) }
end