# = TITLE: # # Release # # = 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/information' module Ratch # = Release class # class Release < Information # Name of release package. attr_accessor :name # Version number. attr_accessor :version validate "version is required" do version end # attr_accessor :buildno do @buildno = Time.now.strftime("%y%m%d%H%M") if TrueClass === @buildno @buildno end # Status of this release: alpha, beta, RC1, etc. attr_accessor :status # Date of release (defaults to Time.now). attr_accessor :date, :released do @date || Time.now.strftime("%Y-%m-%d") end # Codename of this release. attr_accessor :codename # ROLL_FILE = '{,meta/}*.roll' # Load release information. def self.load file = Dir.glob(ROLL_FILE, File::FNM_CASEFOLD).first if file Release.new(parse_rollrc(File.open(file))) else raise LoadError, "release file required -- #{RELEASE_FILE}" end end # Parse ROLLRC file for release information. def self.parse_rollrc(io) if IO === io begin str = io.read ensure io.close end else str = io.to_s end stamp, *libpath = str.strip.split(/\n/) name, version, status, date, *null = *stamp.split(/\s+/) { :name => name, :version => version, :status => status, :date => date, :libpath => libpath } end end end