Class: ChefDK::IdDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-dk/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.



12
13
14
15
# File 'lib/chef-dk/command/describe_cookbook.rb', line 12

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.



9
10
11
# File 'lib/chef-dk/command/describe_cookbook.rb', line 9

def cb_path
  @cb_path
end

#uiObject (readonly)

Returns the value of attribute ui.



10
11
12
# File 'lib/chef-dk/command/describe_cookbook.rb', line 10

def ui
  @ui
end

Instance Method Details

#chefignoreObject



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

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

#cookbook_loaderObject



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

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

#cookbook_pathObject



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

def cookbook_path
  File.expand_path(cb_path)
end

#cookbook_versionObject



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

def cookbook_version
  @cookbook_version ||= cookbook_loader.cookbook_version
end

#runObject



17
18
19
20
21
22
23
24
# File 'lib/chef-dk/command/describe_cookbook.rb', line 17

def run
  id = ChefDK::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