Changeset 27993
- Timestamp:
- 01/06/09 13:36:52 (4 years ago)
- Location:
- lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk
- Files:
-
- 2 added
- 5 modified
-
. (modified) (1 prop)
-
MANIFEST (modified) (1 diff)
-
MANIFEST.SKIP (added)
-
lib/Plagger/Plugin/Acme/CustomConfig.pm (modified) (2 diffs)
-
lib/Plagger/Plugin/Acme/CustomConfig/ReadLine.pm (modified) (2 diffs)
-
lib/Plagger/Plugin/Acme/CustomConfig/ReadPassword.pm (modified) (2 diffs)
-
lib/Plagger/Plugin/Acme/CustomConfig_experiment.pm (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk
-
Property
svn:ignore set
to
blib
inc
pm_to_blib
Makefile
Makefile.old
Plagger-Plugin-Acme-CustomConfig-*.tar.gz
-
Property
svn:ignore set
to
-
lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk/MANIFEST
r27983 r27993 22 22 lib/Plagger/Plugin/Acme/CustomConfig/ReadLine.pm 23 23 lib/Plagger/Plugin/Acme/CustomConfig/ReadPassword.pm 24 lib/Plagger/Plugin/Acme/CustomConfig_experiment.pm 24 25 Makefile.PL 25 26 MANIFEST This list of files 27 MANIFEST.SKIP 26 28 README 27 29 t/00load.t -
lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk/lib/Plagger/Plugin/Acme/CustomConfig.pm
r27984 r27993 11 11 12 12 use Carp; 13 use English qw(-no_match_vars); 13 14 use UNIVERSAL::require; 14 15 15 16 sub register { 16 my $self = shift;17 my ( $self, $context ) = @_; 17 18 18 sub can_handle { 19 my ($data) = @_; 20 return ref $data eq 'HASH' 21 && ( keys %{ $data } )[0] =~ /^Acme::CustomConfig::/ 22 } 19 $context->register_hook( $self, 'plugin.init' => \&init ); 20 return; 21 } 23 22 24 sub by_order { 25 my ( $data, $a, $b ) = @_; 26 my $order_max = 999; 27 return ( ( values %{ $data->{$a} } )[0]->{order} || $order_max ) 28 <=> ( ( values %{ $data->{$b} } )[0]->{order} || $order_max ); 29 } 23 sub init { 24 my ( $self, $context ) = @_; 30 25 31 my $do_walk = Plagger::Plugin->can('do_walk'); 32 undef *Plagger::Plugin::do_walk; 33 *Plagger::Plugin::do_walk = sub { 34 my ($self, $data) = @_; 35 my @conf; 36 if ( ref $data eq 'HASH' ) { 37 foreach my $key ( sort { by_order( $data, $a, $b ) } 38 grep { can_handle( $data->{$_} ) } keys %{$data} ) 39 { 40 my $hash_ref = ( values %{ $data->{$key} } )[0]; 41 if ($key =~ /password/msx) { 42 $hash_ref->{is_password} = 1; 43 } 44 push @conf, \$data->{$key}; 26 foreach my $i ( 0 .. @{ $context->{plugins} } ) { 27 if ( ref $context->{plugins}->[$i] ne __PACKAGE__ ) { 28 next; 29 } 30 $i++; 31 my $plugin = $context->{plugins}->[$i]; # $plugin is the next plugin. 32 foreach my $ref ( @{ $self->conf } ) { 33 my $module = __PACKAGE__ . q{::} . ( keys %{$ref} )[0]; 34 my $config = ( values %{$ref} )[0]; 35 $module->require or croak $EVAL_ERROR; 36 my $value = $module->run($config); 37 if ( defined $value ) { 38 $plugin->conf->{ $config->{name} } = $value; 45 39 } 46 40 } 47 elsif ( ref $data eq 'ARRAY' ) { 48 foreach my $hash_ref ( grep { can_handle($_) } @{$data} ) { 49 push @conf, \$hash_ref; 50 } 51 } 52 53 foreach my $data_ref (@conf) { 54 my $is_password = delete ${$data_ref}->{is_password}; 55 my ($module, $conf) = each %{ ${$data_ref} }; 56 57 $module = 'Plagger::Plugin::' . $module; 58 $module->require or croak $@; 59 ${$data_ref} = $module->run($conf); 60 if ($is_password) { 61 ${$data_ref} = Plagger::Crypt->encrypt(${$data_ref}, 'base64'); 62 } 63 } 64 use Data::Dumper;die Dumper $self; 65 66 goto &{$do_walk}; 67 }; 41 } 68 42 return; 69 43 } … … 116 90 Register this plugin. 117 91 92 =head2 init($context) 93 94 Initialize this plugin. 95 118 96 =head1 DIAGNOSTICS 119 97 -
lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk/lib/Plagger/Plugin/Acme/CustomConfig/ReadLine.pm
r27984 r27993 8 8 use version; our $VERSION = qv('0.0.1'); 9 9 10 use English qw(-no_match_vars);11 10 use Term::ReadKey; 12 11 … … 22 21 $value = ReadLine(0); 23 22 chomp $value; 24 }; 25 if ($EVAL_ERROR) { 26 undef $value; 27 } 23 } or undef $value; 24 28 25 if ( !$value ) { 29 26 $value = $data->{default}; -
lang/perl/Plagger-Plugin-Acme-CustomConfig/trunk/lib/Plagger/Plugin/Acme/CustomConfig/ReadPassword.pm
r27984 r27993 8 8 use version; our $VERSION = qv('0.0.1'); 9 9 10 use English qw(-no_match_vars);11 10 use Term::ReadKey; 12 11 … … 23 22 $value = ReadLine(0); 24 23 chomp $value; 25 } ;24 } or undef $value; 26 25 ReadMode(0); 27 if ($EVAL_ERROR) {28 undef $value;29 }30 26 if ( !$value ) { 31 27 $value = $data->{default};
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)