File Coverage

blib/lib/Devel/PerlySense/BookmarkConfig.pm
Criterion Covered Total %
statement 65 65 100.0
branch 3 4 75.0
condition n/a
subroutine 19 19 100.0
pod 2 3 66.6
total 89 91 97.8


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Devel::PerlySense::BookmarkConfig - A collection of
4             Bookmark::Definition and their configuration.
5              
6              
7             =head1 DESCRIPTION
8              
9             This is the Bookmark config chunk, and the parsed Bookmark::Definition
10             objects that results in.
11              
12             =cut
13              
14              
15              
16              
17              
18 68     68   238 use strict;
  68         82  
  68         1653  
19 68     68   205 use warnings;
  68         74  
  68         1559  
20 68     68   211 use utf8;
  68         87  
  68         376  
21              
22             package Devel::PerlySense::BookmarkConfig;
23             $Devel::PerlySense::BookmarkConfig::VERSION = '0.0218';
24              
25              
26 68     68   2766 use Spiffy -Base;
  68         95  
  68         338  
27 68     68   35498 use Carp;
  68     68   91  
  68     68   985  
  68         196  
  68         83  
  68         1310  
  68         198  
  68         78  
  68         3407  
28 68     68   221 use Data::Dumper;
  68         92  
  68         2243  
29 68     68   242 use File::Basename;
  68         89  
  68         2850  
30 68     68   244 use File::Path;
  68         73  
  68         2555  
31 68     68   236 use Path::Class;
  68         81  
  68         2283  
32              
33 68     68   243 use Devel::PerlySense;
  68         82  
  68         430  
34 68     68   11685 use Devel::PerlySense::Util;
  68         90  
  68         3058  
35 68     68   300 use Devel::PerlySense::Util::Log;
  68         78  
  68         2237  
36              
37 68     68   17323 use Devel::PerlySense::Bookmark::Definition;
  68         112  
  68         326  
38 68     68   29581 use Devel::PerlySense::Bookmark::MatchResult;
  68         109  
  68         357  
39              
40              
41              
42              
43              
44             =head1 PROPERTIES
45              
46             =head2 oPerlySense
47              
48             Devel::PerlySense object.
49              
50             Default: set during new()
51              
52             =cut
53             field "oPerlySense" => undef;
54              
55              
56              
57              
58              
59             =head2 raDefinition
60              
61             Array ref with Bookmark::Definition objects from the oPerlySense
62             config.
63              
64             =cut
65 9     9 1 913 sub raDefinition {
66             return [
67 13         241 map { Devel::PerlySense::Bookmark::Definition->newFromConfig( %$_ ) }
68 9         13 @{$self->oPerlySense->rhConfig->{bookmark}}
  9         126  
69             ];
70             }
71              
72              
73              
74              
75              
76             =head1 METHODS
77              
78             =head2 new(oPerlySense)
79              
80             Create new BookmarkConfig object. Associate it with $oPerlySense.
81              
82             =cut
83 92     92 1 175 sub new {
84 92         489 my ($oPerlySense) = Devel::PerlySense::Util::aNamedArg(["oPerlySense"], @_);
85              
86 92         246 $self = bless {}, $self; #Create the object. It looks weird because of Spiffy
87 92         2230 $self->oPerlySense($oPerlySense);
88              
89 92         2052 return($self);
90             }
91              
92              
93              
94              
95              
96             =head2 aMatch(file)
97              
98             Parse the text in $file and return list of Bookmark::MatchResult
99             objects that have matches.
100              
101             Die on errors, like if $file doesn't exist.
102              
103             =cut
104 5     5 0 883 sub aMatchResult {
105 5         18 my ($file) = Devel::PerlySense::Util::aNamedArg(["file"], @_);
106              
107 5 100       18 defined( my $source = slurp($file) ) or die("Could not read source file ($file)\n");
108              
109 4 50       98 $self->oPerlySense->setFindProject(file => $file) or debug("Could not identify any PerlySense Project for Bookmark matching, but that's not fatal\n");
110              
111             my @aMatchResult = map {
112 6         37 Devel::PerlySense::Bookmark::MatchResult->newFromMatch(
113             oDefinition => $_,
114             file => $file,
115             source => $source
116             );
117 4         7 } @{$self->raDefinition};
  4         13  
118              
119 4         27 return(@aMatchResult);
120             }
121              
122              
123              
124              
125              
126             1;
127              
128              
129              
130              
131              
132             __END__
133              
134             =encoding utf8
135              
136             =head1 AUTHOR
137              
138             Johan Lindstrom, C<< <johanl@cpan.org> >>
139              
140             =head1 BUGS
141              
142             Please report any bugs or feature requests to
143             C<bug-devel-perlysense@rt.cpan.org>, or through the web interface at
144             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense>.
145             I will be notified, and then you'll automatically be notified of progress on
146             your bug as I make changes.
147              
148             =head1 ACKNOWLEDGEMENTS
149              
150             =head1 COPYRIGHT & LICENSE
151              
152             Copyright 2005 Johan Lindstrom, All Rights Reserved.
153              
154             This program is free software; you can redistribute it and/or modify it
155             under the same terms as Perl itself.
156              
157             =cut