Class: Cupper::Cookbook

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

Instance Method Summary collapse

Constructor Details

#initialize(cookbookname = 'default') ⇒ Cookbook

TODO: Read config file to tell the project path and configs



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cupper/cookbook.rb', line 8

def initialize(cookbookname='default')
  @cookbook_path    = "#{Dir.getwd}/cookbooks/#{cookbookname}"
  @cookbook_files_path = "#{@cookbook_path}/files"
  @cookbook_recipes_path = "#{@cookbook_path}/recipes"
  @recipe_deps = [ # TODO this is hard code to reflect all_recipes. Refactor this later
    "#{cookbookname}::packages",
    "#{cookbookname}::cookbook_files",
    "#{cookbookname}::links",
    "#{cookbookname}::users",
    "#{cookbookname}::groups",
    "#{cookbookname}::services",
  ]
  setup_paths
end

Instance Method Details

#all_recipes(collector) ⇒ Object



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

def all_recipes(collector)
  Recipe.new(@cookbook_recipes_path, collector, 'recipe', 'default', @recipe_deps).create
  Recipe.new(@cookbook_recipes_path, collector, '_cookbook_file', 'cookbook_files').create
  Recipe.new(@cookbook_recipes_path, collector, '_links', 'links').create
  Recipe.new(@cookbook_recipes_path, collector, '_groups', 'groups').create
  Recipe.new(@cookbook_recipes_path, collector, '_services', 'services').create
  Recipe.new(@cookbook_recipes_path, collector, '_users', 'users').create
  Recipe.new(@cookbook_recipes_path, collector, '_package', 'packages').create
end

#generateObject



29
30
31
32
33
# File 'lib/cupper/cookbook.rb', line 29

def generate
  collector = Collect.new
  collector.setup
  all_recipes(collector)
end

#setup_pathsObject



23
24
25
26
27
# File 'lib/cupper/cookbook.rb', line 23

def setup_paths
  Dir.mkdir(@cookbook_path) unless Dir.exists?(@cookbook_path)
  Dir.mkdir(@cookbook_files_path) unless Dir.exists?(@cookbook_files_path)
  Dir.mkdir(@cookbook_recipes_path) unless Dir.exists?(@cookbook_recipes_path)
end