| 1 | package HTML::Spelling::Site::Finder; | ||||||||||||||||||||
| 2 | 2 | $HTML::Spelling::Site::Finder::VERSION = '0.10.1'; | |||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use 5.014; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use MooX (qw( late )); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | ▶ | use File::Find::Object (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | ▶ | has 'prune_cb' => ( is => 'ro', isa => 'CodeRef', default => sub { return; } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 13 | 2 | has 'root_dir' => ( is => 'ro', isa => 'Str', 'required' => 1, ); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | sub list_all_htmls | ||||||||||||||||||||
| 16 | { | ||||||||||||||||||||
| 17 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
list_all_htmls: not called CC=6 SCAR=31.3
Pod
documented
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | my $f = File::Find::Object->new( {}, $self->root_dir ); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | my @got; | |||||||||||||||||||
| 22 | 0 | ▶ | while ( my $r = $f->next_obj() ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | { | ||||||||||||||||||||
| 24 | 0 | my $path = $r->path; | |||||||||||||||||||
| 25 | 0 | ▶ | if ( $self->prune_cb->($path) ) | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 26 | { | ||||||||||||||||||||
| 27 | 0 | $f->prune; | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | ▶ | elsif ( $r->is_file and $r->basename =~ /\.x?html\z/ ) | |||||||||||||||||||
|
Condition0%0/3
$r->is_file and $r->basename =~ /\.x?html\z/u
MC/DC0%0/2
$r->is_file and $r->basename =~ /\.x?html\z/u
$r->is_file
$r->basename =~ /\.x?html\z/u
Truth table0%0/3
A and B
A= $r->is_fileB= $r->basename =~ /\.x?html\z/u
| |||||||||||||||||||||
| 30 | { | ||||||||||||||||||||
| 31 | 0 | push @got, $path; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | 2 | ▶ | use locale; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | 2 | ▶ | use POSIX qw(locale_h strtod); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | 0 | ▶ | setlocale( LC_COLLATE, 'C' ) or die "cannot set locale."; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | return [ sort @got ]; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 2 | 1; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =pod | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =encoding UTF-8 | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 NAME | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | HTML::Spelling::Site::Finder - find the relevant .html/.xhtml files in | ||||||||||||||||||||
| 52 | a directory tree. | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 VERSION | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | version 0.10.1 | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =head1 SYNOPSIS | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | use HTML::Spelling::Site::Finder; | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | my $finder = HTML::Spelling::Site::Finder->new( | ||||||||||||||||||||
| 63 | { | ||||||||||||||||||||
| 64 | prune_cb => sub { | ||||||||||||||||||||
| 65 | return (shift =~ m#\Adest/blacklist/#); | ||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||
| 67 | root_dir => 'dest/', | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | foreach my $html_file (@{$finder->list_all_htmls()}) | ||||||||||||||||||||
| 72 | { | ||||||||||||||||||||
| 73 | print "Should check <$html_file>.\n"; | ||||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head1 DESCRIPTION | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | The instances of this class can be used to scan a directory tree of files | ||||||||||||||||||||
| 79 | ending with C<.html> and C<.xhtml> and to return a list of them as a sorted | ||||||||||||||||||||
| 80 | array reference. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head1 METHODS | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head2 ->new({ prune_cb => sub { ... }, root_dir => $root_dir }) | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | Initialises a new object. C<prune_cb> is optional and C<root_dir> is required | ||||||||||||||||||||
| 87 | and is the path to the root of the directory to scan. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =head2 my $array_ref = $finder->list_all_htmls() | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | Returns an array reference of all HTML files, sorted. | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =head2 $finder->prune_cb() | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | Returns the prune callback. Mostly for internal use. | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =head2 $finder->root_dir() | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | Returns the root directory. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | =head1 SUPPORT | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head2 Websites | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | The following websites have more information about this module, and may be of help to you. As always, | ||||||||||||||||||||
| 108 | in addition to those websites please use your favorite search engine to discover more resources. | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =over 4 | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =item * | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | MetaCPAN | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | A modern, open-source CPAN search engine, useful to view POD in HTML format. | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | L<https://metacpan.org/release/HTML-Spelling-Site> | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =item * | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | RT: CPAN's Bug Tracker | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=HTML-Spelling-Site> | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =item * | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | CPANTS | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | L<http://cpants.cpanauthors.org/dist/HTML-Spelling-Site> | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | =item * | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | CPAN Testers | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | L<http://www.cpantesters.org/distro/H/HTML-Spelling-Site> | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item * | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | CPAN Testers Matrix | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | L<http://matrix.cpantesters.org/?dist=HTML-Spelling-Site> | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =item * | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | CPAN Testers Dependencies | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | L<http://deps.cpantesters.org/?module=HTML::Spelling::Site> | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | =back | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | =head2 Bugs / Feature Requests | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | Please report any bugs or feature requests by email to C<bug-html-spelling-site at rt.cpan.org>, or through | ||||||||||||||||||||
| 165 | the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=HTML-Spelling-Site>. You will be automatically notified of any | ||||||||||||||||||||
| 166 | progress on the request by the system. | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | =head2 Source Code | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | The code is open to the world, and available for you to hack on. Please feel free to browse it and play | ||||||||||||||||||||
| 171 | with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull | ||||||||||||||||||||
| 172 | from your repository :) | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | L<https://github.com/shlomif/HTML-Spelling-Site> | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | git clone https://github.com/shlomif/HTML-Spelling-Site.git | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | =head1 AUTHOR | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | Shlomi Fish <shlomif@cpan.org> | ||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | =head1 BUGS | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | Please report any bugs or feature requests on the bugtracker website | ||||||||||||||||||||
| 185 | L<https://github.com/shlomif/html-spelling-site/issues> | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | When submitting a bug or request, please include a test-file or a | ||||||||||||||||||||
| 188 | patch to an existing test-file that illustrates the bug or desired | ||||||||||||||||||||
| 189 | feature. | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | This software is Copyright (c) 2016 by Shlomi Fish. | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | This is free software, licensed under: | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 197 | The MIT (X11) License | ||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | =cut | ||||||||||||||||||||