Tidyp.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.2% 37 / 41 CC 4 SCAR 8.9
CC
4
Cov
88%
config
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Tidyp/ConfigData.pm ↑ Summary
1 package Alien::Tidyp;
2
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 4 ▶use Alien::Tidyp::ConfigData;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use File::ShareDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use File::Spec::Functions qw(catdir catfile rel2abs);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 =head1 NAME
11
12 Alien::Tidyp - Building, finding and using tidyp library - L<http://www.tidyp.com>
13
14 =cut
15
16 4 our $VERSION = 'v1.4.7';
17
18 =head1 VERSION
19
20 Version 1.4.7 of Alien::Tidyp uses I<tidyp> sources v1.04.
21
22 =head1 SYNOPSIS
23
24 B<IMPORTANT:> This module is not a perl binding for I<tidyp> library; it is just a helper module.
25 The real perl binding is implemented by e.g L<HTML::Tidy|HTML::Tidy> module, which is able to
26 use Alien::Tidyp to locate I<tidyp> library on your system (or build it from source codes).
27
28 Alien::Tidyp tries (in given order) during its installation:
29
30 =over
31
32 =item * Locate an already installed I<tidyp> + ask user whether to use the already installed
33 I<tidyp> or whether to build I<tidyp> from sources
34
35 =item * Via env variable TIDYP_DIR you can specify where the build script should look
36 for the already installed I<tidyp> (directories $TIDYP_DIR/lib and $TIDYP_DIR/include/tidyp
37 are expected to exist)
38
39 =item * When not using the already installed I<tidyp> build process continues with
40 the following steps
41
42 =item * Download I<tidyp> source code tarball
43
44 =item * Build I<tidyp> binaries from source codes (note: static libraries are build in this case)
45
46 =item * Install binaries and dev files (*.h, *.a) into I<share> directory of Alien::Tidyp
47 distribution - I<share> directory is usually something like this: /usr/lib/perl5/site_perl/5.10/auto/share/dist/Alien-Tidyp
48
49 =back
50
51 Later on you can use Alien::Tidyp in your module that needs to link with
52 I<tidyp> like this:
53
54 # Sample Makefile.pl
55 use ExtUtils::MakeMaker;
56 use Alien::Tidyp;
57
58 WriteMakefile(
59 NAME => 'Any::Tidyp::Module',
60 VERSION_FROM => 'lib/Any/Tidyp/Module.pm',
61 LIBS => Alien::Tidyp->config('LIBS'),
62 INC => Alien::Tidyp->config('INC'),
63 # + additional params
64 );
65
66 B<IMPORTANT:> As Alien::Tidyp builds static libraries the modules using Alien::Tidyp (e.g. L<HTML::Tidy|HTML::Tidy>)
67 need to have Alien::Tidyp just for building, not for later use. In other words Alien:Tidyp is just "build dependency"
68 not "run-time dependency".
69
70 =head1 Build.PL options
71
72 =head2 --srctarball=<url_or_filename>
73
74 This option might come handy if you are not connected to the Internet. You can use it like:
75
76 Build.PL --srctarball=/path/to/file/tidyp-1.04.tar.gz
77
78 or:
79
80 Build.PL --srctarball=http://any.server.com/path/to/tidyp-1.04.tar.gz
81
82 IMPORTANT: The file should always be exactly the same source code tarball as specified in the end of Build.PL - see
83 source code (SHA1 checksum of the tarball is checked).
84
85 =head1 METHODS
86
87 =head2 config()
88
89 This function is the main public interface to this module.
90
91 Alien::Tidyp->config('LIBS');
92
93 Returns a string like: '-L/path/to/tidyp/dir/lib -ltidyp'
94
95 Alien::Tidyp->config('INC');
96
97 Returns a string like: '-I/path/to/tidyp/dir/include/tidyp'
98
99 Alien::Tidyp->config('PREFIX');
100
101 Returns a string like: '/path/to/tidyp/dir' (note: if using the already installed
102 tidyp config('PREFIX') returns undef)
103
104 =head1 AUTHOR
105
106 KMX, E<lt>kmx at cpan.orgE<gt>
107
108 =head1 BUGS
109
110 Please report any bugs or feature requests to E<lt>bug-Alien-Tidyp at rt.cpan.orgE<gt>, or through
111 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Alien-Tidyp>.
112
113 =head1 LICENSE AND COPYRIGHT
114
115 Please notice that the source code of tidyp library has a different license than module itself.
116
117 =head2 Alien::Tidyp perl module
118
119 Copyright (c) 2010 KMX.
120
121 This program is free software; you can redistribute it and/or modify it
122 under the terms of either: the GNU General Public License as published
123 by the Free Software Foundation; or the Artistic License.
124
125 See http://dev.perl.org/licenses/ for more information.
126
127 =head2 Source code of tidyp library
128
129 Copyright (c) 1998-2003 World Wide Web Consortium
130 (Massachusetts Institute of Technology, European Research
131 Consortium for Informatics and Mathematics, Keio University).
132 All Rights Reserved.
133
134 This software and documentation is provided "as is," and
135 the copyright holders and contributing author(s) make no
136 representations or warranties, express or implied, including
137 but not limited to, warranties of merchantability or fitness
138 for any particular purpose or that the use of the software or
139 documentation will not infringe any third party patents,
140 copyrights, trademarks or other rights.
141
142 The copyright holders and contributing author(s) will not be held
143 liable for any direct, indirect, special or consequential damages
144 arising out of any use of the software or documentation, even if
145 advised of the possibility of such damage.
146
147 Permission is hereby granted to use, copy, modify, and distribute
148 this source code, or portions hereof, documentation and executables,
149 for any purpose, without fee, subject to the following restrictions:
150
151 1. The origin of this source code must not be misrepresented.
152
153 2. Altered versions must be plainly marked as such and must not be misrepresented as being the original source.
154
155 3. This Copyright notice may not be removed or altered from any source or altered source distribution.
156
157 The copyright holders and contributing author(s) specifically
158 permit, without fee, and encourage the use of this source code
159 as a component for supporting the Hypertext Markup Language in
160 commercial products. If you use this source code in a product,
161 acknowledgment is not required but would be appreciated.
162
163 =cut
164
165 sub config
166 10 ▶{
Subroutine config: called CC=4 SCAR=14.4
Pod documented
167 10 my ($package, $param) = @_;
168 10 ▶ return unless ($param =~ /[a-z0-9_]*/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $param =~ /[a-z0-9_]*/i 0 10 10
169 10 my $subdir = Alien::Tidyp::ConfigData->config('share_subdir');
170 10 ▶ unless ($subdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subdir) 0 10 10
171 #we are using tidyp already installed on your system not compiled by Alien::Tidyp
172 #therefore no additinal magic needed
173 0 return Alien::Tidyp::ConfigData->config('config')->{$param};
174 }
175 10 my $share_dir = dist_dir('Alien-Tidyp');
176 10 my $real_prefix = catdir($share_dir, $subdir);
177 10 my $val = Alien::Tidyp::ConfigData->config('config')->{$param};
178 10 ▶ return unless $val;
Branch: 1 branch
BranchTrueFalseTotal
unless $val 0 10 10
179 10 $val =~ s/\@PrEfIx\@/$real_prefix/g; # handle @PrEfIx@ replacement
180 10 return $val;
181 }
182
183 4 1;
« Tidyp/ConfigData.pm ↑ Summary