Class: ChefCLI::Policyfile::CommunityCookbookSource
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::CommunityCookbookSource
- Defined in:
- lib/chef-cli/policyfile/community_cookbook_source.rb
Instance Attribute Summary collapse
-
#preferred_cookbooks ⇒ Object
readonly
Returns the value of attribute preferred_cookbooks.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #default_source_args ⇒ Object
- #desc ⇒ Object
-
#initialize(uri = nil) {|_self| ... } ⇒ CommunityCookbookSource
constructor
A new instance of CommunityCookbookSource.
- #null? ⇒ Boolean
- #preferred_for(*cookbook_names) ⇒ Object
- #preferred_source_for?(cookbook_name) ⇒ Boolean
- #source_options_for(cookbook_name, cookbook_version) ⇒ Object
- #universe_graph ⇒ Object
Constructor Details
#initialize(uri = nil) {|_self| ... } ⇒ CommunityCookbookSource
Returns a new instance of CommunityCookbookSource.
31 32 33 34 35 36 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 31 def initialize(uri = nil) @uri = uri || "https://supermarket.chef.io" @http_connections = {} @preferred_cookbooks = [] yield self if block_given? end |
Instance Attribute Details
#preferred_cookbooks ⇒ Object (readonly)
Returns the value of attribute preferred_cookbooks.
29 30 31 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 29 def preferred_cookbooks @preferred_cookbooks end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
28 29 30 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 28 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 50 def ==(other) other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks end |
#default_source_args ⇒ Object
38 39 40 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 38 def default_source_args [:supermarket, uri] end |
#desc ⇒ Object
73 74 75 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 73 def desc "supermarket(#{uri})" end |
#null? ⇒ Boolean
69 70 71 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 69 def null? false end |
#preferred_for(*cookbook_names) ⇒ Object
42 43 44 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 42 def preferred_for(*cookbook_names) preferred_cookbooks.concat(cookbook_names) end |
#preferred_source_for?(cookbook_name) ⇒ Boolean
46 47 48 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 46 def preferred_source_for?(cookbook_name) preferred_cookbooks.include?(cookbook_name) end |
#source_options_for(cookbook_name, cookbook_version) ⇒ Object
64 65 66 67 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 64 def (cookbook_name, cookbook_version) base_uri = full_community_graph[cookbook_name][cookbook_version]["download_url"] { artifactserver: base_uri, version: cookbook_version } end |
#universe_graph ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/chef-cli/policyfile/community_cookbook_source.rb', line 54 def universe_graph @universe_graph ||= full_community_graph.inject({}) do |normalized_graph, (cookbook_name, )| normalized_graph[cookbook_name] = .inject({}) do |deps_by_version, (version, )| deps_by_version[version] = ["dependencies"] deps_by_version end normalized_graph end end |