File Coverage

lib/App/Followme/TextData.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 1 2 50.0
total 39 40 97.5


line stmt bran cond sub pod time code
1             package App::Followme::TextData;
2              
3 3     3   637 use 5.008005;
  3         23  
4 3     3   22 use strict;
  3         6  
  3         71  
5 3     3   16 use warnings;
  3         6  
  3         118  
6 3     3   20 use integer;
  3         8  
  3         17  
7 3     3   84 use lib '../..';
  3         6  
  3         23  
8              
9 3     3   432 use base qw(App::Followme::FileData);
  3         5  
  3         695  
10 3     3   24 use App::Followme::FIO;
  3         7  
  3         356  
11 3     3   23 use App::Followme::Web;
  3         7  
  3         595  
12              
13             our $VERSION = "2.02";
14              
15             #----------------------------------------------------------------------
16             # Read the default parameter values
17              
18             sub parameters {
19 28     28 1 49 my ($self) = @_;
20              
21             return (
22 28         100 extension => 'md',
23             text_pkg => 'Text::Markdown',
24             text_method => 'markdown',
25             );
26             }
27              
28             #----------------------------------------------------------------------
29             # Convert content block markup to html
30              
31             sub fetch_as_html {
32 44     44 0 89 my ($self, $content_block) = @_;
33              
34 44         77 my $method = $self->{text_method};
35 44         212 return $self->{text}->$method($content_block);
36             }
37              
38             1;
39             __END__
40             =encoding utf-8
41              
42             =head1 NAME
43              
44             App::Followme::TextData - Convert text files to html
45              
46             =head1 SYNOPSIS
47              
48             use FIO;
49             my $data = App::Followme::TextData->new();
50             my $page = fio_read_page('new_file.md');
51             my $html = $data_fetch_as_html($page);
52              
53             =head1 DESCRIPTION
54              
55             This module contains the methods that build metadata values from a text
56             file. The text file is optionally preceded by a section containing Yaml
57             formatted data.
58              
59             =head1 METHODS
60              
61             All data are accessed through the build method.
62              
63             =over 4
64              
65             =item my %data = $obj->build($name, $filename);
66              
67             Build a variable's value. The first argument is the name of the variable. The
68             second argument is the name of the file the metadata is being computed for. If
69             it is undefined, the filename stored in the object is used.
70              
71             =back
72              
73             =head1 VARIABLES
74              
75             The text metadata class can evaluate the following variables. When passing
76             a name to the build method, the sigil should not be used.
77              
78             =over 4
79              
80             =item $body
81              
82             All the contents of the file, minus the title if there is one. Text is
83             called on the file's content to generate html before being stored in the body
84             variable.
85              
86             =item $description
87              
88             A one line sentence description of the content.
89              
90             =item $title
91              
92             The title of the page is derived from contents of the top header tag, if one is
93             at the front of the file content, or the filename, if it is not.
94              
95              
96             =back
97              
98             =head1 CONFIGURATION
99              
100             The following parameters are used from the configuration:
101              
102             =over 4
103              
104             =item extension
105              
106             The extension of files that are converted to web pages. The default value
107             is md.
108              
109             =item text_pkg
110              
111             The name of the package which converts text to html. The default value
112             is 'Text::Markdown'.
113              
114             =item text_method
115              
116             The name of the method that does the conversion. The default value is 'markdown'.
117              
118             =back
119              
120             =head1 LICENSE
121              
122             Copyright (C) Bernie Simon.
123              
124             This library is free software; you can redistribute it and/or modify
125             it under the same terms as Perl itself.
126              
127             =head1 AUTHOR
128              
129             Bernie Simon E<lt>bernie.simon@gmail.comE<gt>
130              
131             =cut