more complete pod
This commit is contained in:
parent
4a61946399
commit
470c79f18c
8 changed files with 482 additions and 41 deletions
|
|
@ -1,16 +1,100 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File - Role for upgrade file classes
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package WebGUI::Upgrade::File::ext;
|
||||
with 'WebGUI::Upgrade::File';
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
print "Running " . $self->file . "\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
To be consumed by classes for running upgrade scripts.
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File;
|
||||
use 5.010;
|
||||
use Moose::Role;
|
||||
|
||||
=head1 REQUIRED METHODS
|
||||
|
||||
Classes consuming this role must implement the following methods:
|
||||
|
||||
=head2 run
|
||||
|
||||
This method much be implemented and should run the actual upgrade file on the config file.
|
||||
|
||||
=cut
|
||||
|
||||
requires 'run';
|
||||
|
||||
has file => ( is => 'ro' );
|
||||
has configFile => ( is => 'ro' );
|
||||
has version => ( is => 'ro' );
|
||||
has upgrade => (
|
||||
is => 'ro',
|
||||
handles => [ 'quiet' ],
|
||||
=head1 ATTRIBUTES
|
||||
|
||||
This role includes the following attributes.
|
||||
|
||||
=cut
|
||||
|
||||
=head2 file
|
||||
|
||||
The upgrade file to run.
|
||||
|
||||
=cut
|
||||
|
||||
has file => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
=head2 version
|
||||
|
||||
The version the upgrade is for.
|
||||
|
||||
=cut
|
||||
|
||||
has version => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
=head2 upgrade
|
||||
|
||||
The WebGUI::Upgrade object to use for this upgrade.
|
||||
|
||||
=cut
|
||||
|
||||
has upgrade => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
handles => [ 'quiet' ],
|
||||
);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 once
|
||||
|
||||
A method to be overridden that controls if the upgrade file should
|
||||
be run more than once per server.
|
||||
|
||||
=cut
|
||||
|
||||
sub once { 0 }
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File::pl - Upgrade class for Perl scripts
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File::pl;
|
||||
use Moose;
|
||||
use Class::MOP::Class;
|
||||
|
|
@ -7,8 +25,9 @@ with 'WebGUI::Upgrade::File';
|
|||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
my $configFile = shift;
|
||||
|
||||
local $ENV{WEBGUI_CONFIG} = $self->configFile;
|
||||
local $ENV{WEBGUI_CONFIG} = $configFile;
|
||||
local $ENV{WEBGUI_UPGRADE_VERSION} = $self->version;
|
||||
local $ENV{WEBGUI_UPGRADE_QUIET} = $self->quiet;
|
||||
return _runScript($self->file);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,40 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File::pod - Upgrade class for POD documents
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File::pod;
|
||||
use Moose;
|
||||
use POSIX qw(_exit);
|
||||
with 'WebGUI::Upgrade::File';
|
||||
|
||||
sub once { 1 }
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
my $configFile = shift;
|
||||
if ( ! $self->quiet ) {
|
||||
system { $^X } $^X, '-MPod::Perldoc', '-ePod::Perldoc->run', $self->file;
|
||||
my $pid = fork;
|
||||
if (! $pid) {
|
||||
require Pod::Perldoc;
|
||||
@ARGV = ($self->file);
|
||||
Pod::Perldoc->run;
|
||||
_exit;
|
||||
}
|
||||
waitpid $pid, 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,32 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File::sql - Upgrade class for SQL scripts
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File::sql;
|
||||
use Moose;
|
||||
with 'WebGUI::Upgrade::File';
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
my $configFile = shift;
|
||||
|
||||
my @command_line = (
|
||||
$self->upgrade->mysql,
|
||||
$self->upgrade->mysqlCommandLine($self->configFile),
|
||||
$self->upgrade->mysqlCommandLine($configFile),
|
||||
'--batch',
|
||||
'--execute=source ' . $self->file,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File::txt - Upgrade class for text documents
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File::txt;
|
||||
use Moose;
|
||||
with 'WebGUI::Upgrade::File';
|
||||
|
|
@ -6,13 +24,14 @@ sub once { 1 }
|
|||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
my $configFile = shift;
|
||||
if ( ! $self->quiet ) {
|
||||
open my $fh, '<', $self->file;
|
||||
while ( my $line = <$fh> ) {
|
||||
print $line;
|
||||
}
|
||||
close $fh;
|
||||
if (-t STDIN) {
|
||||
if (-t) {
|
||||
print "\nPress ENTER to continue... ";
|
||||
my $nothing = <>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::File::wgpkg - Upgrade class for WebGUI packages
|
||||
|
||||
=cut
|
||||
|
||||
package WebGUI::Upgrade::File::wgpkg;
|
||||
use Moose;
|
||||
with 'WebGUI::Upgrade::File';
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ sub import {
|
|||
my @cleanups;
|
||||
|
||||
sub _build_exports {
|
||||
my $configFile = $ENV{WEBGUI_CONFIG} || die 'WEBGUI_CONFIG environment variable must be specified';
|
||||
my $version = $ENV{WEBGUI_UPGRADE_VERSION} || die 'WEBGUI_UPGRADE_VERSION must be set';
|
||||
my $configFile = $ENV{WEBGUI_CONFIG}
|
||||
or die 'WEBGUI_CONFIG environment variable must be specified';
|
||||
my $version = $ENV{WEBGUI_UPGRADE_VERSION}
|
||||
or die 'WEBGUI_UPGRADE_VERSION must be set';
|
||||
my $quiet = $ENV{WEBGUI_UPGRADE_QUIET};
|
||||
my $upgrade_file = $caller_upgrade_file;
|
||||
(my $vol, my $dir, my $shortname) = File::Spec->splitpath( $upgrade_file );
|
||||
|
|
@ -216,35 +218,58 @@ END {
|
|||
|
||||
__END__
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Upgrade::Script - Functions for WebGUI upgrade scripts
|
||||
WebGUI::Upgrade::Script - Utility package for WebGUI upgrade scripts
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Upgrade::Script;
|
||||
report "Performing upgrade...";
|
||||
|
||||
print "Adding new snippet.\n";
|
||||
import_node->addChild({ className => 'WebGUI::Asset::Snippet', title => 'New Snippet'});
|
||||
config->set('config/item', 'new value');
|
||||
done;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module exports a number of functions to simplify upgrade scripts. The
|
||||
WEBGUI_CONFIG, WEBGUI_UPGRADE_VERSION, and WEBGUI_UPGRADE_QUIET variables
|
||||
will be used to set up the subs.
|
||||
This is a package to be used in upgrade scripts to provide a number
|
||||
of functions and automatic cleanup to make writing upgrade scripts
|
||||
faster and simpler.
|
||||
|
||||
In addition to the upgrade subs, it has a number of methods available to
|
||||
code that is wrapping an upgrade script.
|
||||
C<use>ing this module will also enable strictures, warnings, and
|
||||
all of Perl 5.10's syntax enhancements in the caller.
|
||||
|
||||
Some cleanup needs to be done after running an upgrade script. This will
|
||||
be done on program exit by default, but can also be managed manually with
|
||||
the methods.
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
This package will use the following environment variables to determine
|
||||
its operation. These variables are automatically set by
|
||||
L<WebGUI::Upgrade::File::pl> if run through the main upgrade system.
|
||||
|
||||
=head2 WEBGUI_CONFIG
|
||||
|
||||
The WebGUI config file to operate against.
|
||||
|
||||
=head2 WEBGUI_UPGRADE_VERSION
|
||||
|
||||
The version being upgraded to.
|
||||
|
||||
=head1 EXPORTED SUBROUTINES
|
||||
|
||||
=head2 quiet
|
||||
|
||||
Returns the value of the quiet flag.
|
||||
These subroutines are all exported by default using L<Sub::Exporter>.
|
||||
They cannot be called directly.
|
||||
|
||||
=head2 report ( $message )
|
||||
|
||||
|
|
@ -285,7 +310,7 @@ paths.
|
|||
|
||||
=head2 collateral
|
||||
|
||||
Returns a Path::Class::Dir object for the upgrade script's collateral
|
||||
Returns a L<Path::Class::Dir> object for the upgrade script's collateral
|
||||
path. The collateral path is the same as the name of the upgrade
|
||||
script with the extension stripped off.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue