Class: ChefDK::Policyfile::ChefRepoCookbookSource

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-dk/policyfile/chef_repo_cookbook_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ChefRepoCookbookSource

Constructor

Parameters:

  • path (String)

    path to a chef-repo or the cookbook path under it



35
36
37
38
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 35

def initialize(path)
  self.path = path
  @ui = UI.new
end

Instance Attribute Details

#pathObject

path to a chef-repo or the cookbook path under it



28
29
30
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 28

def path
  @path
end

#uiObject

UI object for output



30
31
32
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 30

def ui
  @ui
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 40

def ==(other)
  other.kind_of?(self.class) && other.path == path
end

#descObject



64
65
66
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 64

def desc
  "chef_repo(#{path})"
end

#null?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 60

def null?
  false
end

#source_options_for(cookbook_name, cookbook_version) ⇒ Hash

Returns the metadata (path and version) for an individual cookbook

Returns:

  • (Hash)

    metadata for a single cookbook version



56
57
58
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 56

def source_options_for(cookbook_name, cookbook_version)
  { path: cookbook_version_paths[cookbook_name][cookbook_version], version: cookbook_version }
end

#universe_graphHash

Calls the slurp_metadata! helper once to calculate the @universe_graph and @cookbook_version_paths metadata. Returns the @universe_graph.

Returns:

  • (Hash)

    universe_graph



48
49
50
51
# File 'lib/chef-dk/policyfile/chef_repo_cookbook_source.rb', line 48

def universe_graph
  slurp_metadata! if @universe_graph.nil?
  @universe_graph
end