Class: Bosh::Director::CompressedRenderedJobTemplates

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/compressed_rendered_job_templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CompressedRenderedJobTemplates

Returns a new instance of CompressedRenderedJobTemplates.



6
7
8
# File 'lib/bosh/director/compressed_rendered_job_templates.rb', line 6

def initialize(path)
  @path = path
end

Instance Method Details

#contentsObject



20
21
22
# File 'lib/bosh/director/compressed_rendered_job_templates.rb', line 20

def contents
  File.open(@path, 'r')
end

#sha1Object



24
25
26
# File 'lib/bosh/director/compressed_rendered_job_templates.rb', line 24

def sha1
  Digest::SHA1.file(@path).hexdigest
end

#write(rendered_templates) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/bosh/director/compressed_rendered_job_templates.rb', line 10

def write(rendered_templates)
  Dir.mktmpdir do |dir|
    writer = RenderedTemplatesWriter.new
    writer.write(rendered_templates, dir)

    tar_gzipper = TarGzipper.new
    tar_gzipper.compress(dir, %w(.), @path)
  end
end