Changeset 21030
- Timestamp:
- 10/09/08 11:44:08 (5 years ago)
- Location:
- lang/perl/Archer/trunk
- Files:
-
- 3 modified
-
examples/config.yaml (modified) (1 diff)
-
lib/Archer.pm (modified) (1 diff)
-
lib/Archer/ConfigLoader.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Archer/trunk/examples/config.yaml
r3671 r21030 2 2 work_dir: /tmp/working_archer/ 3 3 dest_dir: /path/to/dest/ 4 assets_path: /tmp/ 4 5 5 6 tasks: -
lang/perl/Archer/trunk/lib/Archer.pm
r21029 r21030 167 167 my ( $self, $level ) = @_; 168 168 169 $levels{ $level }170 >= $levels{ $self->{ config }->{ global }->{ log }->{ level }};169 my $setting_level = $self->{config}->{global}->{log}->{level} || 'debug'; 170 $levels{ $level } >= $levels{ $setting_level }; 171 171 } 172 172 -
lang/perl/Archer/trunk/lib/Archer/ConfigLoader.pm
r21029 r21030 2 2 use strict; 3 3 use warnings; 4 use YAML;5 4 use Storable; 6 5 use Carp; … … 9 8 use FindBin; 10 9 10 my $yaml_class; 11 if (eval "require YAML::Syck; 1;") { 12 $yaml_class = "YAML::Syck"; 13 } else { 14 require YAML; 15 $yaml_class = "YAML"; 16 } 17 11 18 sub new { bless {}, shift } 12 19 13 20 sub load { 14 21 my ( $self, $stuff, $context ) = @_; 22 23 $context->log('debug' => "yaml class: $yaml_class"); 15 24 16 25 # load … … 19 28 || ( -e $stuff && -r _ ) ) 20 29 { 21 $config = YAML::LoadFile($stuff);30 $config = $yaml_class->can('LoadFile')->($stuff); 22 31 $context->{config_path} = $stuff if $context; 23 32 } 24 33 elsif ( ref($stuff) && ref($stuff) eq 'SCALAR' ) { 25 $config = YAML::Load( ${$stuff} );34 $config = $yaml_class->can('Load')->( ${$stuff} ); 26 35 } 27 36 elsif ( ref($stuff) && ref($stuff) eq 'HASH' ) { … … 38 47 # verify 39 48 my $schema_file = file( $config->{global}->{assets_path}, 'kwalify', 'schema.yaml' ); 40 my $res = validate( YAML::LoadFile($schema_file), $config );49 my $res = validate( $yaml_class->can('LoadFile')->($schema_file), $config ); 41 50 $context->log( error => $res ) unless $res == 1; 42 51
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)