Sha256: 89763d48298a5706e903e55d7435e599427f12bbd4928ccaf5310e23ee22c9de

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

#--
#  __  __           _  __        _
# |  \/  |__ _ _ _ (_)/ _|___ __| |_
# | |\/| / _` | ' \| |  _/ -_|_-<  _|
# |_|  |_\__,_|_||_|_|_| \___/__/\__|
#
#++

require 'digest/md5'

module Reap

  # = Manifest
  #
  # Create a manifest file for the package. Presently it is a very simple
  # md5 + filename manifest. In the future this will be exanded to build
  # a varity of manifest formats.
  #
  # Task specific settings:
  #
  #    include       Files to include
  #    exclude       Files to exclude
  #

  class Manifest

    include TaskUtils

    MUST_EXCLUDE = [ 'InstalledFiles', '**/CVS/**/*', '**/*~' ] #, 'dist', 'pkg' ]

    # Note that ++dir++ is not offset by ++trunk++. But ++include++ and ++exclude++ are offset.

    attr_accessor :trunk, :dir, :include, :exclude

    def initialize( man )
      @dir     = '.'
      @include = ['**/*']
      @exclude = []

      super

      @trunk = '.' unless @trunk
      @exclude |= MUST_EXCLUDE
    end

    # Generate manifest file.

    def generate #( type=nil )
      manifest_file = File.join( File.expand_path( @dir ), 'MANIFEST' )
      package_files = FileList.new
      Dir.chdir( @trunk ) do
        package_files.include(*@include)
        package_files.exclude(*@exclude) #if @exclude and not @exclude.empty?
        File.open( manifest_file, 'w+') do |f|
          package_files.each do |pf|
            f << "#{salt(pf)} #{pf}\n" if File.file?(pf)
          end
        end
      end
    end

    alias_method :call, :generate

  private

    def salt( file )
      Digest::MD5.new( File.read( file ) ).hexdigest
    end

  end

end #module Reap

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reap-6.0.0 lib/reap/class/manifest.rb