Class: CookVizPlugins::CookbookViz
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- CookVizPlugins::CookbookViz
- Defined in:
- lib/chef/knife/cook_viz.rb
Instance Method Summary collapse
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chef/knife/cook_viz.rb', line 17 def run config[:cookbook_path] ||= Chef::Config[:cookbook_path] ck_loader = Chef::CookbookLoader.new(config[:cookbook_path]) cks = ck_loader.load_cookbooks puts 'digraph chef_cook {' if config[:with_versions] run_with_versions cks else cks.each do |name, ck| n = "#{name.gsub(/[:.-]/, '_')}" ck..dependencies.each do |dep_name, vc| dep_n = "#{dep_name.gsub(/[:.-]/, '_')}" puts " #{n} -> #{dep_n};" end end end puts '}' end |
#run_with_versions(cks) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef/knife/cook_viz.rb', line 36 def run_with_versions(cks) cks.each do |name, ck| n = "#{name.gsub(/[:.-]/, '_')}" ck..dependencies.each do |dep_name, version_constraint| vc = Chef::VersionConstraint.new version_constraint dep_n = "#{dep_name.gsub(/[:.-]/, '_')}" if not cks.has_key? dep_name \ or not vc.include?(cks[dep_name]..version) style = 'dotted' end attrs = [] attrs << "style=\"#{style}\"" unless style.nil? if vc.to_s != Chef::VersionConstraint::DEFAULT_CONSTRAINT attrs << "label=\"#{vc}\"" end attrss = "[#{attrs.join ','}]" puts " #{n} -> #{dep_n} #{attrss};" end end end |