Class: InfraTestingHelpers::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/infra_testing_helpers/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site_code, module_path, project_root, project_mount_point) ⇒ Site

Returns a new instance of Site.



6
7
8
9
10
11
12
# File 'lib/infra_testing_helpers/site.rb', line 6

def initialize(site_code, module_path, project_root, project_mount_point)
  @site_code = site_code
  @module_path = module_path
  @project_root = project_root
  @project_mount_point = project_mount_point
  @manifest_code = ""
end

Instance Attribute Details

#module_pathObject (readonly)

Returns the value of attribute module_path.



14
15
16
# File 'lib/infra_testing_helpers/site.rb', line 14

def module_path
  @module_path
end

Instance Method Details

#add_manifest(manifest) ⇒ Object



23
24
25
# File 'lib/infra_testing_helpers/site.rb', line 23

def add_manifest(manifest)
  @manifest_code << "#{manifest}\n"
end

#manifest_fileObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/infra_testing_helpers/site.rb', line 27

def manifest_file
  file = Tempfile.new(['infra-testing-helpers', '.pp'], @project_root)
  begin
    file.puts puppet_code
    file.fsync
    yield("#{@project_mount_point}/#{File.basename(file.path)}") if block_given?
  ensure 
    file.close
    file.unlink
  end
end

#puppet_codeObject



39
40
41
# File 'lib/infra_testing_helpers/site.rb', line 39

def puppet_code
  "#{@site_code}\n#{@manifest_code}"
end