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.



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

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

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 45

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

#source_options_for(cookbook_name, cookbook_version) ⇒ Object



61
62
63
64
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 61

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



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 49

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