CHips L MINI SHELL

CHips L pro

Current Path : /proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/
Upload File :
Current File : //proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/ParamHandler.pm

#!/usr/bin/perl
package RVL::ParamHandler;
##LICENSE##
=head1 NAME

  RVL::ParamHandler - Handling file parsing.

=head1 SYNOPSIS


=head1 DESCRIPTION


=head1 METHODS

=cut

use IO::Interactive qw(is_interactive interactive busy);
use Digest::MD5 qw(md5 md5_hex md5_base64);
use Class::Std::Utils;
{
    # class attribute
    my ($source);
    
    sub new {
        my ($class, $opt, $data) = @_;
        my %hash;
        my ($this) = bless(\%hash, $class);
        
        if (defined $opt->{source}) {
            $hash{source} = $opt->{source};
        }
        
        if (defined $data->{data}) {
            $hash{data} = $data->{data};
        }
                
        return $this;
    }

    sub getSource {
        return $source;
    }
=head2 singleton()

 Returns a singleton Request instance.
 
=cut
    sub singleton {
        my ($class) = __PACKAGE__;
        my ($source) = shift;
        my ($data) = shift;
    
        my ($signature) = $source;
        if (!defined $RVL::INSTANCE{$class}{$signature}) {
            my ($ext4) = substr $source, -4;
            my ($ext3) = substr $source, -3;
            my ($ext2) = substr $source, -2;
            my ($ref);
            
            if (lc($ext4) eq 'yaml') {
                $ref = RVL::ParamHandler::YAML->new({source => $source}, {data => $data});
            } elsif (lc($ext3) eq 'ini') {
                $ref = RVL::ParamHandler::Ini->new({source => $source}, {data => $data});
            } elsif (lc($ext3) eq 'xml') {
                $ref = RVL::ParamHandler::Xml->new({source => $source}, {data => $data});
            } elsif (lc($ext2) eq 'pl') {
                $ref = RVL::ParamHandler::Pl->new({source => $source}, {data => $data});
            }
            
            $RVL::INSTANCE{$class}{$signature} = $ref;
        }
        return $RVL::INSTANCE{$class}{$signature};
    }
    
    sub readFile { }
    
    sub write { }
    
}

=head1 
    
    RVL::ParamHandler::YAML - YAML Handler

=cut
package RVL::ParamHandler::YAML;
use base qw(RVL::ParamHandler);
use YAML::Syck;
use Class::Std::Utils;
{
    sub read {
        my ($this) = @_;
        my $dataLoad = {};
        return (-f $this->{source}) ? LoadFile($this->{source}) : $dataLoad;
    }
    
    sub write {
    	my ($this) = @_;
    	my ($res) = 0;
    	if (RVL::String::is_hash($this->{data}) == 1) {
    		if (open(my $FILEHANDLE, '>', $this->{source})) {
    			close($FILEHANDLE);
    			$res = (DumpFile($this->{source}, $this->{data})) ? 1 : 0;
    		}
    	}
        return $res;
    }
}

=head1 
    
  RVL::ParamHandler::YAML - INI Handler

=cut
package RVL::ParamHandler::Ini;
use base qw(RVL::ParamHandler);
use Class::Std::Utils;
{
    sub read {
    	my ($this) = @_;
        return RVL::File::parse_ini_file($this->{source});
    }
    
    sub write {
    }
}

=head1 

  RVL::ParamHandler::YAML - XML Handler

=cut
package RVL::ParamHandler::Xml;
use base qw(RVL::ParamHandler);
use Class::Std::Utils;
{
    sub read {
    }
    
    sub write {
    }
}

=head1 

  RVL::ParamHandler::YAML - PERL Config Handler

=cut
package RVL::ParamHandler::Pl;
use base qw(RVL::ParamHandler);
use Class::Std::Utils;
{
    sub read {
    }
    
    sub write {
    }
}
1;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez