File Coverage

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 63     63   401 use strict;
  63         95  
  63         1931  
19 63     63   247 use warnings;
  63         89  
  63         1851  
20 63     63   231 use utf8;
  63         76  
  63         449  
21              
22             package Devel::PerlySense::BookmarkConfig;
23              
24              
25              
26 63     63   4789 use Spiffy -Base;
  63         140  
  63         289  
27 63     63   41573 use Carp;
  63     63   81  
  63     63   1833  
  63         217  
  63         76  
  63         1260  
  63         234  
  63         78  
  63         4037  
28 63     63   235 use Data::Dumper;
  63         94  
  63         2368  
29 63     63   260 use File::Basename;
  63         83  
  63         3542  
30 63     63   247 use File::Path;
  63         90  
  63         3018  
31 63     63   244 use Path::Class;
  63         105  
  63         2729  
32              
33 63     63   256 use Devel::PerlySense;
  63         90  
  63         400  
34 63     63   12376 use Devel::PerlySense::Util;
  63         81  
  63         3391  
35 63     63   243 use Devel::PerlySense::Util::Log;
  63         82  
  63         2518  
36              
37 63     63   37259 use Devel::PerlySense::Bookmark::Definition;
  63         122  
  63         495  
38 63     63   33948 use Devel::PerlySense::Bookmark::MatchResult;
  63         118  
  63         510  
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 20 sub raDefinition {
66             return [
67 13         342 map { Devel::PerlySense::Bookmark::Definition->newFromConfig( %$_ ) }
  9         251  
68 9         9 @{$self->oPerlySense->rhConfig->{bookmark}}
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 84     84 1 242 sub new {
84 84         424 my ($oPerlySense) = Devel::PerlySense::Util::aNamedArg(["oPerlySense"], @_);
85              
86 84         299 $self = bless {}, $self; #Create the object. It looks weird because of Spiffy
87 84         4561 $self->oPerlySense($oPerlySense);
88              
89 84         3427 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 181 sub aMatchResult {
105 5         17 my ($file) = Devel::PerlySense::Util::aNamedArg(["file"], @_);
106              
107 5 100       19 defined( my $source = slurp($file) ) or die("Could not read source file ($file)\n");
108              
109 4 50       113 $self->oPerlySense->setFindProject(file => $file) or debug("Could not identify any PerlySense Project for Bookmark matching, but that's not fatal\n");
110              
111 6         39 my @aMatchResult = map {
112 4         12 Devel::PerlySense::Bookmark::MatchResult->newFromMatch(
113             oDefinition => $_,
114             file => $file,
115             source => $source
116             );
117 4         8 } @{$self->raDefinition};
118              
119 4         50 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 Lindström, C<< <johanl[ÄT]DarSerMan.com> >>
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 Lindström, 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