Shorten.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 97.5% 39 / 40 CC 3 SCAR 5.6
CC
3
Cov
97%
import
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« Shorten/generic.pm ↑ Summary Shorten/LinkToolbot.pm »
1 package WWW::Shorten;
2  
3 4 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use base qw(WWW::Shorten::generic);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $DEFAULT_SERVICE = 'TinyURL';
11 4 our @EXPORT = qw(makeashorterlink makealongerlink);
12 4 our $VERSION = '3.093';
13 4 $VERSION = eval $VERSION;
14  
15 4 my $style;
16  
17 sub import {
18 4 ▶ my $class = shift;
Subroutine import: called CC=3 SCAR=11.0
19 4 $style = shift;
20 4 ▶ $style = $DEFAULT_SERVICE unless defined $style;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $style 1 3 4
21 4 my $package = "${class}::${style}";
22 4 eval {
23 4 my $file = $package;
24 4 $file =~ s/::/\//g;
25 4 require "$file.pm";
26 };
27 4 ▶ Carp::croak($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 4 4
28 4 $package->import(@_);
29 }
30  
31 4 1;
32  
33 =head1 NAME
34  
35 WWW::Shorten - Interface to URL shortening sites.
36  
37 =head1 SYNOPSIS
38  
39 #!/usr/bin/env perl
40 use strict;
41 use warnings;
42  
43 use WWW::Shorten 'TinyURL'; # Recommended
44 # use WWW::Shorten 'Linkz'; # or one of the others
45 # use WWW::Shorten 'Shorl';
46  
47 # Individual modules have have their own syntactic variations.
48 # See the documentation for the particular module you intend to use for details
49  
50 my $url = 'https://metacpan.org/pod/WWW::Shorten';
51 my $short_url = makeashorterlink($url);
52 my $long_url = makealongerlink($short_url);
53  
54 # - OR -
55 # If you don't like the long function names:
56  
57 use WWW::Shorten 'TinyURL', ':short';
58 my $short_url = short_link($url);
59 my $long_url = long_link( $short_url );
60  
61 =head1 DESCRIPTION
62  
63 A Perl interface to various services that shorten URLs. These sites maintain
64 databases of long URLs, each of which has a unique identifier.
65  
66 # DEPRECATION NOTICE
67  
68 The following shorten services have been deprecated as the endpoints no longer
69 exist or function:
70  
71 =over
72  
73 =item *
74  
75 L<WWW::Shorten::LinkToolbot>
76  
77 =item *
78  
79 L<WWW::Shorten::Linkz>
80  
81 =item *
82  
83 L<WWW::Shorten::MakeAShorterLink>
84  
85 =item *
86  
87 L<WWW::Shorten::Metamark>
88  
89 =item *
90  
91 L<WWW::Shorten::TinyClick>
92  
93 =item *
94  
95 L<WWW::Shorten::Tinylink>
96  
97 =item *
98  
99 L<WWW::Shorten::Qurl>
100  
101 =item *
102  
103 L<WWW::Shorten::Qwer>
104  
105 =back
106  
107 When version C<3.100> is released, these deprecated services will not be part of
108 the distribution.
109  
110 =head1 COMMAND LINE PROGRAM
111  
112 A very simple program called F<shorten> is supplied in the
113 distribution's F<bin> folder. This program takes a URL and
114 gives you a shortened version of it.
115  
116 =head1 BUGS, REQUESTS, COMMENTS
117  
118 Please submit any L<issues|https://github.com/p5-shorten/www-shorten/issues> you
119 might have. We appreciate all help, suggestions, noted problems, and especially patches.
120  
121 Note that support for extra shortening services should be released as separate modules,
122 like L<WWW::Shorten::Googl> or L<WWW::Shorten::Bitly>.
123  
124 Support for this module is supplied primarily via the using the
125 L<GitHub Issues|https://github.com/p5-shorten/www-shorten/issues> but we also
126 happily respond to issues submitted to the
127 L<CPAN RT|http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Shorten> system via the web
128 or email: C<bug-www-shorten@rt.cpan.org>
129  
130 * https://github.com/p5-shorten/www-shorten/issues
131 * http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Shorten
132 * ( shorter URL: http://xrl.us/rfb )
133 * C<bug-www-shorten@rt.cpan.org>
134  
135 =head1 AUTHOR
136  
137 Iain Truskett C<spoon@cpan.org>
138  
139 =head1 CONTRIBUTORS
140  
141 =over
142  
143 =item *
144  
145 Alex Page -- for the original LWP hacking on which Dave based his code.
146  
147 =item *
148  
149 Ask Bjoern Hansen -- providing L<WWW::Shorten::Metamark>
150  
151 =item *
152  
153 Chase Whitener C<capoeirab@cpan.org>
154  
155 =item *
156  
157 Dave Cross dave@perlhacks.com -- Authored L<WWW::MakeAShorterLink> on which this was based
158  
159 =item *
160  
161 Eric Hammond -- writing L<WWW::Shorten::NotLong>
162  
163 =item *
164  
165 Jon and William (wjr) -- smlnk services
166  
167 =item *
168  
169 Kazuhiro Osawa C<yappo@cpan.org>
170  
171 =item *
172  
173 Kevin Gilbertson (Gilby) -- TinyURL API information
174  
175 =item *
176  
177 Martin Thurn -- bug fixes
178  
179 =item *
180  
181 Matt Felsen (mattf) -- shorter function names
182  
183 =item *
184  
185 Neil Bowers C<neilb@cpan.org>
186  
187 =item *
188  
189 PJ Goodwin -- code for L<WWW::Shorten::OneShortLink>
190  
191 =item *
192  
193 Shashank Tripathi C<shank@shank.com> -- for providing L<WWW::Shorten::SnipURL>
194  
195 =item *
196  
197 Simon Batistoni -- giving the `makealongerlink` idea to Dave.
198  
199 =item *
200  
201 Everyone else we might have missed.
202  
203 =back
204  
205 In 2004 Dave Cross took over the maintenance of this distribution
206 following the death of Iain Truskett.
207  
208 In 2016, Chase Whitener took over the maintenance of this distribution.
209  
210 =head1 LICENSE AND COPYRIGHT
211  
212 Copyright (c) 2002 by Iain Truskett.
213  
214 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
215  
216 =head1 SEE ALSO
217  
218 L<CGI::Shorten>, L<WWW::Shorten::Simple>
219  
220 =cut
« Shorten/generic.pm ↑ Summary Shorten/LinkToolbot.pm »