Module: BinInstall::Brew::Service
- Defined in:
- lib/bin_install/brew/service.rb
Class Method Summary collapse
- .restart(service) ⇒ Object
- .restart!(service) ⇒ Object
- .run(service) ⇒ Object
- .run!(service) ⇒ Object
- .services ⇒ Object
- .start(service) ⇒ Object
- .start!(service) ⇒ Object
- .started?(service) ⇒ Boolean
- .stop(service) ⇒ Object
- .stop!(service) ⇒ Object
- .stopped?(service) ⇒ Boolean
Class Method Details
.restart(service) ⇒ Object
52 53 54 |
# File 'lib/bin_install/brew/service.rb', line 52 def self.restart(service) system("brew services restart #{service}") end |
.restart!(service) ⇒ Object
56 57 58 |
# File 'lib/bin_install/brew/service.rb', line 56 def self.restart!(service) BinInstall.system!("brew services restart #{service}") end |
.run(service) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/bin_install/brew/service.rb', line 4 def self.run(service) if started?(service) puts "Service #{service} already started. Skipping #{service} install.".blue else system("brew services run #{service}") end end |
.run!(service) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bin_install/brew/service.rb', line 12 def self.run!(service) if started?(service) puts "Service #{service} already started. Skipping #{service} install.".blue else BinInstall.system!("brew services run #{service}") end end |
.services ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bin_install/brew/service.rb', line 68 def self.services output = `brew services list` lines = output.split("\n") lines.shift # Remove header from table. lines.map do |row| columns = row.split(' ') [columns[0].to_sym, columns[1].to_sym] end.to_h end |
.start(service) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bin_install/brew/service.rb', line 20 def self.start(service) if started?(service) puts "Service #{service} already started. Skipping #{service} install.".blue else system("brew services start #{service}") end end |
.start!(service) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bin_install/brew/service.rb', line 28 def self.start!(service) if started?(service) puts "Service #{service} already started. Skipping #{service} install.".blue else BinInstall.system!("brew services start #{service}") end end |
.started?(service) ⇒ Boolean
60 61 62 |
# File 'lib/bin_install/brew/service.rb', line 60 def self.started?(service) services[service.to_sym] == :started end |
.stop(service) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/bin_install/brew/service.rb', line 36 def self.stop(service) if stopped?(service) puts "Service #{service} already stopped. Skipping #{service} install.".blue else system("brew services stop #{service}") end end |
.stop!(service) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/bin_install/brew/service.rb', line 44 def self.stop!(service) if stopped?(service) puts "Service #{service} already stopped. Skipping #{service} install.".blue else BinInstall.system!("brew services stop #{service}") end end |
.stopped?(service) ⇒ Boolean
64 65 66 |
# File 'lib/bin_install/brew/service.rb', line 64 def self.stopped?(service) services[service.to_sym] == :stopped end |