Class: ChefDK::Policyfile::CommunityCookbookSource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil) ⇒ CommunityCookbookSource

Returns a new instance of CommunityCookbookSource.



33
34
35
36
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 33

def initialize(uri = nil)
  @uri = uri || "https://supermarket.chef.io"
  @http_connections = {}
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



31
32
33
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 31

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 38

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

#source_options_for(cookbook_name, cookbook_version) ⇒ Object



54
55
56
57
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 54

def source_options_for(cookbook_name, cookbook_version)
  base_uri = full_community_graph[cookbook_name][cookbook_version]["download_url"]
  { artifactserver: base_uri, version: cookbook_version }
end

#universe_graphObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 42

def universe_graph
  @universe_graph ||= begin
    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
end