NAME

slackget10::Package - This class is the internal representation of a package for slack-get 1.0

VERSION

Version 1.0.0

SYNOPSIS

This module is used to represent a package for slack-get

    use slackget10::Package;

    my $package = slackget10::Package->new('package-1.0.0-noarch-1');
    $package->setValue('description',"This is a test of the slackget10::Package object");
    $package->fill_object_from_package_name();

CONSTRUCTOR

new

The constructor take two parameters : a package name, and an id (the namespace of the package like 'slackware' or 'linuxpackages')

        my $package = new slackget10::Package ('aaa_base-10.0.0-noarch-1','slackware');

The constructor automatically call the fill_object_from_package_name() method.

You also can pass some extra arguments like that :

        my $package = new slackget10::Package ('aaa_base-10.0.0-noarch-1', 'package-object-version' => '1.0.0');

The constructor return undef if the id is not defined.

FUNCTIONS

merge

This method merge $another_package with $package. WARNING: $another_package will be destroy in the operation (this is a collateral damage ;-), for some dark preocupation of memory.

This method overwrite existing value.

        $package->merge($another_package);

compare_version

This method take another slackget10::Package as argument and compare it's version to the current object.

        if( $package->compare_version( $another_package ) == -1 )
        {
                print $another_package->get_id," is newer than ",$package->get_id ,"\n";
        }

Returned code :

        -1 => $package version is lesser than $another_package's one
        0 => $package version is equal to $another_package's one
        1 => $package version is greater than $another_package's one
        undef => an error occured.

fill_object_from_package_name

Try to extract the maximum informations from the name of the package. The constructor automatically call this method.

        $package->fill_object_from_package_name();

extract_informations

Extract informations about a package from a string. This string must be a line of the description of a package.

        $package->extract_informations($data);

This method is designe to be called by the slackget10::SpecialFiles::PACKAGES class, and automatically call the clean_description() method.

clean_description

remove the "<package_name>: " string in front of each line of the description. Remove extra tabulation (for identation).

        $package->clean_description();

grab_info_from_description

Try to find some informations in the description. For example, packages from linuxpackages.net contain a line starting by Packager: ..., this method will extract this information and re-set the package-maintener tag.

The supported tags are: package-maintener, info-destination-slackware, info-packager-mail, info-homepage, info-packager-tool, info-packager-tool-version

        $package->grab_info_from_description();

to_XML

return the package as an XML encoded string.

        $xml = $package->to_XML();

to_string

Alias for to_XML()

to_HTML

return the package as an HTML string

        my $html = $package->to_HTML ;

Note: I have design this method for 2 reasons. First for an easy integration of the search result in a GUI, second for my website search engine. So this HTML may not satisfy you. In this case just generate new HTML from accessors ;-)

PRINTING METHODS

Print a part of package information.

        $package->print_restricted_info();

Print all informations found in the package.

        $package->print_full_info();

fprint_restricted_info

Same as print_restricted_info, but output in HTML

        $package->fprint_restricted_info();

fprint_full_info

Same as print_full_info, but output in HTML

        $package->fprint_full_info();

ACCESSORS

setValue

Set the value of a named key to the value passed in argument.

        $package->setValue($key,$value);

getValue

Return the value of a key :

        $string = $package->getValue($key);

status

Return the current status of the package object as a slackget10::Status object. This object is set by other class, and in most case you don't have to set it by yourself.

        print "The current status for ",$package->name," is ",$package->status()->to_string,"\n";

You also can set the status, by passing a slackget10::Status object, to this method.

        $package->status($status_object);

This method return 1 if all goes well and undef else.

_setId [PRIVATE]

set the package ID (normally the package complete name, like aaa_base-10.0.0-noarch-1). In normal use you don't need to use this method

        $package->_setId('aaa_base-10.0.0-noarch-1');

get_id

return the package id (full name, like aaa_base-10.0.0-noarch-1).

        $string = $package->get_id();

description

return the description of the package.

        $string = $package->description();

filelist

return the list of files in the package. WARNING: by default this list is not included !

        $string = $package->filelist();

name

return the name of the package. Ex: for the package aaa_base-10.0.0-noarch-1 name() will return aaa_base

        my $string = $package->name();

compressed_size

return the compressed size of the package

        $number = $package->compressed_size();

uncompressed_size

return the uncompressed size of the package

        $number = $package->uncompressed_size();

location

return the location of the installed package.

        $string = $package->location();

conflicts

return the list of conflicting pakage.

        $string = $apckage->conflict();

suggests

return the suggested package related to the current package.

        $string = $package->suggest();

required

return the required packages for installing the current package

        $string = $package->required();

architecture

return the architecture the package is compiled for.

        $string = $package->architecture();

version

return the package version.

        $string = $package->version();

get_fields_list

return a list of all fields of the package. This method is suitable for example in GUI for displaying informations on packages.

        foreach my $field ( $package->get_fields_list )
        {
                qt_textbrowser->append( "<b>$field</b> : ".$package->getValue( $field )."<br/>\n" ) ;
        }

AUTHOR

DUPUIS Arnaud, <a.dupuis@infinityperl.org>

BUGS

Please report any bugs or feature requests to bug-slackget10-Package@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=slackget10. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2005 DUPUIS Arnaud, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.