Class: ChefCLI::Policyfile::ChefRepoCookbookSource
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::ChefRepoCookbookSource
- Defined in:
- lib/chef-cli/policyfile/chef_repo_cookbook_source.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
path to a chef-repo or the cookbook path under it.
-
#preferred_cookbooks ⇒ Object
readonly
Returns the value of attribute preferred_cookbooks.
-
#ui ⇒ Object
UI object for output.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #default_source_args ⇒ Object
- #desc ⇒ Object
-
#initialize(path) {|_self| ... } ⇒ ChefRepoCookbookSource
constructor
Constructor.
- #null? ⇒ Boolean
- #preferred_for(*cookbook_names) ⇒ Object
- #preferred_source_for?(cookbook_name) ⇒ Boolean
-
#source_options_for(cookbook_name, cookbook_version) ⇒ Hash
Returns the metadata (path and version) for an individual cookbook.
-
#universe_graph ⇒ Hash
Calls the slurp_metadata! helper once to calculate the @universe_graph and @cookbook_version_paths metadata.
Constructor Details
#initialize(path) {|_self| ... } ⇒ ChefRepoCookbookSource
Constructor
37 38 39 40 41 42 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 37 def initialize(path) self.path = path @ui = UI.new @preferred_cookbooks = [] yield self if block_given? end |
Instance Attribute Details
#path ⇒ Object
path to a chef-repo or the cookbook path under it
28 29 30 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 28 def path @path end |
#preferred_cookbooks ⇒ Object (readonly)
Returns the value of attribute preferred_cookbooks.
32 33 34 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 32 def preferred_cookbooks @preferred_cookbooks end |
#ui ⇒ Object
UI object for output
30 31 32 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 30 def ui @ui end |
Instance Method Details
#==(other) ⇒ Object
56 57 58 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 56 def ==(other) other.is_a?(self.class) && other.path == path && other.preferred_cookbooks == preferred_cookbooks end |
#default_source_args ⇒ Object
44 45 46 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 44 def default_source_args [:chef_repo, path] end |
#desc ⇒ Object
80 81 82 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 80 def desc "chef_repo(#{path})" end |
#null? ⇒ Boolean
76 77 78 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 76 def null? false end |
#preferred_for(*cookbook_names) ⇒ Object
48 49 50 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 48 def preferred_for(*cookbook_names) preferred_cookbooks.concat(cookbook_names) end |
#preferred_source_for?(cookbook_name) ⇒ Boolean
52 53 54 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 52 def preferred_source_for?(cookbook_name) preferred_cookbooks.include?(cookbook_name) end |
#source_options_for(cookbook_name, cookbook_version) ⇒ Hash
Returns the metadata (path and version) for an individual cookbook
72 73 74 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 72 def (cookbook_name, cookbook_version) { path: cookbook_version_paths[cookbook_name][cookbook_version], version: cookbook_version } end |
#universe_graph ⇒ Hash
Calls the slurp_metadata! helper once to calculate the @universe_graph and @cookbook_version_paths metadata. Returns the @universe_graph.
64 65 66 67 |
# File 'lib/chef-cli/policyfile/chef_repo_cookbook_source.rb', line 64 def universe_graph if @universe_graph.nil? @universe_graph end |