class ChefCLI::Policyfile::ReadCookbookForCompatModeUpload

file should be renamed
TODO: when compat mode is removed, this class should be removed and the

def self.load(name, version_override, directory_path)

as necessary, and return a Chef::CookbookVersion object.
Convenience method to load a cookbook, set up name and version overrides
def self.load(name, version_override, directory_path)
  new(name, version_override, directory_path).cookbook_version
end

def chefignore

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

def cookbook_version

def cookbook_version
  @cookbook_version ||=
    begin
      cookbook_version = loader.cookbook_version
      # TODO: dont do this for non-compat mode
      cookbook_version.version = version_override
      # TODO: dont do this either
      # Fixup manifest.
      # What happens is, the 'manifest' representation of cookbook
      # version is created, it has a "name" field like foo-1.0.0, then we
      # change the version to 1234.5678.9876 but the manifest is not
      # regenerated so erchef rejects our upload b/c the name field
      # doesn't match the expected `$cookbook_name-$version` based on the
      # other fields.
      cookbook_version.manifest[:name] = "#{cookbook_version.name}-#{version_override}"
      cookbook_version.freeze_version
      cookbook_version
    end
end

def initialize(cookbook_name, version_override, directory_path)

def initialize(cookbook_name, version_override, directory_path)
  @cookbook_name = cookbook_name
  @version_override = version_override
  @directory_path = directory_path
  @cookbook_version = nil
  @loader = nil
end

def loader

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