Apache-Voodoo

 view release on metacpan or  search on metacpan

bin/voodoo-control  view on Meta::CPAN

	print "    install \"installfile\" Install the given application.\n";
	print "    update \"app name\"     Run the update steps on an already installed application.\n";
	print "    showconfig            Show global configuration settings.\n";
	print "    setconfig             Change global configuration settings.\n";
	print "    anything else         Show this help message.\n";
	print "Options:\n";
	print "    --pretend    Step through operations.  Don't actually do anything\n";
	print "    -h --dbhost  Override database host name in config files\n";
	print "    -n --dbname  Override database name in conf files\n";
	print "    -u --dbuser  Override database username in conf files\n";
	print "    -p --dbpass  Override database password in conf files\n";
	print "    -r --dbroot  Database root password\n";
	print "    -v number    Increase verbosity \n";
	print "\n";
	print "Expert Options: (Useful in a development environment; dangerous in a production environment.)\n";
	print "    --ignore           Causes errors in the update command files to be ignored\n";
	print "    markupdatesapplied Makes the system believe all the update have been applied,\n";
	print "                       doesn't acutally process them.\n";
	print "\n";
	exit;
}

lib/Apache/Voodoo/Application/ConfigParser.pm  view on Meta::CPAN

				unless (ref ($_->{'extra'}) eq "HASH") {
					$_->{'extra'} = {};
				}
				$_->{'extra'}->{PrintError}  = 0;
				$_->{'extra'}->{RaiseError}  = 0;
				$_->{'extra'}->{HandleError} = Exception::Class::DBI->handler;

				[
					$_->{'connect'},
					$_->{'username'},
					$_->{'password'},
					$_->{'extra'}
				]
			} @{$db}
		];
	}
	else {
		$self->{'dbs'} = [];
	}

	$self->{'models'}   = $conf{'models'}   || {};

lib/Apache/Voodoo/Install/Distribution.pm  view on Meta::CPAN


		$dbhost =~ s/.*\bhost=//;
		$dbhost =~ s/[^\w\.-]+.*$//;

		$dbname =~ s/.*\bdatabase=//;
		$dbname =~ s/[^\w\.-]+.*$//;

		$self->{'dbhost'} ||= $dbhost;
		$self->{'dbname'} ||= $dbname;
		$self->{'dbuser'} ||= $old_cdata{'database'}->{'username'};
		$self->{'dbpass'} ||= $old_cdata{'database'}->{'password'};
	}
	else {
		$self->info("not found. This will be a fresh install.");
	}
}

