NAME

Linux::Info::DistributionFinder - class to search for candidate files

VERSION

version 2.12

SYNOPSIS

use Linux::Info::DistributionFinder;
my $finder = Linux::Info::DistributionFinder->new;
my $info_ref = $finder->search_distro;

DESCRIPTION

This class should be used to retrieve Linux distribution information on several candidates files.

First it tries /etc/os-release (since it should contain more data), then look into other known places.

METHODS

new

Creates and returns a new instance.

An optional parameter might be passed, which is how to handle caching.

If the parameter is "true" (1), result will be cached after a call to search_distro method. If "false" (0), each call of search_distro will invalidate the cache and files will be searched and parsed.

The default value is "false" (0) and is probably what you want unless you want to rely on the cache or using has_distro_info and has_custom methods.

set_config_dir

Changes the default configuration directory used by a instance.

Most useful for unit testing with mocks.

search_distro

Search and return the Linux distribution information.

The returned value might be one generated by Linux::Info::Distribution::OSRelease parse method, if there is a /etc/os-release file available.

If not, a custom distribution file will be attempted and the returned value will be a hash reference with the following structure:

{
    id => 'someid',
    file_to_parse => '/etc/foobar_version',
}

Since the file needs to be parsed to retrieve all available information, this file will need to be parsed by a Linux::Info::Distribution::Custom subclasses.

has_distro_info

Returns "true" (1) if the instance has already cached distribution information.

Otherwise, returns "false" (0).

has_custom

Returns "true" (1) if the instance has cached distribution information retrieved from a custom file, in other words, not in the expected format of /etc/os-release.

Otherwise, returns "false" (0).

EXPORTS

Nothing.

You can use Linux::Info:DistributionFinder::DEFAULT_CONFIG_DIR to fetch the default directory used to search for distribution information.

AUTHOR

Alceu Rodrigues de Freitas Junior <glasswalk3r@yahoo.com.br>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Alceu Rodrigues de Freitas Junior.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007