Class: Sambot::Chef::Cookbook
- Inherits:
-
Object
- Object
- Sambot::Chef::Cookbook
- Defined in:
- lib/sambot/chef/cookbook.rb
Constant Summary collapse
- ESSENTIAL_FILES =
[ '.config.yml', 'recipes', 'README.md' ].freeze
- GENERATED_FILES =
{ 'teamcity.sh.erb': {eruby: true, dest: 'teamcity.sh', platform: [:windows, :centos]}, 'chefignore': {eruby: false, dest: 'chefignore', platform: [:windows, :centos]}, 'Berksfile': {eruby: false, dest: 'Berksfile', platform: [:windows, :centos]}, '.rubocop.yml': {eruby: false, dest: '.rubocop.yml', platform: [:windows, :centos]}, '.gitignore.sample': {eruby: false, dest: '.gitignore', platform: [:windows, :centos]}, 'bootstrap.sh': {eruby: false, dest: 'bootstrap.sh', platform: [:centos]}, 'bootstrap.ps1': {eruby: false, dest: 'bootstrap.ps1', platform: [:windows]}, 'Vagrantfile.erb': {eruby: false, dest: 'Vagrantfile.erb', platform: [:windows, :centos]}, 'winrm_config': {eruby: false, dest: 'winrm_config', platform: [:windows]} }
- CHEF_ARTEFACTS =
['Berksfile.lock']
- KITCHEN_FILES_PATTERN =
'\.kitchen*\.yml'
Class Method Summary collapse
Class Method Details
.build(config) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/sambot/chef/cookbook.rb', line 34 def build(config) Generator.from_templates(config['platforms'], ESSENTIAL_FILES, GENERATED_FILES) Kitchen.setup(config) Metadata.generate(config) Hooks.copy() UI.info('The cookbook has been successfully built.') end |
.clean ⇒ Object
42 43 44 45 46 47 |
# File 'lib/sambot/chef/cookbook.rb', line 42 def clean() UI.info('Removing all generated files from this cookbook.') targets = ['metadata.rb', 'Berksfile.lock'] + GENERATED_FILES.map{ |key, val| val[:dest]} + Dir.glob(KITCHEN_FILES_PATTERN) - ['.gitignore'] targets.each { |file| delete(file) } UI.info('The cookbook has been successfully cleaned.') end |
.generate(config) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sambot/chef/cookbook.rb', line 49 def generate(config) Git.init(config[:name]) Dir.chdir(config[:name]) do ['test', 'spec', 'recipes'].each {|target| FileUtils.mkdir(target) } FileUtils.touch('README.md') Template.new('.config.yml.erb').write(config, '.config.yml') UI.debug("./.config.yml has been added to the cookbook.") end UI.info('The cookbook has been successfully generated.') end |