=end
class Package
- attr_accessor :package_name, :label, :version, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
+ attr_accessor :package_name, :label, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
def initialize (package_name)
@package_name = package_name
@label = ""
- @version = ""
+ @version = nil
@os = ""
@os_list = []
@build_host_os = []
puts self.to_s
end
+ def version
+ return @version.to_s
+ end
+
+ def version= (str)
+ @version = Version.new(str)
+ end
+
def to_s
string = "Package : " + @package_name
if not @label.empty? then string = string + "\n" + "Label : " + @label end
- if not @version.empty? then string = string + "\n" + "Version : " + @version end
+ if not @version.nil? then string = string + "\n" + "Version : " + @version.to_s end
if not @os_list.empty? then string = string + "\n" + "OS : " + @os_list.join(", ") end
if not @build_host_os.empty? then string = string + "\n" + "Build-host-os : " + @build_host_os.join(", ") end
if not @maintainer.empty? then string = string + "\n" + "Maintainer : " + @maintainer end
string = ""
@change_log.sort.each do |list|
- string = "* " + list[0] + "\n" + list[1] + "\n" + string
+ string = "* " + list[0].to_s + "\n" + list[1] + "\n" + string
end
return "#Change log\n" + string
end
when /^\*[ \t]*([0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*)[ \t]*$/ then
state = "CHANGELOG"
change_log[change_version] = change_contents.strip if not change_version.nil?
- change_version = $1
+ change_version = Version.new($1)
change_contents = ""
when /^Include$/i then
pfile = File.dirname(file) + "/" + l.sub(/^[ \t]*Include[ \t]*:[ \t]*/i,"").strip
else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{l}"
end
end
- change_version = $1
+ change_version = Version.new($1)
change_contents = ""
else
change_contents = change_contents + "\n" + l.rstrip
if not package.nil? then pkglist.push package end
if not change_version.nil? then
if change_log[change_version].nil? then change_log[change_version] = change_contents.strip
- else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{change_version}"
+ else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{change_version.to_s}"
end
end
pkglist.each {|pkg| pkg.change_log = change_log }