Class: Berkshelf::InitGenerator
- Inherits:
-
BaseGenerator
- Object
- Thor::Group
- BaseGenerator
- Berkshelf::InitGenerator
- Defined in:
- lib/berkshelf/init_generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(*args) ⇒ InitGenerator
constructor
A new instance of InitGenerator.
Methods inherited from BaseGenerator
Constructor Details
#initialize(*args) ⇒ InitGenerator
Returns a new instance of InitGenerator.
7 8 9 10 11 12 |
# File 'lib/berkshelf/init_generator.rb', line 7 def initialize(*args) super(*args) if @options[:cookbook_name] @cookbook_name = @options[:cookbook_name] end end |
Instance Method Details
#generate ⇒ Object
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/berkshelf/init_generator.rb', line 61 def generate validate_configuration check_option_support template 'Berksfile.erb', target.join('Berksfile') template 'Thorfile.erb', target.join('Thorfile') if [:chefignore] copy_file 'chefignore', target.join(Berkshelf::Chef::Cookbook::Chefignore::FILENAME) 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 [:chef_minitest] empty_directory target.join('files/default/tests/minitest/support') template 'default_test.rb.erb', target.join('files/default/tests/minitest/default_test.rb') template 'helpers.rb.erb', target.join('files/default/tests/minitest/support/helpers.rb') end if [:scmversion] create_file target.join('VERSION'), '0.1.0' end unless [:no_bundler] template 'Gemfile.erb', target.join('Gemfile') end if defined?(Kitchen::Generator::Init) unless [:skip_test_kitchen] # Temporarily use Dir.chdir to ensure the destionation_root of test kitchen's generator # is where we expect until this bug can be addressed: # https://github.com/opscode/test-kitchen/pull/140 Dir.chdir target do # Kitchen::Generator::Init.new([], {}, destination_root: target).invoke_all Kitchen::Generator::Init.new([], {}).invoke_all end end end unless [:skip_vagrant] template 'Vagrantfile.erb', target.join('Vagrantfile') end end |