# = TITLE: # # Package # # = COPYING: # # Copyright (c) 2007 Psi T Corp. # # This file is part of the ProUtils' Ratch program. # # Ratch is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ratch is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ratch. If not, see . require 'ratch/metadata/project' require 'ratch/metadata/release' module Ratch # = Package Class # # Package class contains projectinformation but also # release information such as current version and release date. # # Release information is delgated to the Release class via method_missing. class Package < Project def self.load package = super package.release = Release.load package end # Overrides Project#name. # TODO: Is this what we want ? def name @name ||= release.name end # List of project files included in package. # # TODO: Read from MANIFEST ? #attr_accessor :filelist # Package format of this package (tar.gz, zip, gem, deb, etc.) # For a package this is purely informational. attr_accessor :format, :type # Release information. attr_accessor :release # Delegate to release. def method_missing(s, *a, &b) if release.respond_to?(s) release.send(s, *a, &b) else super end end # Package name is generally in the form of +name-version+, or # +name-version-platform+ if +platform+ is specified. # # Template can be used to modify the name via sprintf. The defaults # is "%s-%s" for name-version or "%s-%s-%s for name-version-platform. def package_name(template=nil) unless template template = platform ? "%s-%s-%s" : "%s-%s" end if buildno # TODO Make this better. buildno = Time.now.strftime("%H*60+%M") versnum = "#{version}.#{buildno}" else versnum = version end template % [ name, versnum, platform ] end alias_method :stage_name, :package_name # #validate "release isnt valid" do # release.validate #end end end