Icon-Theme-Index-Parse

 view release on metacpan or  search on metacpan

lib/Icon/Theme/Index/Parse.pm  view on Meta::CPAN

package Icon::Theme::Index::Parse;

use warnings;
use strict;
use Config::IniHash;

=head1 NAME

Icon::Theme::Index::Parse - Parse the index file for Freedesktop compatible icon themes.

=head1 VERSION

Version 0.0.1

=cut

our $VERSION = '0.0.1';


=head1 SYNOPSIS

Information for index file specification can be found at the URL below.

http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html

    use Icon::Theme::Index::Parse;

    my $themeindex = Icon::Theme::Index::Parse->new_from_file('/usr/local/share/icons/hicolor/index.theme');
    if($themeindex->{error}){
        print "Error!\n";
    }

=head1 METHOD

=head2 new_from_data

This forms a new object from the raw data.

One arguement is accepted and it is the raw data from a
index file.

    my $themeindex=Icon::Theme::Index::Parse->new_from_data($data);
    if($themeindex->{error}){
        print "Error!\n";
    }

=cut

sub new_from_data{
	my $data=$_[1];
	my $method='new_from_data';

	#init the object
	my $self={ error=>undef, errorString=>'', perror=>undef, module=>'Icon-Theme-Index-Parse' };
	bless $self;
	
	#make sure a file is specified
	if (!defined( $data )) {
		$self->{error}=4;
		$self->{errorString}='No data specified';
		$self->{perror}=1;
		warm($self->{module}.' '.$method.':'.$self->{error}.': '.$self->{errorString});
		return $self;
	}

	$self->{ini}=ReadINI(\$data, case=>'preserve' );

	return $self;
}

=head2 new_from_file

This creates a new object from the specified
index file.

One arguement is accepted and it is the path to the
file.

    my $themeindex=Icon::Theme::Index::Parse->new_from_file('/usr/local/share/icons/hicolor/index.theme');
    if($themeindex->{error}){
        print "Error!\n";
    }

=cut



( run in 0.485 second using v1.01-cache-2.11-cpan-e93a5daba3e )