Class: Sambot::Commands::Cookbook

Inherits:
Thor
  • Object
show all
Includes:
Domain::Common::Runtime, Domain::Common::UI
Defined in:
lib/sambot/commands/cookbook.rb

Instance Method Summary collapse

Methods included from Domain::Common::Runtime

#ensure_latest, #is_obsolete

Methods included from Domain::Common::UI

#debug, #error, #info

Instance Method Details

#buildObject



36
37
38
39
40
41
42
43
# File 'lib/sambot/commands/cookbook.rb', line 36

def build
  ensure_latest
  modified_files = Domain::Cookbooks::AssistantChef.new.build_cookbook(ESSENTIAL_FILES, GENERATED_FILES)
  modified_files.each {|file| debug("./#{file} has been added to the cookbook.")}
  info('The cookbook has been successfully built.')
rescue Domain::Common::ApplicationException => e
  error(e.message)
end

#cleanObject



19
20
21
22
23
24
25
26
27
# File 'lib/sambot/commands/cookbook.rb', line 19

def clean
  ensure_latest
  info('Removing all generated files from this cookbook.')
  modified_files = Sambot::Domain::Cookbooks::AssistantChef.new.clean_cookbook(GENERATED_FILES - ['.gitignore'])
  modified_files.each {|file| debug("./#{file} has been removed.")}
  info('The cookbook has been successfully cleaned.')
rescue Domain::Common::ApplicationException => e
  error(e.message)
end

#generateObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sambot/commands/cookbook.rb', line 50

def generate()
  ensure_latest
  name = ask(' What is the name of this cookbook?')
  description = ask(' What does this cookbook do?')
  platform = ask(' What operating system will this cookbook run on?', :limited_to => ['windows', 'linux'])
  type = ask(' What type of cookbook will this be?', :limited_to => ['wrapper', 'role'])
  Sambot::Domain::Cookbooks::AssistantChef.new.generate_cookbook(name, platform, type, description, ESSENTIAL_FILES, GENERATED_FILES)
  info('The cookbook has been successfully generated.')
rescue Domain::Common::ApplicationException => e
  error(e.message)
end