Class: NormalizeRunner

Inherits:
Object
  • Object
show all
Includes:
Common, PackerExec
Defined in:
lib/bento/normalize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PackerExec

#for_packer_run_with, #write_box_metadata, #write_var_file

Methods included from Common

#banner, #box_metadata, #build_list, #builds_yml, #duration, #info, #macos?, #metadata_files, #private_box?, #unix?, #vc_account, #warn, #windows?

Constructor Details

#initialize(opts) ⇒ NormalizeRunner

Returns a new instance of NormalizeRunner.



9
10
11
12
13
14
# File 'lib/bento/normalize.rb', line 9

def initialize(opts)
  @templates = opts.template_files
  @debug = opts.debug
  @modified = []
  @build_timestamp = Time.now.gmtime.strftime("%Y%m%d%H%M%S")
end

Instance Attribute Details

#build_timestampObject (readonly)

Returns the value of attribute build_timestamp.



7
8
9
# File 'lib/bento/normalize.rb', line 7

def build_timestamp
  @build_timestamp
end

#debugObject (readonly)

Returns the value of attribute debug.



7
8
9
# File 'lib/bento/normalize.rb', line 7

def debug
  @debug
end

#override_versionObject (readonly)

Returns the value of attribute override_version.



7
8
9
# File 'lib/bento/normalize.rb', line 7

def override_version
  @override_version
end

#templatesObject (readonly)

Returns the value of attribute templates.



7
8
9
# File 'lib/bento/normalize.rb', line 7

def templates
  @templates
end

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bento/normalize.rb', line 16

def start
  banner("Normalizing for templates:")
  templates.each { |t| puts "- #{t}" }
  time = Benchmark.measure do
    templates.each do |file|
      dir = file.split("/")[0]
      template = file.split("/")[1]
      Dir.chdir dir
      validate(template)
      Dir.chdir("..")
    end
  end
  unless @modified.empty?
    info("")
    info("The following templates were modified:")
    @modified.sort.each { |template| info("  * #{template}") }
  end
  banner("Normalizing finished in #{duration(time.real)}.")
end