Class: Berkshelf::CookbookGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/berkshelf/cookbook_generator.rb

Constant Summary collapse

LICENSE_MAP =
{
  "apachev2" => "Apache 2.0",
  "gplv2"    => "GNU Public License 2.0",
  "gplv3"    => "GNU Public License 3.0",
  "mit"      => "MIT",
  "reserved" => "All rights reserved",
}.freeze

Constants inherited from BaseGenerator

BaseGenerator::PATTERNS

Instance Method Summary collapse

Methods inherited from BaseGenerator

source_root

Instance Method Details

#generateObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/berkshelf/cookbook_generator.rb', line 60

def generate
  case options[:pattern]
  when "library"
    empty_directory target.join("libraries")
    empty_directory target.join("providers")
    empty_directory target.join("resources")
  when "wrapper"
    empty_directory target.join("attributes")
    empty_directory target.join("recipes")
    template "default_recipe.erb", target.join("recipes/default.rb")
  when "environment", "application"
    empty_directory target.join("files/default")
    empty_directory target.join("templates/default")
    empty_directory target.join("attributes")
    empty_directory target.join("libraries")
    empty_directory target.join("providers")
    empty_directory target.join("recipes")
    empty_directory target.join("resources")
    template "default_recipe.erb", target.join("recipes/default.rb")
  end

  template 'metadata.rb.erb', target.join('metadata.rb')
  template license_file, target.join('LICENSE')
  template 'README.md.erb', target.join('README.md')
  template 'CHANGELOG.md.erb', target.join('CHANGELOG.md')

  Berkshelf::InitGenerator.new([target], options.merge(default_options)).invoke_all
end