lib/chef/cookbook_version.rb
# See #manifest for a description of the manifest return value.
# See #preferred_manifest_record for a description an individual manifest record.
See #manifest for a description of the manifest return value.
See #preferred_manifest_record for a description an individual manifest record.
See #manifest for a description of the manifest return value . See #preferred_manifest_record for a description an individual manifest record .
def generate_manifest
      manifest = Mash.new({
        :recipes => Array.new,
        :definitions => Array.new,
        :libraries => Array.new,
        :attributes => Array.new,
        :files => Array.new,
        :templates => Array.new,
        :resources => Array.new,
        :providers => Array.new,
        :root_files => Array.new
      })
      checksums_to_on_disk_paths = {}
      COOKBOOK_SEGMENTS.each do |segment|
        segment_filenames(segment).each do |segment_file|
          next if File.directory?(segment_file)
          file_name = nil
          path = nil
          specificity = "default"
          if segment == :root_files
            matcher = segment_file.match(".+/#{Regexp.escape(name.to_s)}/(.+)")
            file_name = matcher[1]
            path = file_name
          elsif segment == :templates || segment == :files
            matcher = segment_file.match("/#{Regexp.escape(name.to_s)}/(#{Regexp.escape(segment.to_s)}/(.+?)/(.+))")
            unless matcher
              Chef::Log.debug("Skipping file #{segment_file}, as it isn't in any of the proper directories (platform-version, platform or default)")
              Chef::Log.debug("You probably need to move #{segment_file} into the 'default' sub-directory")
              next
            end
            path = matcher[1]
            specificity = matcher[2]
            file_name = matcher[3]
          else
            matcher = segment_file.match("/#{Regexp.escape(name.to_s)}/(#{Regexp.escape(segment.to_s)}/(.+))")
            path = matcher[1]
            file_name = matcher[2]
          end
          csum = self.class.checksum_cookbook_file(segment_file)
          checksums_to_on_disk_paths[csum] = segment_file
          rs = Mash.new({
            :name => file_name,
            :path => path,
            :checksum => csum
          })
          rs[:specificity] = specificity
          manifest[segment] << rs
        end
      end
      manifest[:cookbook_name] = name.to_s
      manifest[:metadata] = metadata
      manifest[:version] = metadata.version
      manifest[:name] = full_name
      @checksums = checksums_to_on_disk_paths
      @manifest = manifest
      @manifest_records_by_path = extract_manifest_records_by_path(manifest)
    end
def generate_manifest manifest = Mash . new ( { :recipes => Array . new , :definitions => Array . new , :libraries => Array . new , :attributes => Array . new , :files => Array . new , :templates => Array . new , :resources => Array . new , :providers => Array . new , :root_files => Array . new } ) checksums_to_on_disk_paths = { } COOKBOOK_SEGMENTS . each do | segment | segment_filenames ( segment ) . each do | segment_file | next if File . directory? ( segment_file ) file_name = nil path = nil specificity = "default" if segment == :root_files matcher = segment_file . match ( ".+/#{Regexp.escape(name.to_s)}/(.+)" ) file_name = matcher [ 1 ] path = file_name elsif segment == :templates || segment == :files matcher = segment_file . match ( "/#{Regexp.escape(name.to_s)}/(#{Regexp.escape(segment.to_s)}/(.+?)/(.+))" ) unless matcher Chef :: Log . debug ( "Skipping file #{segment_file}, as it isn't in any of the proper directories (platform-version, platform or default)" ) Chef :: Log . debug ( "You probably need to move #{segment_file} into the 'default' sub-directory" ) next end path = matcher [ 1 ] specificity = matcher [ 2 ] file_name = matcher [ 3 ] else matcher = segment_file . match ( "/#{Regexp.escape(name.to_s)}/(#{Regexp.escape(segment.to_s)}/(.+))" ) path = matcher [ 1 ] file_name = matcher [ 2 ] end csum = self . class . checksum_cookbook_file ( segment_file ) checksums_to_on_disk_paths [ csum ] = segment_file rs = Mash . new ( { :name => file_name , :path => path , :checksum => csum } ) rs [ :specificity ] = specificity manifest [ segment ] << rs end end manifest [ :cookbook_name ] = name . to_s manifest [ :metadata ] = metadata manifest [ :version ] = metadata . version manifest [ :name ] = full_name @checksums = checksums_to_on_disk_paths @manifest = manifest @manifest_records_by_path = extract_manifest_records_by_path ( manifest ) end
See #manifest for a description of the manifest return value.
See #manifest for a description of the manifest return value .