Class: ExampleResource

Inherits:
Object
  • Object
show all
Defined in:
lib/templates/resource_pack/libraries/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alternate_path = nil) ⇒ ExampleResource

Returns a new instance of ExampleResource.



4
5
6
# File 'lib/templates/resource_pack/libraries/example.rb', line 4

def initialize(alternate_path = nil)
  @path = alternate_path || default_path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/templates/resource_pack/libraries/example.rb', line 16

def path
  @path
end

Instance Method Details

#default_pathObject



8
9
10
11
12
13
14
# File 'lib/templates/resource_pack/libraries/example.rb', line 8

def default_path
  if inspec.os.windows?
    'C:\example\bin\example.bat'
  else
    '/usr/bin/example'
  end
end

#versionObject



18
19
20
21
# File 'lib/templates/resource_pack/libraries/example.rb', line 18

def version
  raw_result = inspec.command("#{path} --version").stdout
  raw_result.split.first
end