| 1 | package App::PodPreview; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | $App::PodPreview::VERSION = '0.002'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Preview POD files in a browser | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use autodie; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Perl6::Export::Attrs; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Pod::Simple::HTML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Config::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Browser::Open qw(open_browser_cmd); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use File::HomeDir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use File::Temp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Carp qw(carp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub podpreview :Export | ||||||||||||||||||||||||||
|
Subroutine
podpreview: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | { | ||||||||||||||||||||||||||||
| 23 | 0 | my $input_pod = shift; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my $parser = Pod::Simple::HTML->new; | |||||||||||||||||||||||||||
| 26 | 0 | my $config_path = File::Spec->catfile(File::HomeDir->my_home, '.podpreview'); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ( -e $config_path and -f $config_path ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $config_path and -f $config_path
MC/DC0%0/2
-e $config_path and -f $config_path
-e $config_path
-f $config_path
Truth table0%0/3
A and B
A= -e $config_pathB= -f $config_path
| |||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $config = Config::Tiny->read($config_path) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | or carp "Error loading config: " . Config::Tiny::errstr; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my @options = qw( | |||||||||||||||||||||||||||
| 34 | perldoc_url_prefix | ||||||||||||||||||||||||||||
| 35 | perldoc_url_postfix | ||||||||||||||||||||||||||||
| 36 | man_url_prefix | ||||||||||||||||||||||||||||
| 37 | man_url_postfix | ||||||||||||||||||||||||||||
| 38 | title_prefix | ||||||||||||||||||||||||||||
| 39 | title_postfix | ||||||||||||||||||||||||||||
| 40 | html_h_level | ||||||||||||||||||||||||||||
| 41 | html_header_before_title | ||||||||||||||||||||||||||||
| 42 | html_header_after_title | ||||||||||||||||||||||||||||
| 43 | html_footer | ||||||||||||||||||||||||||||
| 44 | index | ||||||||||||||||||||||||||||
| 45 | html_css | ||||||||||||||||||||||||||||
| 46 | html_javascript | ||||||||||||||||||||||||||||
| 47 | force_title | ||||||||||||||||||||||||||||
| 48 | default_title | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | foreach my $option (@options) | |||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( exists $config->{_}->{$option} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||
| 55 | 0 | $parser->$option( $config->{_}->{$option} ); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | my $fh = File::Temp->new( SUFFIX => '.html'); | |||||||||||||||||||||||||||
| 61 | 0 | $parser->output_fh($fh); | |||||||||||||||||||||||||||
| 62 | 0 | $parser->parse_file($input_pod); | |||||||||||||||||||||||||||
| 63 | 0 | close $fh; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( $^O eq "MSWin32" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | # Browser::Open currently has issues on Win32 | ||||||||||||||||||||||||||||
| 68 | 0 | exec ( "start " . $fh->filename ); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | else | ||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||
| 72 | 0 | exec ( open_browser_cmd . " " . $fh->filename ); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 1 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 NAME | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | App::PodPreview - Preview POD files in a browser | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 VERSION | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | version 0.002 | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | use App::PodPreview qw(podpreview); | ||||||||||||||||||||||||||||
| 89 | podpreview('/path/to/file.pod'); | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | This module is used internally by the C<podpreview> utility. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Peter Shangov <pshangov at yahoo dot com> | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | This software is copyright (c) 2010 by Peter Shangov. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | This is free software; you can redistribute it and/or modify it under the | ||||||||||||||||||||||||||||
| 104 | same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||