Class: ChefCLI::Policyfile::CookbookLoaderWithChefignore

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cookbook_name, directory_path) ⇒ CookbookLoaderWithChefignore

Returns a new instance of CookbookLoaderWithChefignore.



38
39
40
41
42
43
44
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 38

def initialize(cookbook_name, directory_path)
  @cookbook_name = cookbook_name
  @directory_path = directory_path

  @cookbook_version = nil
  @loader = nil
end

Instance Attribute Details

#cookbook_nameObject (readonly)

Returns the value of attribute cookbook_name.



35
36
37
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 35

def cookbook_name
  @cookbook_name
end

#directory_pathObject (readonly)

Returns the value of attribute directory_path.



36
37
38
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 36

def directory_path
  @directory_path
end

Class Method Details

.load(name, directory_path) ⇒ Object

Convenience method to load a cookbook and return a Chef::CookbookVersion object.



31
32
33
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 31

def self.load(name, directory_path)
  new(name, directory_path).cookbook_version
end

Instance Method Details

#chefignoreObject



59
60
61
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 59

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

#cookbook_versionObject



46
47
48
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 46

def cookbook_version
  @cookbook_version ||= loader.cookbook_version
end

#loaderObject



50
51
52
53
54
55
56
57
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 50

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