Class: Serverspec::Type::WindowsScheduledTask

Inherits:
Base
  • Object
show all
Defined in:
lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ WindowsScheduledTask

Returns a new instance of WindowsScheduledTask.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 10

def initialize(name)
  @name = name
  @runner = Specinfra::Runner

  stdout = `schtasks /query /tn \"#{name}\" /fo csv /v`
  return unless $?.success?
  csv = CSV.parse(stdout)
  @exists = true
  headers = csv[0]
  data = csv[1]
  @state = data[headers.index{|x|x=="Status"}]
  @user_id = data[headers.index{|x|x=="Run As User"}]
  @run_level = data[headers.index{|x|x=="Logon Mode"}]
  @schedule_type = data[headers.index{|x|x=="Schedule Type"}].strip
  @repeat_every = data[headers.index{|x|x=="Repeat: Every"}]
end

Instance Attribute Details

#repeat_everyObject (readonly)

Returns the value of attribute repeat_every.



7
8
9
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 7

def repeat_every
  @repeat_every
end

#run_levelObject (readonly)

Returns the value of attribute run_level.



7
8
9
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 7

def run_level
  @run_level
end

#schedule_typeObject (readonly)

Returns the value of attribute schedule_type.



7
8
9
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 7

def schedule_type
  @schedule_type
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 7

def state
  @state
end

#user_idObject (readonly)

Returns the value of attribute user_id.



7
8
9
# File 'lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb', line 7

def user_id
  @user_id
end