Class: DeployRubygem::InspecTestor

Inherits:
Object
  • Object
show all
Defined in:
lib/deploy_rubygem/inspectestor.rb

Overview

Using Inspec to deploy and manage Inspec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inspec_path, input_file = nil, waiver_file = nil) ⇒ InspecTestor

Returns a new instance of InspecTestor.



14
15
16
17
18
# File 'lib/deploy_rubygem/inspectestor.rb', line 14

def initialize(inspec_path, input_file = nil, waiver_file = nil)
  @inspec_path = inspec_path
  @input_file = input_file
  @waiver_file = waiver_file
end

Instance Attribute Details

#input_fileObject (readonly)

Returns the value of attribute input_file.



12
13
14
# File 'lib/deploy_rubygem/inspectestor.rb', line 12

def input_file
  @input_file
end

#inspec_pathObject (readonly)

Returns the value of attribute inspec_path.



12
13
14
# File 'lib/deploy_rubygem/inspectestor.rb', line 12

def inspec_path
  @inspec_path
end

#waiver_fileObject (readonly)

Returns the value of attribute waiver_file.



12
13
14
# File 'lib/deploy_rubygem/inspectestor.rb', line 12

def waiver_file
  @waiver_file
end

Instance Method Details

#applyObject



24
25
26
27
28
29
30
31
32
# File 'lib/deploy_rubygem/inspectestor.rb', line 24

def apply
  puts "ActuaL Dir #{Dir.pwd}"
  puts "inspec_name = #{inspec_name}"
  puts "input_file = #{input_file}"
  puts "waiver_file = #{waiver_file}"

  check
  system("chef exec inspec exec #{inspec_path} #{inspec_options.join(' ')}")
end

#cleanObject



48
49
50
51
# File 'lib/deploy_rubygem/inspectestor.rb', line 48

def clean
  FileUtils.rm_rf(vendor_folder)
  FileUtils.rm_f(lock_file)
end

#inspec_nameObject



20
21
22
# File 'lib/deploy_rubygem/inspectestor.rb', line 20

def inspec_name
  File.basename(inspec_path)
end

#save_as_html(html_file) ⇒ Object



39
40
41
42
# File 'lib/deploy_rubygem/inspectestor.rb', line 39

def save_as_html(html_file)
  check
  system("chef exec inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter html:#{html_file}")
end

#test_jsonObject



44
45
46
# File 'lib/deploy_rubygem/inspectestor.rb', line 44

def test_json
  @test_json ||= InspecTestorResult.new(as_json)
end

#updateObject



34
35
36
37
# File 'lib/deploy_rubygem/inspectestor.rb', line 34

def update
  clean
  system("chef exec inspec vendor #{inspec_path} ")
end