Class: Berkshelf::InitGenerator
- Inherits:
-
BaseGenerator
- Object
- Thor::Group
- BaseGenerator
- Berkshelf::InitGenerator
- Defined in:
- lib/berkshelf/init_generator.rb
Overview
Instance Method Summary collapse
-
#generate ⇒ Object
Generate the cookbook.
-
#initialize(*args) ⇒ InitGenerator
constructor
A new instance of InitGenerator.
Methods inherited from BaseGenerator
Constructor Details
#initialize(*args) ⇒ InitGenerator
Returns a new instance of InitGenerator.
5 6 7 8 9 10 |
# File 'lib/berkshelf/init_generator.rb', line 5 def initialize(*args) super(*args) if @options[:cookbook_name] @cookbook_name = @options[:cookbook_name] end end |
Instance Method Details
#generate ⇒ Object
Generate the cookbook
52 53 54 55 56 57 58 59 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 88 |
# File 'lib/berkshelf/init_generator.rb', line 52 def generate validate_configuration check_option_support template "Berksfile.erb", target.join("Berksfile") if [:chefignore] copy_file "chefignore", target.join("chefignore") end unless [:skip_git] template "gitignore.erb", target.join(".gitignore") unless File.exists?(target.join(".git")) inside target do run "git init", capture: true end end end if [:foodcritic] || [:scmversion] template "Thorfile.erb", target.join("Thorfile") end if [:scmversion] create_file target.join("VERSION"), "0.1.0" end unless [:no_bundler] template "Gemfile.erb", target.join("Gemfile") end unless [:skip_vagrant] template "Vagrantfile.erb", target.join("Vagrantfile") ::Berkshelf::Cli.new([], berksfile: target.join("Berksfile")).invoke(:install) end end |