Class: Sambot::Chef::Cookbook

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/chef/cookbook.rb

Constant Summary collapse

GENERATED_FILES =
{
  'teamcity.sh.erb': {eruby: true, dest: 'teamcity.sh', platform: [:windows, :centos]},
  'chefignore': {eruby: false, dest: 'chefignore', platform: [:windows, :centos]},
  'docker-compose.yml': {eruby: false, dest: 'docker-compose.yml', platform: [:windows, :centos]},
  '.env': {eruby: false, dest: '.env', 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]},
  'Vagrantfile.erb': {eruby: false, dest: 'Vagrantfile.erb', platform: [:windows, :centos]},
  'winrm_config': {eruby: false, dest: 'winrm_config', platform: [:windows]}
}

Class Method Summary collapse

Class Method Details

.build(config, cloud, local_workflow) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/sambot/chef/cookbook.rb', line 23

def build(config, cloud, local_workflow)
  create_files(config)
  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

.bumpObject



32
33
34
35
# File 'lib/sambot/chef/cookbook.rb', line 32

def bump()
  new_version = Config.bump_version
  UI.info("You have bumped the version of this cookbook to #{new_version}.")
end

.cleanObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/sambot/chef/cookbook.rb', line 37

def clean()
  UI.info('Removing all generated files from this cookbook.')
  targets = GENERATED_FILES.map{ |key, 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) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/sambot/chef/cookbook.rb', line 48

def create(config)
  require 'git'
  Git.init(config.name)
  Dir.chdir(config.name) do
    create_files(config)
  end
  UI.info('The cookbook has been successfully created.')
end