Class: ChefGen::Flavors

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_gen/flavors.rb

Overview

a plugin framework for creating ChefDK generator flavors

Constant Summary collapse

VERSION =

the version of the gem

'0.9.0'

Class Method Summary collapse

Class Method Details

.pathString

return the path to to the copy of the generator cookbook for the selected ChefGen Flavor

Returns:

  • (String)

    the path to the code_generator cookbook



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chef_gen/flavors.rb', line 20

def path
  # select the plugin to use
  @plugins = plugins.dup
  add_builtin_template
  selected = plugin_from_env ||
             only_plugin ||
             prompt_for_plugin ||
             fail('no ChefGen flavors found!')
  $stdout.puts "using ChefGen flavor '#{selected}'"

  # return early if we're using the builtin flavor
  return nil if :builtin == selected

  # get a temp dir
  tmpdir = create_tmpdir(selected)

  # call the content hooks in the flavor
  @plugins[selected].new(temp_path: tmpdir).add_content

  # return the temporary directory
  tmpdir
end