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.



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

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

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



28
29
30
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 28

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



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

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

#descObject



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

def desc
  "supermarket(#{uri})"
end

#null?Boolean

Returns:

  • (Boolean)


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

def null?
  false
end

#source_options_for(cookbook_name, cookbook_version) ⇒ Object



51
52
53
54
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 51

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



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef-dk/policyfile/community_cookbook_source.rb', line 39

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