Class: Pixiebox::Service

Inherits:
Object
  • Object
show all
Includes:
Utils::Output, Utils::Visitable
Defined in:
lib/pixiebox/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Output

#display_error, #display_info, #display_line, #display_status

Methods included from Utils::Visitable

#accept

Constructor Details

#initialize(os) ⇒ Service

Returns a new instance of Service.



8
9
10
# File 'lib/pixiebox/service.rb', line 8

def initialize(os)
  @os = os
end

Instance Attribute Details

#osObject (readonly)

Returns the value of attribute os.



6
7
8
# File 'lib/pixiebox/service.rb', line 6

def os
  @os
end

Instance Method Details

#add(services) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/pixiebox/service.rb', line 19

def add(services)
  services.each { |service| accept(Commands::AddService.new(service)) }
  accept(Commands::Restart.new)
rescue StandardError => e
  display_error e
  exit 1
end

#build(service = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/pixiebox/service.rb', line 12

def build(service=nil)
  accept(Commands::BuildService.new(service))
rescue StandardError => e
  display_error e
  exit 1
end

#listObject



42
43
44
45
46
47
48
# File 'lib/pixiebox/service.rb', line 42

def list()
  accept(Commands::UpdatePackages.new)
  accept(Commands::ListServices.new)
rescue StandardError => e
  display_error e
  exit 1
end

#remove(type = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pixiebox/service.rb', line 28

def remove(type = nil)
  return if type.nil?
  accept(Commands::RemoveService.new(type))
  accept(Commands::Restart.new)
rescue Errors::ServiceNotInstalled
  display_service_not_installed type
rescue Errors::ServiceNotImplemented
  display_service_not_available type
rescue StandardError => e
  display_error e
  exit 1
end