/[Perly]/lib/Perly/Bootstrap.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/Perly/Bootstrap.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations)
Sun Jun 8 18:08:56 2008 UTC (15 years, 11 months ago) by dpavlin
File size: 968 byte(s)
Import bootstrap code and input data
1 dpavlin 44 use warnings;
2     use strict;
3    
4     package Perly::Bootstrap;
5     use base qw(Jifty::Bootstrap);
6    
7     use File::Find;
8     use File::Slurp;
9     use Data::Dump qw/dump/;
10    
11     =head1 Bootstrap examples
12    
13     Import initial code and data examples
14    
15     =cut
16    
17     sub run {
18     my $self = shift;
19    
20     my $system_user = Perly::CurrentUser->superuser( _bootstrap => 1 );
21    
22     # we need to first scan files and then import them to preserve order
23     my @import;
24     find({ no_chdir => 1, wanted => sub {
25     my $path = $File::Find::name;
26    
27     return unless $path =~ m!examples/(Code|Input)/(.+)!;
28     my ( $model, $name ) = ( $1, $2 );
29     push @import, [ $path, $model, $name ];
30    
31     }}, 'examples');
32    
33     foreach my $i ( sort { $a->[0] cmp $b->[0] } @import ) {
34     my ( $path, $model, $name ) = @$i;
35    
36     Jifty->log->info("import $path as $model with name $name");
37    
38     my $import = Jifty->app_class('Model', $model)->new;
39     $import->create(
40     name => $name,
41     $model eq 'Code' ? 'source' : 'content' => scalar read_file( $path ),
42     );
43     }
44    
45     }
46    
47     1;

  ViewVC Help
Powered by ViewVC 1.1.26