Class: Unit
- Inherits:
-
Object
- Object
- Unit
- Defined in:
- lib/tomo/testing/systemctl.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #enable ⇒ Object
-
#initialize(name, spec) ⇒ Unit
constructor
A new instance of Unit.
- #restart ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(name, spec) ⇒ Unit
Returns a new instance of Unit.
72 73 74 75 |
# File 'lib/tomo/testing/systemctl.rb', line 72 def initialize(name, spec) @name = name @spec = spec end |
Class Method Details
.find(name) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/tomo/testing/systemctl.rb', line 64 def self.find(name) path = File.join(File.("~/.config/systemd/user/"), name) raise "Unknown unit: #{name}" unless File.file?(path) return Service.new(name, File.read(path)) if name.end_with?(".service") new(name, File.read(path)) end |
Instance Method Details
#enable ⇒ Object
77 78 79 |
# File 'lib/tomo/testing/systemctl.rb', line 77 def enable with_persistent_state { |state| state[:enabled] = true } end |
#restart ⇒ Object
94 95 96 |
# File 'lib/tomo/testing/systemctl.rb', line 94 def restart must_be_enabled! end |
#start ⇒ Object
86 87 88 |
# File 'lib/tomo/testing/systemctl.rb', line 86 def start must_be_enabled! end |
#status ⇒ Object
81 82 83 84 |
# File 'lib/tomo/testing/systemctl.rb', line 81 def status puts "● #{name}" puts " Loaded: loaded (enabled; vendor preset: enabled)" if enabled? end |
#stop ⇒ Object
90 91 92 |
# File 'lib/tomo/testing/systemctl.rb', line 90 def stop must_be_enabled! end |