File Coverage

blib/lib/App/Critique/Session/File.pm
Criterion Covered Total %
statement 32 37 86.4
branch 2 4 50.0
condition 3 5 60.0
subroutine 12 15 80.0
pod 0 10 0.0
total 49 71 69.0


line stmt bran cond sub pod time code
1             package App::Critique::Session::File;
2              
3 3     3   14094 use strict;
  3         4  
  3         70  
4 3     3   9 use warnings;
  3         3  
  3         109  
5              
6             our $VERSION = '0.04';
7             our $AUTHORITY = 'cpan:STEVAN';
8              
9 3     3   10 use Scalar::Util ();
  3         3  
  3         27  
10 3     3   8 use Carp ();
  3         2  
  3         33  
11              
12 3     3   683 use Path::Tiny ();
  3         9725  
  3         790  
13              
14             sub new {
15 2     2 0 788 my ($class, %args) = @_;
16              
17 2         5 my $path = $args{path};
18              
19 2 50       6 Carp::confess('You must supply a `path` argument')
20             unless defined $path;
21              
22 2 50 33     20 $path = Path::Tiny::path( $path )
23             unless Scalar::Util::blessed( $path )
24             && $path->isa('Path::Tiny');
25              
26             return bless {
27             path => $path,
28             meta => $args{meta} || {},
29 2   100     73 } => $class;
30             }
31              
32             # accessors
33              
34 2     2 0 366 sub path { $_[0]->{path} }
35 0     0 0 0 sub meta { $_[0]->{meta} }
36              
37             sub remember {
38 2     2 0 567 my ($self, $key, $value) = @_;
39 2         3 $self->{meta}->{ $key } = $value;
40 2         4 return;
41             }
42              
43             sub recall {
44 3     3 0 7 my ($self, $key) = @_;
45 3         11 return $self->{meta}->{ $key };
46             }
47              
48             sub forget {
49 1     1 0 505 my ($self, $key) = @_;
50 1         4 return delete $self->{meta}->{ $key };
51             }
52              
53             sub forget_all {
54 0     0 0 0 my ($self) = @_;
55             $self->{meta} = {}
56 0         0 }
57              
58             # ...
59              
60             sub relative_path {
61 0     0 0 0 my ($self, $path) = @_;
62 0         0 return $self->{path}->relative( $path );
63             }
64              
65             # ...
66              
67             sub pack {
68 4     4 0 692 my ($self) = @_;
69             return {
70             path => $self->{path}->stringify,
71             meta => $self->{meta},
72 4         11 };
73             }
74              
75             sub unpack {
76 1     1 0 1532 my ($class, $data) = @_;
77 1         4 return $class->new( %$data );
78             }
79              
80              
81             1;
82              
83             =pod
84              
85             =head1 NAME
86              
87             App::Critique::Session::File - Information about file processed by App::Critique
88              
89             =head1 VERSION
90              
91             version 0.04
92              
93             =head1 DESCRIPTION
94              
95             This class holds information about files that have been processed
96             by L<App::Critique> and contains no real user serviceable parts.
97              
98             =head1 AUTHOR
99              
100             Stevan Little <stevan@cpan.org>
101              
102             =head1 COPYRIGHT AND LICENSE
103              
104             This software is copyright (c) 2016 by Stevan Little.
105              
106             This is free software; you can redistribute it and/or modify it under
107             the same terms as the Perl 5 programming language system itself.
108              
109             =cut
110              
111             __END__
112              
113             # ABSTRACT: Information about file processed by App::Critique
114