SVN::S4::Config - Get subversion config values


SVN-S4 documentation Contained in the SVN-S4 distribution.

Index


Code Index:

NAME

Top

SVN::S4::Config - Get subversion config values

SYNOPSIS

Top

Scripts: use SVN::S4; # See below

DESCRIPTION

Top

SVN::S4::Config reads the user .subversion config files.

METHODS ADDED TO SVN::S4

Top

The following methods extend to the global SVN::S4 class.

$s4->config_get(<section>,<key>)

Return the config value for the given section and key.

DISTRIBUTION

Top

The latest version is available from CPAN and from http://www.veripool.org/.

Copyright 2005-2011 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

AUTHORS

Top

Wilson Snyder <wsnyder@wsnyder.org>

SEE ALSO

Top

SVN::S4


SVN-S4 documentation Contained in the SVN-S4 distribution.

# See copyright, etc in below POD section.
######################################################################

package SVN::S4::Config;
require 5.006_001;

use SVN::S4;
use SVN::S4::Debug qw (DEBUG is_debug);

use strict;
use Carp;
use Config::Tiny;
use vars qw($AUTOLOAD);

our $VERSION = '1.053';

#######################################################################
#######################################################################
#######################################################################
#######################################################################
# OVERLOADS of S4 object
package SVN::S4;
use SVN::S4::Debug qw (DEBUG is_debug);

sub _config_filenames {
    # Files where config may live
    our @out = ("/etc/subversion/config", "$ENV{HOME}/.subversion/config");
    if ($ENV{S4_CONFIG}) {
	push @out, $ENV{S4_CONFIG};
    }
    return @out;
}

sub _config_read {
    my $self = shift;
    return if $self->{_config};

    $self->{_config} ||= {};
    foreach my $filename ($self->_config_filenames) {
	DEBUG "s4: _config_read $filename\n" if $self->debug;
	if (-e $filename) {
	    my $cfg = Config::Tiny->read($filename);
	    foreach my $sec (keys %$cfg) {
		foreach my $key (keys %{$cfg->{$sec}}) {
		    $self->{_config}{$sec}{$key} = $cfg->{$sec}{$key};
		}
	    }
	}
	#print Dumper($self->{_config});
    }
}

sub config_get {
    my $self = shift;
    my $sec = shift;
    my $key = shift;
    $self->_config_read;
    my $val = $self->{_config}{$sec}{$key};
    return $val;
}

sub config_get_bool {
    my $self = shift;
    my $val = $self->config_get(@_);
    return undef if !defined $val;
    return 1 if ($val && $val !~ /^no$/i);
    return 0;
}

######################################################################
### Package return
package SVN::S4::Config;
1;
__END__