From: Chris W. <la...@us...> - 2005-03-09 20:26:38
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29942/lib/OpenInteract2/Config Modified Files: Package.pm Log Message: OIN-72: be able to install an OI2 package from a CPAN dist Index: Package.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Config/Package.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Package.pm 28 Feb 2005 00:59:18 -0000 1.22 --- Package.pm 9 Mar 2005 20:26:23 -0000 1.23 *************** *** 30,34 **** my @OBJECT_FIELDS = qw( filename package_dir ); ! # Define the keys in 'package.conf' that can be a list, meaning you # can have multiple items defined: # --- 30,34 ---- my @OBJECT_FIELDS = qw( filename package_dir ); ! # Define the keys in 'package.ini' that can be a list, meaning you # can have multiple items defined: # *************** *** 41,50 **** message_file config_watcher ); ! # Define the keys in 'package.conf' that can be a hash, meaning that ! # you can have items defined as multiple key-value pairs ! # (space-separated): # ! # template_plugin MyNew OpenInteract2::TT::Plugin::New ! # template_plugin MyURL OpenInteract2::TT::Plugin::URL # NOTE: If you add a field here you must also add it to @SERIAL_FIELDS --- 41,49 ---- message_file config_watcher ); ! # Define the keys in 'package.ini' that should be a hash # ! # [package template_plugin] ! # MyNew = OpenInteract2::TT::Plugin::New ! # MyURL = OpenInteract2::TT::Plugin::URL # NOTE: If you add a field here you must also add it to @SERIAL_FIELDS *************** *** 71,79 **** } if ( $filename and -f $filename ) { ! my $new_params = $class->_read_config( $filename ); $params->{ $_ } = $new_params->{ $_ } for ( keys %{ $new_params } ); $self->filename( $filename ); $self->package_dir( rel2abs( dirname( $filename ) ) ); } return $self->_initialize( $params ); } --- 70,83 ---- } if ( $filename and -f $filename ) { ! my $new_params = $class->_read_config( file => $filename ); $params->{ $_ } = $new_params->{ $_ } for ( keys %{ $new_params } ); $self->filename( $filename ); $self->package_dir( rel2abs( dirname( $filename ) ) ); } + elsif ( $params->{content} ) { + my $new_params = $class->_read_config( content => $params->{content} ); + $params->{ $_ } = $new_params->{ $_ } for ( keys %{ $new_params } ); + + } return $self->_initialize( $params ); } *************** *** 225,234 **** sub _read_config { ! my ( $class, $filename ) = @_; ! unless ( -f $filename ) { ! oi_error "Package configuration file '$filename' does not exist."; } ! my $ini = OpenInteract2::Config::Ini->new({ filename => $filename }); return {} unless ( $ini->{package} ); my %params = (); --- 229,248 ---- sub _read_config { ! my ( $class, $type, $value ) = @_; ! my %ini_conf = (); ! if ( $type eq 'file' ) { ! unless ( -f $value ) { ! oi_error "Package configuration file '$value' does not exist."; ! } ! $ini_conf{filename} = $value; ! } ! elsif ( $type eq 'content' ) { ! unless ( $value ) { ! oi_error "No content to use for package configuration"; ! } ! $ini_conf{content} = $value; } ! my $ini = OpenInteract2::Config::Ini->new( \%ini_conf ); return {} unless ( $ini->{package} ); my %params = (); *************** *** 264,273 **** url = http://www.oirox.com/ description = This package rocks! ! [package template_plugin] TestPlugin = OpenInteract2::Plugin::Test ! [package observer] ! mywiki = OpenInteract2::Filter::MyWiki # Create a new package file from scratch --- 278,287 ---- url = http://www.oirox.com/ description = This package rocks! ! [package template_plugin] TestPlugin = OpenInteract2::Plugin::Test ! [package observer] ! mywiki = OpenInteract2::Filter::MyWiki # Create a new package file from scratch *************** *** 300,303 **** --- 314,323 ---- filename => 'work/pkg/mypackage/package-alt.ini' }); + + # Read the content yourself and pass it in + my $ini_text = _read_ini_file( '...' ); + my $c = OpenInteract2::Config::Package->new({ + content => $ini_text + }); =head1 DESCRIPTION *************** *** 323,329 **** =item * ! C<directory>: Read the configuration from the file C<package.conf> located in this directory. (Also: C<package_dir>) =back --- 343,353 ---- =item * ! C<directory>: Read the configuration from the file C<package.ini> located in this directory. (Also: C<package_dir>) + =item * + + C<content>: Use the text in this value as the package configuration. + =back |