Data-Collector

 view release on metacpan or  search on metacpan

lib/Data/Collector.pm  view on Meta::CPAN

package Data::Collector;
{
  $Data::Collector::VERSION = '0.15';
}
# ABSTRACT: Collect information from multiple sources

use Carp;
use Moose;
use MooseX::Types::Set::Object;
use Module::Pluggable::Object;
use Class::Load 'try_load_class';
use namespace::autoclean;

has 'format'        => ( is => 'ro', isa => 'Str',     default => 'JSON'     );
has 'format_args'   => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
has 'engine'        => ( is => 'ro', isa => 'Str',     default => 'OpenSSH'  );
has 'engine_args'   => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
has 'info_args'     => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
has 'engine_object' => (
    is         => 'ro',
    isa        => 'Object',
    lazy_build => 1,
);

has 'data' => (
    is      => 'rw',
    isa     => 'HashRef',
    traits  => ['Hash'],
    default => sub { {} },
);

has 'infos' => (
    is       => 'ro',
    isa      => 'Set::Object',
    coerce   => 1,
    default  => sub { Set::Object->new },
);

has 'exclude_infos' => (
    is       => 'ro',
    isa      => 'Set::Object',
    coerce   => 1,
    default  => sub { Set::Object->new },
);

has 'os' => (
    is        => 'rw',
    isa       => 'Str',
    trigger   => sub { shift->load_os(@_) },
    predicate => 'has_os',
);

sub _build_engine_object {
    my $self  = shift;
    my $type  = $self->engine;
    my $class = "Data::Collector::Engine::$type";

    my ( $res, $reason ) = try_load_class($class);
    $res or die "Can't load engine: $reason\n";

    return $class->new( %{ $self->engine_args } );
}

sub BUILD {
    my $self = shift;

    if ( ! $self->has_os ) {
        # default if not run by App.pm
        $self->os('CentOS');
    }
}

sub load_os {
    my ( $self, $new_os, $old_os ) = @_;
}

sub collect {
    my $self   = shift;



( run in 2.691 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )