Class: Specinfra::Command::Windows::Base::Service
- Inherits:
-
Specinfra::Command::Windows::Base
- Object
- Specinfra::Command::Windows::Base
- Specinfra::Command::Windows::Base::Service
- Defined in:
- lib/specinfra/command/windows/base/service.rb
Class Method Summary collapse
- .check_has_property(service, property) ⇒ Object
- .check_has_start_mode(service, mode) ⇒ Object
- .check_is_enabled(service, level = nil) ⇒ Object
- .check_is_installed(service) ⇒ Object
- .check_is_running(service) ⇒ Object
- .get_property(service) ⇒ Object
Methods inherited from Specinfra::Command::Windows::Base
Class Method Details
.check_has_property(service, property) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/specinfra/command/windows/base/service.rb', line 31 def check_has_property(service, property) command = [] property.keys.each do |key| value= property[key] command << "(FindService -name '#{service}').#{key} -eq '#{value}'" end executable = command.join(' -and ') Backend::PowerShell::Command.new do using 'find_service.ps1' exec executable end end |
.check_has_start_mode(service, mode) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/specinfra/command/windows/base/service.rb', line 10 def check_has_start_mode(service, mode) Backend::PowerShell::Command.new do using 'find_service.ps1' exec "'#{mode}' -match (FindService -name '#{service}').StartMode -and (FindService -name '#{service}') -ne $null" end end |
.check_is_enabled(service, level = nil) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/specinfra/command/windows/base/service.rb', line 17 def check_is_enabled(service, level=nil) Backend::PowerShell::Command.new do using 'find_service.ps1' exec "(FindService -name '#{service}').StartMode -eq 'Auto'" end end |
.check_is_installed(service) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/specinfra/command/windows/base/service.rb', line 3 def check_is_installed(service) Backend::PowerShell::Command.new do using 'find_service.ps1' exec "@(FindService -name '#{service}').count -gt 0" end end |
.check_is_running(service) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/specinfra/command/windows/base/service.rb', line 24 def check_is_running(service) Backend::PowerShell::Command.new do using 'find_service.ps1' exec "(FindService -name '#{service}').State -eq 'Running'" end end |
.get_property(service) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/specinfra/command/windows/base/service.rb', line 44 def get_property(service) Backend::PowerShell::Command.new do using 'find_service.ps1' exec "(FindService -name '#{service}') | Select-Object *" end end |