Class: ChefCLI::IdDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/command/describe_cookbook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ui, cb_relpath) ⇒ IdDumper

Returns a new instance of IdDumper.



29
30
31
32
# File 'lib/chef-cli/command/describe_cookbook.rb', line 29

def initialize(ui, cb_relpath)
  @ui = ui
  @cb_path = cb_relpath
end

Instance Attribute Details

#cb_pathObject (readonly)

Returns the value of attribute cb_path.



26
27
28
# File 'lib/chef-cli/command/describe_cookbook.rb', line 26

def cb_path
  @cb_path
end

#uiObject (readonly)

Returns the value of attribute ui.



27
28
29
# File 'lib/chef-cli/command/describe_cookbook.rb', line 27

def ui
  @ui
end

Instance Method Details

#chefignoreObject



60
61
62
# File 'lib/chef-cli/command/describe_cookbook.rb', line 60

def chefignore
  @chefignore ||= Chef::Cookbook::Chefignore.new(File.join(cookbook_path, "chefignore"))
end

#cookbook_loaderObject



51
52
53
54
55
56
57
58
# File 'lib/chef-cli/command/describe_cookbook.rb', line 51

def cookbook_loader
  @cookbook_loader ||=
    begin
      loader = Chef::Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore)
      loader.load!
      loader
    end
end

#cookbook_pathObject



47
48
49
# File 'lib/chef-cli/command/describe_cookbook.rb', line 47

def cookbook_path
  File.expand_path(cb_path)
end

#cookbook_versionObject



43
44
45
# File 'lib/chef-cli/command/describe_cookbook.rb', line 43

def cookbook_version
  @cookbook_version ||= cookbook_loader.cookbook_version
end

#runObject



34
35
36
37
38
39
40
41
# File 'lib/chef-cli/command/describe_cookbook.rb', line 34

def run
  id = ChefCLI::CookbookProfiler::Identifiers.new(cookbook_version)
  ui.msg "Path: #{cookbook_path}"
  ui.msg "SemVer version: #{id.semver_version}"
  ui.msg "Identifier: #{id.content_identifier}"
  ui.msg "File fingerprints:"
  ui.msg id.fingerprint_text
end