File Coverage

lib/Egg/Plugin/rc.pm
Criterion Covered Total %
statement 9 19 47.3
branch 0 10 0.0
condition 0 11 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 45 28.8


line stmt bran cond sub pod time code
1             package Egg::Plugin::rc;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: rc.pm 337 2008-05-14 12:30:09Z lushe $
6             #
7 1     1   412 use strict;
  1         2  
  1         37  
8 1     1   5 use warnings;
  1         2  
  1         29  
9 1     1   6 use YAML;
  1         2  
  1         1097  
10              
11             our $VERSION = '3.00';
12              
13             sub load_rc {
14 0     0 1   my($e, $dir)= @_;
15 0   0       my $rc_name= $ENV{EGG_RC_NAME} || 'egg_releaserc';
16 0           my($rc_file, $conf);
17 0 0 0       if ($rc_file= $dir and -e "$rc_file/.$rc_name") {
    0 0        
    0 0        
    0          
18 0           $rc_file.= "/.$rc_name";
19             } elsif ($conf= $e->config
20             and $rc_file= $conf->{root} and -e "$rc_file/.$rc_name") {
21 0           $rc_file.= "/.$rc_name";
22             } elsif (-e "~/.$rc_name") {
23 0           $rc_file = "~/.$rc_name";
24             } elsif (-e "/etc/$rc_name") {
25 0           $rc_file = "/etc/$rc_name";
26             } else {
27 0           return 0;
28             }
29 0 0         YAML::LoadFile($rc_file) || 0;
30             }
31              
32             1;
33              
34             __END__
35              
36             =head1 NAME
37              
38             Egg::Plugin::rc - Loading the resource code file for Egg is supported.
39              
40             =head1 SYNOPSIS
41              
42             use Egg qw/ rc /;
43            
44             my $rc= $e->load_rc;
45              
46             =head1 DESCRIPTION
47              
48             This plugin supports loading the resource code file for Egg.
49              
50             Please prepare the resource code file in the following places.
51              
52             ./.egg_releaserc
53             /project_root/.egg_releaserc
54             ~/.egg_releaserc
55             /etc/egg_releaserc
56              
57             * The content of the resource code file is a thing that is the YAML form for HASH.
58              
59             If file name is changed, environment variable EGG_RC_NAME is set.
60             Default is egg_releaserc.
61              
62             It tries to read the EGG_RC_NAME name like the miso when it evaluates under the
63             control of '/etc'. EGG_RC_NAME that puts '.' on the head is read usually.
64              
65             The key used with L<Egg::Helper> is as follows.
66              
67             =over 4
68              
69             =item * author ..... Writer's data.
70              
71             =item * copywright ..... Mark of copyright.
72              
73             =item * headcopy ..... It inserts it in the header of the generation module.
74              
75             =item * license ..... License form. Perl and GPL, etc.
76              
77             =back
78              
79             =head1 METHODS
80              
81             =head2 load_rc ([ATTR_HASH])
82              
83             If the rc file is found, YAML::LoadFile. Goes and returns the result.
84              
85             PATH can be set in 'current_dir' of ATTR_HASH and the rc file of an arbitrary
86             place be read.
87              
88             my $rc= $e->load_rc('/path/to');
89              
90             =head1 SEE ALSO
91              
92             L<Egg::Release>,
93             L<Egg::YAML>,
94              
95             =head1 AUTHOR
96              
97             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             Copyright (C) 2008 by Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>.
102              
103             This library is free software; you can redistribute it and/or modify
104             it under the same terms as Perl itself, either Perl version 5.8.6 or,
105             at your option, any later version of Perl 5 you may have available.
106              
107             =cut