File Coverage

blib/lib/Wiki/Toolkit/Formatter/Mediawiki/Link.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 2 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 1 1 100.0
total 13 29 44.8


line stmt bran cond sub pod time code
1             package Wiki::Toolkit::Formatter::Mediawiki::Link;
2              
3 1     1   10802 use warnings;
  1         2  
  1         32  
4 1     1   6 use strict;
  1         2  
  1         54  
5              
6             =head1 NAME
7              
8             Wiki::Toolkit::Formatter::Mediawiki::Link - Link object returned by Wiki::Toolkit::Formatter::Mediawiki's
9             find_internal_links method.
10              
11             =cut
12              
13             our $VERSION = $Wiki::Toolkit::Formatter::Mediawiki::VERSION;
14              
15             =head1 SYNOPSIS
16              
17             This package implements a link object for the Wiki::Toolkit::Formatter::Mediawiki
18             which stores a link 'name' and its 'type' be it page, external, or a template link.
19             If both 'name' and 'type' are not provided, the method returns undef.
20              
21             use Wiki::Toolkit
22             use Wiki::Toolkit::Store::Mediawiki;
23             use Wiki::Toolkit::Formatter::Mediawiki;
24            
25             my $store = Wiki::Toolkit::Store::Mediawiki->new ( ... );
26             # See below for parameter details.
27             my $formatter = Wiki::Toolkit::Formatter::Mediawiki->new (%config,
28             store => $store);
29             my $wiki = Wiki::Toolkit->new (store => $store, formatter => $formatter);
30            
31             my $content = $config{wiki}->retrieve_node ($node);
32             my @links_to = $config{formatter}->find_internal_links ($content);
33            
34             foreach my $link (@links_to){
35             print $link . "\n"
36             unless $link->{type} eq 'EXTERNAL';
37             }
38              
39             =cut
40              
41              
42 1     1   5 use overload ('""' => '_string');
  1         2  
  1         7  
43              
44              
45             =head1 METHODS
46              
47             =head2 new
48              
49             =cut
50              
51             sub new
52             {
53 0     0 1   my ($class, $name, $type) = @_;
54              
55 0           my $self = {};
56 0           bless $self, $class;
57             return undef
58 0 0 0       unless $name && $type;
59 0           $self->{name} = $name;
60 0           $self->{type} = $type;
61              
62 0           return $self;
63             }
64              
65             # Overload the stringify.
66             sub _string {
67 0     0     my $this = shift;
68              
69 0           return $this->{name};
70             }
71              
72              
73             =head1 SEE ALSO
74              
75             =over 4
76              
77             =item L
78              
79             =item L
80              
81             =item L
82              
83             =item L
84              
85             =back
86              
87             =head1 AUTHOR
88              
89             Derek R. Price, C<< >>
90              
91             =head1 BUGS
92              
93             Please report any bugs or feature requests to
94             C, or through the web interface at
95             L.
96             I will be notified, and then you'll automatically be notified of progress on
97             your bug as I make changes.
98              
99             =head1 SUPPORT
100              
101             You can find documentation for this module with the perldoc command.
102              
103             perldoc Wiki::Toolkit::Formatter::Mediawiki::Link
104              
105             You can also look for information at:
106              
107             =over 4
108              
109             =item * AnnoCPAN: Annotated CPAN documentation
110              
111             L
112              
113             =item * CPAN Ratings
114              
115             L
116              
117             =item * RT: CPAN's request tracker
118              
119             L
120              
121             =item * Search CPAN
122              
123             L
124              
125             =back
126              
127             =head1 ACKNOWLEDGEMENTS
128              
129             My thanks go to Kake Pugh, for providing the well written L and
130             L modules, which got me started on this.
131              
132             =head1 COPYRIGHT & LICENSE
133              
134             Copyright 2008 Ximbiot LLC., all rights reserved.
135              
136             This program is free software; you can redistribute it and/or modify it
137             under the same terms as Perl itself.
138              
139             =cut
140              
141             1; # End of Wiki::Toolkit::Formatter::Mediawiki::Link