Rhetoric/Helpers.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« auto/share/dist/Rhetoric/widgets/sidebar/search.pl ↑ Summary Rhetoric.pm »
1 package Rhetoric::Helpers;
2 1 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use aliased 'Squatting::H';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Data::Page;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 0 ▶use Rhetoric::Formatters;
Subroutine BEGIN: called CC=1 SCAR=2.6
7 use IO::All;
8  
9 our $F = $Rhetoric::Formatters::F;
10 our @EXPORT_OK = qw(now slug rl wl file_owner $F);
11 our %EXPORT_TAGS = (all => \@EXPORT_OK);
12  
13 # y m d h m s
14 sub now {
15 my @d = localtime;
16 return (
17 $d[5]+1900,
18 $d[4]+1,
19 $d[3],
20 $d[2],
21 $d[1],
22 $d[0]
23 );
24 }
25  
26 # make a url-friendly slug out of a post title
27 sub slug {
28 # FIXME - protect against duplicate y-m-slug combinations
29 my $title = shift;
30 $title =~ s/^\W+//;
31 $title =~ s/\W+$//;
32 $title =~ s/\W+/-/g;
33 return $title;
34 }
35  
36 # read line
37 sub rl {
38 my $file = shift;
39 io($file)->chomp->getline();
40 }
41  
42 # write line
43 sub wl {
44 my $file = shift;
45 my $line = shift;
46 io($file) < "$line\n";
47 }
48  
49 # owner of file
50 sub file_owner {
51 my $file = shift;
52 getpwuid( (stat($file))[4] );
53 }
54  
55 1;
« auto/share/dist/Rhetoric/widgets/sidebar/search.pl ↑ Summary Rhetoric.pm »