Class: ChefDK::Policyfile::IncludedPoliciesCookbookSource

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

Defined Under Namespace

Classes: ConflictingCookbookDependencies, ConflictingCookbookSources, ConflictingCookbookVersions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(included_policy_location_specs) {|_self| ... } ⇒ IncludedPoliciesCookbookSource

Constructor

Yields:

  • (_self)

Yield Parameters:



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

def initialize(included_policy_location_specs)
  @included_policy_location_specs = included_policy_location_specs
  @ui = UI.new
  @preferred_cookbooks = []
  yield self if block_given?
end

Instance Attribute Details

#included_policy_location_specsObject (readonly)

A list of included policies



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

def included_policy_location_specs
  @included_policy_location_specs
end

#uiObject

UI object for output



42
43
44
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 42

def ui
  @ui
end

Instance Method Details

#==(other) ⇒ Object



71
72
73
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 71

def ==(other)
  other.is_a?(self.class) && other.included_policy_location_specs == included_policy_location_specs
end

#check_for_conflicts!Object



57
58
59
60
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 57

def check_for_conflicts!
  source_options
  universe_graph
end

#default_source_argsObject



53
54
55
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 53

def default_source_args
  [:included_policies, []]
end

#descObject



94
95
96
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 94

def desc
  "included_policies()"
end

#null?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 90

def null?
  false
end

#preferred_cookbooksObject



67
68
69
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 67

def preferred_cookbooks
  universe_graph.keys
end

#preferred_source_for?(cookbook_name) ⇒ Boolean

All are preferred here

Returns:

  • (Boolean)


63
64
65
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 63

def preferred_source_for?(cookbook_name)
  universe_graph.include?(cookbook_name)
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



86
87
88
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 86

def source_options_for(cookbook_name, cookbook_version)
  source_options[cookbook_name][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



79
80
81
# File 'lib/chef-dk/policyfile/included_policies_cookbook_source.rb', line 79

def universe_graph
  @universe_graph ||= build_universe
end