Sha256: ebe6f6f112bed962f71420c881a52e1953279c5dd12d8b6f9f26d073ce8c7fa4

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

require 'cupper/collect'
require 'cupper/recipe'
require 'cupper/cookbook_file'

module Cupper
  class Cookbook
    # TODO: Read config file to tell the project path and configs
    def initialize(cookbookname='default')
      @cookbook_path    = "#{Dir.getwd}/#{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}::groups",
        "#{cookbookname}::services",
        "#{cookbookname}::users",
      ]
      setup_paths
    end

    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

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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cupper-0.1.3 lib/cupper/cookbook.rb
cupper-0.1.2 lib/cupper/cookbook.rb
cupper-0.1.1 lib/cupper/cookbook.rb