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   242 use strict;
  68         83  
  68         1706  
19 68     68   212 use warnings;
  68         96  
  68         1488  
20 68     68   213 use utf8;
  68         88  
  68         359  
21              
22             package Devel::PerlySense::BookmarkConfig;
23             $Devel::PerlySense::BookmarkConfig::VERSION = '0.0217';
24              
25              
26 68     68   2756 use Spiffy -Base;
  68         92  
  68         337  
27 68     68   35434 use Carp;
  68     68   86  
  68     68   1004  
  68         195  
  68         84  
  68         1337  
  68         198  
  68         89  
  68         3344  
28 68     68   230 use Data::Dumper;
  68         93  
  68         2336  
29 68     68   242 use File::Basename;
  68         93  
  68         2923  
30 68     68   244 use File::Path;
  68         77  
  68         2643  
31 68     68   242 use Path::Class;
  68         87  
  68         2405  
32              
33 68     68   239 use Devel::PerlySense;
  68         83  
  68         407  
34 68     68   11568 use Devel::PerlySense::Util;
  68         99  
  68         3100  
35 68     68   265 use Devel::PerlySense::Util::Log;
  68         80  
  68         2258  
36              
37 68     68   17608 use Devel::PerlySense::Bookmark::Definition;
  68         113  
  68         321  
38 68     68   29399 use Devel::PerlySense::Bookmark::MatchResult;
  68         107  
  68         362  
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 947 sub raDefinition {
66             return [
67 13         249 map { Devel::PerlySense::Bookmark::Definition->newFromConfig( %$_ ) }
68 9         10 @{$self->oPerlySense->rhConfig->{bookmark}}
  9         138  
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 166 sub new {
84 92         471 my ($oPerlySense) = Devel::PerlySense::Util::aNamedArg(["oPerlySense"], @_);
85              
86 92         237 $self = bless {}, $self; #Create the object. It looks weird because of Spiffy
87 92         2200 $self->oPerlySense($oPerlySense);
88              
89 92         2024 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 887 sub aMatchResult {
105 5         21 my ($file) = Devel::PerlySense::Util::aNamedArg(["file"], @_);
106              
107 5 100       16 defined( my $source = slurp($file) ) or die("Could not read source file ($file)\n");
108              
109 4 50       91 $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         14  
118              
119 4         23 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