File Coverage

blib/lib/Run/Parts/Common.pm
Criterion Covered Total %
statement 14 14 100.0
branch 4 6 66.6
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Run::Parts::Common;
2              
3 5     5   36 use Modern::Perl;
  5         9  
  5         44  
4 5     5   12668 use Exporter::Easy ( EXPORT => [qw[lines chomped_lines]] );
  5         7999  
  5         41  
5 5     5   640 use Scalar::Util qw(blessed);
  5         10  
  5         1253  
6              
7             =encoding utf8
8              
9             =head1 NAME
10              
11             Run::Parts::Common - Common helpers for Run::Parts and its backends
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             our $VERSION = '0.01';
20              
21             =head1 SYNOPSIS
22              
23             Exports helper functions used by Run::Parts as well as its backends.
24              
25             =head1 EXPORTED FUNCTIONS
26              
27             =head2 lines
28              
29             Gets an array of strings as parameter.
30              
31             In scalar context returns a string with all lines concatenated. In
32             array context it passes through the array.
33              
34             =cut
35              
36             sub lines {
37             # Sanity check
38 37 50   37 1 1528 die "lines is no method" if blessed $_[0];
39              
40 37 100       2102 return wantarray ? @_ : join("\n", @_)."\n";
41             }
42              
43             =head2 chomped_lines
44              
45             Gets an array of strings as parameter and calls chomp() on it.
46              
47             In scalar context returns a string with all lines concatenated. In
48             array context it passes through the array.
49              
50             =cut
51              
52             sub chomped_lines {
53             # Sanity check
54 19 50   19 1 1101 die "chomped_lines is no method" if blessed $_[0];
55              
56 19         137 chomp(@_);
57 19         218 return lines(@_);
58             }
59              
60              
61              
62             =head1 SEE ALSO
63              
64             Run::Parts
65              
66              
67             =head1 AUTHOR
68              
69             Axel Beckert, C<< >>
70              
71              
72             =head1 BUGS
73              
74             Please report any bugs or feature requests to C
75             rt.cpan.org>, or through the web interface at
76             L. I will
77             be notified, and then you'll automatically be notified of progress on
78             your bug as I make changes.
79              
80              
81             =head1 SUPPORT
82              
83             You can find documentation for this module with the perldoc command.
84              
85             perldoc Run::Parts::Common
86              
87              
88             =head1 LICENSE AND COPYRIGHT
89              
90             Copyright 2013 Axel Beckert.
91              
92             This program is free software; you can redistribute it and/or modify it
93             under the terms of either: the GNU General Public License as published
94             by the Free Software Foundation; or the Artistic License.
95              
96             See L for more information.
97              
98             =cut
99              
100             1; # End of Run::Parts::Common