Config-Trivial-Storable

 view release on metacpan or  search on metacpan

lib/Config/Trivial/Storable.pm  view on Meta::CPAN

        || ( $_file eq $file )
        || ( $0     eq $file ) )
    {
        return $self->_raise_error(
            'Not allowed to store to the calling file.');
    }

    if ( -e $file ) {
        croak "ERROR: Insufficient permissions to write to: $file"
            unless ( -w $file );
        rename $file, $file . $self->{_backup_char}
            or croak "ERROR: Unable to rename $file.";
    }

    my $settings = $args{'configuration'} || $self->{_configuration};

    if ( ! ( $settings && ref $settings eq 'HASH') ) {
        return $self->_raise_error(
            q{Configuration object isn't a HASH reference.})
    };

t/04-write.t  view on Meta::CPAN

	configuration => $data));					# Write it too
ok(-e "./t/test3.data");

#
#	Read things back (8-15)
#

ok($config = Config::Trivial::Storable->new(
    config_file => "./t/test2.data"));          # Create Config object
ok($config->read("test1"), "foo");
ok($config->write);								# write it back (should make a backup)
ok(-e "./t/test2.data~");

ok($config = Config::Trivial::Storable->new(
    config_file => "./t/test3.data"));           # Create Config object
ok($config->read("test"), "womble");
ok($config->read('longer_key'), 'muppet');
ok($config->read('silly_key'), 'fraggle');
#
#	Make sure we clean up (16-19)
#

t/05-store.t  view on Meta::CPAN


#
#	Read things back (12-24)
#

ok($config = Config::Trivial::Storable->new(
    config_file => "./t/test2.data"));              # 12 Create Config object
ok($data = $config->retrieve);                      # 13 Get it back
ok($data->{test1}, "foo");                          # 14 check value
ok($data->{test3}, "baz");                          # 15 check value
ok($config->write);								    # 16 write it back (should make a backup)
ok(-e "./t/test2.data~");                           # 17 Check it's updated the old file

ok($config = Config::Trivial::Storable->new(
    config_file => "./t/test3.data"));              # 18 Create Config object
ok($config->retrieve("test"), "womble");            # 19 Retrive a single value
ok($config->retrieve("test1"), "orrinoco");         # 20 Retrive a single value

ok($config = Config::Trivial::Storable->new);       # 21 New empty setting 
ok($config->set_storable_file("./t/test3.data"));   # 22 Manuall set the storefile
ok($config->{_storable_file}, "./t/test3.data");    # 23 Set manually



( run in 1.055 second using v1.01-cache-2.11-cpan-49f99fa48dc )