sub update_conf_file {
	my $self = shift;

	my $new_conf = File::Spec->catfile($self->{'unpack_dir'},$self->{'ac'}->conf_file());

lib/Apache/Voodoo/Install/Distribution.pm  view on Meta::CPAN

	my $config = Config::General->new($new_conf);
	my %cdata = $config->getall();

	foreach (keys %{$self->{'old_conf_data'}}) {
		$self->debug("Merging config data: $_");
		$cdata{$_} = $self->{'old_conf_data'}->{$_};
	}

	$self->debug("Merging database config");
	$cdata{'database'}->{'username'} = $self->{'dbuser'}                               if $self->{'dbuser'};
	$cdata{'database'}->{'password'} = $self->{'dbpass'}                               if $self->{'dbpass'};
	$cdata{'database'}->{'connect'} =~ s/\bdatabase=[^;"]+/database=$self->{'dbname'}/ if $self->{'dbname'};
	$cdata{'database'}->{'connect'} =~ s/\bhost=[^;"]+/host=$self->{'dbhost'}/         if $self->{'dbhost'};

	$self->{'pretend'} || $config->save_file($new_conf,\%cdata);
}

sub install_files {
	my $self = shift;

	my $unpack_dir   = $self->{'unpack_dir'};

lib/Apache/Voodoo/Install/Updater.pm  view on Meta::CPAN

use Config::General qw(ParseConfig);

# make CPAN download dependancies
$CPAN::Config->{'prerequisites_policy'} = 'follow';

################################################################################
# Creates a new updater object with given configuration options.  It assumes
# that the files for the application have already been installed or exist in
# appropriate location.  A good database security setup would not allow the
# user the application connects as to have alter, create or drop privileges; thus
# the need for the database root password.  If pretend is set to a true value,
# the operations are stepped through, but nothing actually happens.
#
# usage:
#    Apache::Voodoo::Install::Updater->new(
#		dbroot   => $database_root_password,
#		app_name => $application_name,
#		verbose  => $output_verbosity_level,
#		pretend  => $boolean
#	);
################################################################################
sub new {
	my $class = shift;
	my %params = @_;

	my $self = {%params};

lib/Apache/Voodoo/Validate/varchar.pm  view on Meta::CPAN

my $alphanums      =  "(?:${alphanum}+)";
my $escape         =  "(?:%$hex\{2})";
my $safe           =  '[$\-_.+]';
my $extra          =  "[!*'(),]";
my $reserved       =  '[;/?:@&=]';
my $uchar          =  "(?:${alphanum}|${safe}|${extra}|${escape})";
   $uchar          =~ s/\Q]|[\E//g;  # Make string smaller, and speed up regex.

# URL schemeparts for ip based protocols:
my $user           =  "(?:(?:${uchar}|[;?&=])*)";
my $password       =  "(?:(?:${uchar}|[;?&=])*)";
my $hostnumber     =  "(?:${digits}(?:${dot}${digits}){3})";
my $toplabel       =  "(?:${alpha}(?:(?:${alphanum}|-)*${alphanum})?)";
my $domainlabel    =  "(?:${alphanum}(?:(?:${alphanum}|-)*${alphanum})?)";
my $hostname       =  "(?:(?:${domainlabel}${dot})*${toplabel})";
my $host           =  "(?:${hostname}|${hostnumber})";
my $hostport       =  "(?:${host}(?::${digits})?)";
my $login          =  "(?:(?:${user}(?::${password})?\@)?${hostport})";

# The predefined schemes:

## FTP (see also RFC959)
#my $fsegment       =  "(?:(?:${uchar}|[?:\@&=])*)";
#my $fpath          =  "(?:${fsegment}(?:/${fsegment})*)";
#my $ftpurl         =  "(?:ftp://${login}(?:/${fpath}(?:;type=[AIDaid])?)?)";


# HTTP

t/Application-ConfigParser.t  view on Meta::CPAN

	['halt_on_errors',  0]
	) {

	is($cp->{config}->{$_->[0]}, $_->[1],"$_->[0] set correctly");
}

eq_or_diff($cp->{config}->{template_opts}, {}, "default value for template_opts set correctly");
foreach (
	['dbs',[
		[
			'dbi:mysql:database=test;host=localhost','root','root_password',
			{HandleError => sub { "DUMMY" }, PrintError => 0, RaiseError => 0 }
		]
	]],
	['models',        {}],
	['views',         {}],
	['includes',      {skeleton    => undef}],
	['controllers',   {test_module => undef}],
	['template_conf', {default => {pre_include => 'skeleton'}}]
	){
	eq_or_diff($cp->{$_->[0]}, $_->[1], "$_->[0] set correctly");

t/Application-ConfigParser.t  view on Meta::CPAN

	['test_passthrough','works']
	) {

	is($cp->{config}->{$_->[0]}, $_->[1],"$_->[0] set correctly");
}

eq_or_diff($cp->{config}->{template_opts}, {}, "default value for template_opts set correctly");
foreach (
	['dbs',[
		[
			'dbi:mysql:database=test;host=localhost','root','root_password',
			{HandleError => sub { "DUMMY" }, PrintError => 0, RaiseError => 0 }
		],
		[
			'dbi:mysql:database=test2;host=localhost','username','password',
			{HandleError => sub { "DUMMY" }, PrintError => 0, RaiseError => 0, key => 'value' }
		]
	]],
	['models',        {'a::model'      => undef}],
	['views',         {'a::view'       => undef}],
	['controllers',   {'a::controller' => undef}],
	){
	eq_or_diff($cp->{$_->[0]}, $_->[1], "$_->[0] set correctly");
}

t/Constants.t  view on Meta::CPAN

	['conf_file',     'etc/voodoo.conf'],
	['conf_path',     'etc'],
	['install_path',  '/data/apache/sites'],
	['prefix',        '/data/apache'],
	['session_path',  '/data/apache/session'],
	['tmpl_path',     'html'],
	['updates_path',  'etc/updates'],
	['debug_dbd', [
		'dbi:SQLite:dbname=/tmp/apachevoodoo.db',
		'username',
		'password'
  		]
	],
	['debug_path',    '/debug'],
	['use_log4perl',  1],
	['log4perl_conf', '/etc/log4perl.conf'],
) {
	my ($method,$value) = @{$_};
	is_deeply($c->$method,$value,$method);
}

t/app_newstyle/etc/voodoo.conf  view on Meta::CPAN

devel_mode = 1

test_passthrough = works

<database>
	connect = "dbi:mysql:database=test;host=localhost"
	username = "root"
	password = "root_password"
</database>

<database>
	connect = "dbi:mysql:database=test2;host=localhost"
	username = "username"
	password = "password"
	<extra>
		key = value
	</extra>
</database>

<controllers>
	a::controller
</controllers>

<models>

t/app_oldstyle/etc/voodoo.conf  view on Meta::CPAN

logout_target = /logout/target

session_timeout = 0
upload_size_max = 10
dynamic_loading = 1
halt_on_errors  = 0

<database>
	connect = "dbi:mysql:database=test;host=localhost"
	username = "root"
	password = "root_password"
</database>

<modules>
	test_module
</modules>

<includes>
	skeleton
</includes>

t/test_data/MyConfig.pm  view on Meta::CPAN


$CONFIG = {
  'APACHE_GID' => 80,
  'APACHE_UID' => 81,
  'CODE_PATH' => 'code',
  'CONF_FILE' => 'etc/voodoo.conf',
  'CONF_PATH' => 'etc',
  'DEBUG_DBD' => [
    'dbi:SQLite:dbname=/tmp/apachevoodoo.db',
    'username',
    'password'
  ],
  'DEBUG_PATH' => '/debug',
  'INSTALL_PATH' => '/data/apache/sites',
  'PREFIX' => '/data/apache',
  'SESSION_PATH' => '/data/apache/session',
  'TMPL_PATH' => 'html',
  'UPDATES_PATH' => 'etc/updates',
  'USE_LOG4PERL' => 1,
  'LOG4PERL_CONF' => '/etc/log4perl.conf'
}



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