lib/berkshelf/cookbook_generator.rb in berkshelf-2.0.0.beta vs lib/berkshelf/cookbook_generator.rb in berkshelf-2.0.0

- old
+ new

@@ -1,8 +1,9 @@ module Berkshelf - # @author Jamie Winsor <reset@riotgames.com> class CookbookGenerator < BaseGenerator + require_relative 'config' + argument :name, type: :string, required: true class_option :skip_vagrant, @@ -11,10 +12,15 @@ class_option :skip_git, type: :boolean, default: false + class_option :skip_test_kitchen, + type: :boolean, + default: false, + desc: 'Skip adding a testing environment to your cookbook' + class_option :foodcritic, type: :boolean, default: false class_option :chef_minitest, @@ -40,23 +46,23 @@ class_option :maintainer_email, type: :string, default: Berkshelf::Config.instance.cookbook.email def generate - empty_directory target.join("files/default") - empty_directory target.join("templates/default") - empty_directory target.join("attributes") - empty_directory target.join("definitions") - empty_directory target.join("libraries") - empty_directory target.join("providers") - empty_directory target.join("recipes") - empty_directory target.join("resources") + empty_directory target.join('files/default') + empty_directory target.join('templates/default') + empty_directory target.join('attributes') + empty_directory target.join('definitions') + 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") - template "metadata.rb.erb", target.join("metadata.rb") - template license_file, target.join("LICENSE") - template "README.md.erb", target.join("README.md") + template 'default_recipe.erb', target.join('recipes/default.rb') + template 'metadata.rb.erb', target.join('metadata.rb') + template license_file, target.join('LICENSE') + template 'README.md.erb', target.join('README.md') Berkshelf::InitGenerator.new([target], options.merge(default_options)).invoke_all end private @@ -65,15 +71,15 @@ content.split("\n").collect { |s| "# #{s}" }.join("\n") end def license_name case options[:license] - when "apachev2"; "Apache 2.0" - when "gplv2"; "GNU Public License 2.0" - when "gplv3"; "GNU Public License 3.0" - when "mit"; "MIT" - when "reserved"; "All rights reserved" + when 'apachev2'; 'Apache 2.0' + when 'gplv2'; 'GNU Public License 2.0' + when 'gplv3'; 'GNU Public License 3.0' + when 'mit'; 'MIT' + when 'reserved'; 'All rights reserved' else raise Berkshelf::InternalError, "Unknown license: '#{options[:license]}'" end end @@ -81,14 +87,14 @@ ERB.new(File.read(File.join(self.class.source_root, license_file))).result(binding) end def license_file case options[:license] - when "apachev2"; "licenses/apachev2.erb" - when "gplv2"; "licenses/gplv2.erb" - when "gplv3"; "licenses/gplv3.erb" - when "mit"; "licenses/mit.erb" - when "reserved"; "licenses/reserved.erb" + when 'apachev2'; 'licenses/apachev2.erb' + when 'gplv2'; 'licenses/gplv2.erb' + when 'gplv3'; 'licenses/gplv3.erb' + when 'mit'; 'licenses/mit.erb' + when 'reserved'; 'licenses/reserved.erb' else raise Berkshelf::InternalError, "Unknown license: '#{options[:license]}'" end end