From: Chris W. <la...@us...> - 2005-02-08 01:49:38
|
Update of /cvsroot/openinteract/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30530 Modified Files: build_bricks Log Message: move the brick-generation template to OI2::Brick Index: build_bricks =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/build_bricks,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** build_bricks 2 Feb 2005 13:20:03 -0000 1.5 --- build_bricks 8 Feb 2005 01:49:30 -0000 1.6 *************** *** 9,23 **** use File::Basename qw( basename ); use MIME::Base64 qw( encode_base64 ); use Template; my %SPECS = ( 'sample/package' => [ ! 'Package', 'All resources used for creating a package', 'oi2_manage create_package --package=foo', 'This class just holds all the static resources used when creating a package.', ], 'sample/apache' => [ ! 'Apache', 'All resources used for creating Apache 1.x configurations in a new website', 'oi2_manage create_website --website_dir=/path/to/site', --- 9,30 ---- use File::Basename qw( basename ); use MIME::Base64 qw( encode_base64 ); + use OpenInteract2::Brick; use Template; my %SPECS = ( 'sample/package' => [ ! 'Package', 'package', 'All resources used for creating a package', 'oi2_manage create_package --package=foo', 'This class just holds all the static resources used when creating a package.', ], + 'sample/package_cpan' => [ + 'PackageCPAN', 'package_cpan', + 'All resources used for creating a CPAN distribution from a package', + 'oi2_manage create_cpan --package_dir=/path/to/mypackage', + 'This class just holds all the static resources used when creating a CPAN distribution from a package.', + ], 'sample/apache' => [ ! 'Apache', 'apache', 'All resources used for creating Apache 1.x configurations in a new website', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 26,30 **** ], 'sample/apache2' => [ ! 'Apache2', 'All resources used for creating Apache 2.x configurations in a new website', 'oi2_manage create_website --website_dir=/path/to/site', --- 33,37 ---- ], 'sample/apache2' => [ ! 'Apache2', 'apache2', 'All resources used for creating Apache 2.x configurations in a new website', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 33,37 **** ], 'sample/daemon' => [ ! 'Daemon', 'Configuration used for creating the standalone webserver', 'oi2_manage create_website --website_dir=/path/to/site', --- 40,44 ---- ], 'sample/daemon' => [ ! 'Daemon', 'daemon', 'Configuration used for creating the standalone webserver', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 39,43 **** ], 'sample/website/cgi-bin' => [ ! 'CGI', 'Script for running OI2 as a CGI', 'oi2_manage create_website --website_dir=/path/to/site', --- 46,50 ---- ], 'sample/website/cgi-bin' => [ ! 'CGI', 'cgi', 'Script for running OI2 as a CGI', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 45,49 **** ], 'sample/website/conf' => [ ! 'WebsiteConfig', 'Various non-server-specific configuration files for OI2 website', 'oi2_manage create_website --website_dir=/path/to/site', --- 52,56 ---- ], 'sample/website/conf' => [ ! 'WebsiteConfig', 'website_config', 'Various non-server-specific configuration files for OI2 website', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 51,55 **** ], 'sample/website/msg' => [ ! 'Messages', 'All global localization messages', 'oi2_manage create_website --website_dir=/path/to/site', --- 58,62 ---- ], 'sample/website/msg' => [ ! 'Messages', 'messages', 'All global localization messages', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 57,61 **** ], 'sample/website/template' => [ ! 'Widgets', 'All global TT2 template files', 'oi2_manage create_website --website_dir=/path/to/site', --- 64,68 ---- ], 'sample/website/template' => [ ! 'Widgets', 'widgets', 'All global TT2 template files', 'oi2_manage create_website --website_dir=/path/to/site', *************** *** 64,74 **** ); { unless ( -d 'sample' ) { die "You must run this from the root of the OI2 source directory\n"; } ! my $oi2_version = read_version(); my $template = Template->new(); - my $brick_template = join( '', <DATA> ); my @brick_params = (); --- 71,82 ---- ); + my ( $OI2_VERSION ); + { unless ( -d 'sample' ) { die "You must run this from the root of the OI2 source directory\n"; } ! $OI2_VERSION = read_version(); my $template = Template->new(); my @brick_params = (); *************** *** 77,88 **** my @brick_files = read_brick_files( $brick_dir ); my $brick_name = $brick_info->[0]; my %params = ( brick_dir => $brick_dir, brick_name => $brick_name, ! lc_brick_name => lc $brick_name, ! brick_summary => $brick_info->[1], ! brick_example => $brick_info->[2], ! brick_description => $brick_info->[3], ! oi2_version => $oi2_version, all_files => \@brick_files, ); --- 85,99 ---- my @brick_files = read_brick_files( $brick_dir ); my $brick_name = $brick_info->[0]; + my $full_description = join( "\n\n", + $brick_info->[4], get_oi2_version_description(), + ); + my %params = ( brick_dir => $brick_dir, brick_name => $brick_name, ! lc_brick_name => $brick_info->[1], ! brick_summary => $brick_info->[2], ! brick_example => $brick_info->[3], ! brick_description => $full_description, all_files => \@brick_files, ); *************** *** 92,108 **** # Now do the same with packages, but base64 them first... - my $pkg_desc = 'This class holds the Base64-encoded versions of ' . - 'package file "%s" shipped with OpenInteract2. Once you ' . - 'decode them you should store them as a ZIP file ' . - 'and then read them in with Archive::Zip or some ' . - 'other utility.'; my %pkg_brick_base = ( brick_dir => 'pkg', brick_name => 'App%s', - lc_brick_name => 'pkg_%s', brick_summary => "Base-64 encoded OI2 package '%s' shipped with distribution", brick_example => 'oi2_manage create_website --website_dir=/path/to/site', ! brick_description => $pkg_desc, ! oi2_version => $oi2_version, ); foreach my $pkg_file ( read_package_files( 'pkg/' ) ) { --- 103,112 ---- # Now do the same with packages, but base64 them first... my %pkg_brick_base = ( brick_dir => 'pkg', brick_name => 'App%s', brick_summary => "Base-64 encoded OI2 package '%s' shipped with distribution", brick_example => 'oi2_manage create_website --website_dir=/path/to/site', ! ); foreach my $pkg_file ( read_package_files( 'pkg/' ) ) { *************** *** 112,123 **** my $cc_base_name = ucfirst( $base_name ); $cc_base_name =~ s/_(\w)/uc($1)/ge; ! $pkg_brick{brick_name} = sprintf( ! $pkg_brick{brick_name}, $cc_base_name ); ! $pkg_brick{lc_brick_name} = sprintf( ! $pkg_brick{lc_brick_name}, $base_name ); ! $pkg_brick{brick_summary} = sprintf( ! $pkg_brick{brick_summary}, $pkg_file->{name} ); ! $pkg_brick{brick_description} = sprintf( ! $pkg_brick{brick_description}, $pkg_file->{name} ); $pkg_brick{all_files} = [ $pkg_file ]; push @brick_params, \%pkg_brick; --- 116,126 ---- my $cc_base_name = ucfirst( $base_name ); $cc_base_name =~ s/_(\w)/uc($1)/ge; ! my $pkg_brick_name = "pkg_$base_name"; ! $pkg_brick{brick_name} = sprintf( $pkg_brick{brick_name}, $cc_base_name ); ! $pkg_brick{lc_brick_name} = $pkg_brick_name; ! $pkg_brick{brick_summary} = sprintf( $pkg_brick{brick_summary}, $pkg_file->{name} ); ! $pkg_brick{brick_description} = get_package_description( ! $pkg_file->{name}, $pkg_brick_name ! ); $pkg_brick{all_files} = [ $pkg_file ]; push @brick_params, \%pkg_brick; *************** *** 130,134 **** --- 133,143 ---- } + my $brick_template = OpenInteract2::Brick->get_brick_class_template(); + foreach my $brick_param ( @brick_params ) { + $brick_param->{authors} = [ + { name => 'Chris Winters', email => 'ch...@cw...' }, + ]; + $brick_param->{author_names} = [ 'Chris Winters' ]; my $brick_name = $brick_param->{brick_name}; my $output_file = "$brick_lib_dir/$brick_name.pm"; *************** *** 184,190 **** open( ZIP, '<', $zipfile ) || die "Cannot read '$zipfile': $!"; ! my ( $buf, $content ); while ( read( ZIP, $buf, 60*57 ) ) { ! $content .= encode_base64( $buf ); } close( ZIP ); --- 193,199 ---- open( ZIP, '<', $zipfile ) || die "Cannot read '$zipfile': $!"; ! my ( $buf, @contents ); while ( read( ZIP, $buf, 60*57 ) ) { ! push @contents, encode_base64( $buf ); } close( ZIP ); *************** *** 195,201 **** destination => "pkg $base_filename", evaluate => 'no', ! contents => $content, }; } return @specs; } --- 204,211 ---- destination => "pkg $base_filename", evaluate => 'no', ! contents => join( '', @contents ), }; } + return @specs; } *************** *** 217,292 **** } ! __DATA__ ! package OpenInteract2::Brick::[% brick_name %]; ! ! use strict; ! use base qw( OpenInteract2::Brick ); ! use OpenInteract2::Exception; ! ! my %INLINED_SUBS = ( ! [% FOREACH file_info = all_files -%] ! '[% file_info.name %]' => '[% file_info.inline_name %]', ! [% END -%] ! ); ! ! sub get_name { ! return '[% lc_brick_name %]'; ! } ! ! sub get_resources { ! return ( ! [% FOREACH file_info = all_files -%] ! '[% file_info.name %]' => [ '[% file_info.destination %]', '[% file_info.evaluate %]' ], ! [% END -%] ! ); ! } ! ! sub load { ! my ( $self, $resource_name ) = @_; ! my $inline_sub_name = $INLINED_SUBS{ $resource_name }; ! unless ( $inline_sub_name ) { ! OpenInteract2::Exception->throw( ! "Resource name '$resource_name' not found ", ! "in ", ref( $self ), "; cannot load content." ); ! } ! return $self->$inline_sub_name(); ! } ! ! OpenInteract2::Brick->register_factory_type( get_name() => __PACKAGE__ ); ! ! =pod ! ! =head1 NAME ! ! OpenInteract2::Brick::[% brick_name %] - [% brick_summary %] ! ! =head1 SYNOPSIS ! ! [% brick_example | indent(2) %] ! ! =head1 DESCRIPTION ! ! [% brick_description %] ! ! These resources are associated with OpenInteract2 version [% oi2_version %]. ! =head1 COPYRIGHT ! Copyright (c) 2005 Chris Winters. All rights reserved. ! This library is free software; you can redistribute it and/or modify ! it under the same terms as Perl itself. ! =head1 AUTHORS ! Chris Winters E<lt>ch...@cw...E<gt> ! =cut ! [% FOREACH file_info = all_files %] ! sub [% file_info.inline_name %] { ! return <<'SOMELONGSTRING'; ! [% file_info.contents %] ! SOMELONGSTRING } - [% END %] --- 227,261 ---- } ! sub get_package_description { ! my ( $pkg_file, $pkg_brick_name ) = @_; ! my $version_info = get_oi2_version_description(); ! return sprintf( <<'DESC', $pkg_file, $pkg_brick_name, $version_info ); ! Are you sure you even need to be reading this? If you are just looking ! to install a package just follow the instructions from the SYNOPSIS. ! Still here? This class holds the Base64-encoded versions of package ! file "%s" shipped with OpenInteract2. Once you decode them you ! should store them as a ZIP file and then read them in with ! Archive::Zip or some other utility. ! A typical means to do this is: ! my $brick = OpenInteract2::Brick->new( '%s' ); ! # there's only one resource in this brick... ! my ( $pkg_name ) = $brick->list_resources; ! my $pkg_info = $brick->load_resource( $pkg_name ); ! my $pkg_file = OpenInteract2::Util->decode_base64_and_store( ! \$pkg_info->{content} ! ); ! # $pkg_file now references a file on the filesystem that you can ! # manipulate as normal ! %s ! DESC ! } ! sub get_oi2_version_description { ! return "These resources are associated with OpenInteract2 version $OI2_VERSION."; } |