class Sambot::Chef::Cookbook

Constants

GENERATED_FILES

Public Class Methods

build(config, cloud, local_workflow) click to toggle source
# File lib/sambot/chef/cookbook.rb, line 23
def build(config, cloud, local_workflow)
  Generator.from_templates(config, cloud, local_workflow, GENERATED_FILES)
  Kitchen.setup(cloud, config, local_workflow)
  Metadata.generate(config)
  Hooks.copy
  UI.info('The cookbook has been successfully built.')
end
bump() click to toggle source
# File lib/sambot/chef/cookbook.rb, line 31
def bump
  new_version = Config.bump_version
  UI.info("You have bumped the version of this cookbook to #{new_version}.")
end
clean() click to toggle source
# File lib/sambot/chef/cookbook.rb, line 36
def clean
  UI.info('Removing all generated files from this cookbook.')
  targets = GENERATED_FILES.map { |_, val| val[:dest] } - ['.gitignore']
  targets.each { |file| Sambot::FS.delete(file) }
  Sambot::FS.delete('bootstrap.sh')
  Sambot::FS.delete('bootstrap.ps1')
  Metadata.clean
  Kitchen.clean
  UI.info('The cookbook has been successfully cleaned.')
end
create(config) click to toggle source
# File lib/sambot/chef/cookbook.rb, line 47
def create(config)
  require 'git'
  Git.init(config.name)
  Dir.chdir(config.name) do
    create_files(config)
  end
  #TeamCity.create_build_configuration(config)
  #SourceControl.create_repository(config)
  UI.info('The cookbook has been successfully created.')
end

Private Class Methods

create_files(config) click to toggle source
# File lib/sambot/chef/cookbook.rb, line 60
def create_files(config)
  ['README.md'].each { |resource| FS.copy(resource) unless FS.exist?(resource) }
  %w[spec test attributes].each { |resource| FS.mkdir(resource) unless FS.exist?(resource) }
  Dir.chdir('attributes') { FileUtils.touch('default.rb') unless FS.exist?('default.rb') }
  Dir.chdir('spec') { FS.copy('spec_helper.rb') unless FS.exist?('spec_helper.rb') }
  %w[recipes libraries resources files templates].each { |target| FS.mkdir(target) unless FS.exist?(target) }
  Dir.chdir('recipes') do
    FileUtils.touch('default.rb') unless FS.exist?('default.rb')
  end
  unless FS.exist?('.config.yml')
    Template.new('.config.yml.erb').write({ config: config }, '.config.yml')
    UI.debug('./.config.yml has been added to the cookbook.')
  end
end