| 1 | package CPAN::MetaCurator::Search; | ||
| 2 | |||
| 3 | use boolean; | ||
| 4 | use feature 'say'; | ||
| 5 | use open qw(:std :utf8); | ||
| 6 | use parent 'CPAN::MetaCurator::HTML'; | ||
| 7 | use warnings qw(FATAL utf8); # Fatalize encoding glitches. | ||
| 8 | |||
| 9 | use Data::Dumper::Concise; # For Dumper(). | ||
| 10 | |||
| 11 | use File::Slurper 'read_lines'; | ||
| 12 | use File::Spec; | ||
| 13 | |||
| 14 | use Moo; | ||
| 15 | |||
| 16 | use Types::Standard qw/Str/; | ||
| 17 | |||
| 18 | has names_path => | ||
| 19 | ( | ||
| 20 | default => sub{return 'data/module.names.txt'}, | ||
| 21 | is => 'rw', | ||
| 22 | isa => Str, | ||
| 23 | required => 0, | ||
| 24 | ); | ||
| 25 | |||
| 26 | our $VERSION = '1.29'; | ||
| 27 | |||
| 28 | # -------------------------------------------------- | ||
| 29 | |||
| 30 | sub check | ||
| 31 | { | ||
| 32 | my($self) = @_; | ||
| 33 | |||
| 34 | $self -> init_config; | ||
| 35 | $self -> init_db; | ||
| 36 | |||
| 37 | my($pad) = $self -> build_pad; | ||
| 38 | my($database_path) = File::Spec -> catfile($self -> home_path, $self -> database_path); | ||
| 39 | my($names_path) = File::Spec -> catfile($self -> home_path, $self -> names_path); | ||
| 40 | |||
| 41 | $self -> logger -> info("Searching modules table"); | ||
| 42 | $self -> logger -> info("Reading: $database_path"); | ||
| 43 | $self -> logger -> info("Reading: $names_path"); | ||
| 44 | $self -> logger -> debug(Dumper $$pad{module_names}); | ||
| 45 | |||
| 46 | my(@names) = read_lines($names_path); | ||
| 47 | |||
| 48 | my($found, @found); | ||
| 49 | my(@not_found); | ||
| 50 | |||
| 51 | for my $name (sort @names) | ||
| 52 | { | ||
| 53 | $found = exists $$pad{module_names}{$name}; | ||
| 54 | |||
| 55 | if ($found) | ||
| 56 | { | ||
| 57 | push @found, $name; | ||
| 58 | } | ||
| 59 | else | ||
| 60 | { | ||
| 61 | push @not_found, $name; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | $self -> logger -> info('Found:'); | ||
| 66 | $self -> logger -> info(Dumper @found); | ||
| 67 | $self -> logger -> info('Not found:'); | ||
| 68 | $self -> logger -> info(Dumper @not_found); | ||
| 69 | $self -> logger -> info('check() finished'); | ||
| 70 | |||
| 71 | } # End of check. | ||
| 72 | |||
| 73 | # -------------------------------------------------- | ||
| 74 | |||
| 75 | 1; | ||
| 76 | |||
| 77 | =pod | ||
| 78 | |||
| 79 | =head1 Machine-Readable Change Log | ||
| 80 | |||
| 81 | The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>. | ||
| 82 | |||
| 83 | =head1 Version Numbers | ||
| 84 | |||
| 85 | Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. | ||
| 86 | |||
| 87 | =head1 Support | ||
| 88 | |||
| 89 | Email the author. | ||
| 90 | |||
| 91 | =head1 Method check() | ||
| 92 | |||
| 93 | Note: Module names are case-sensitive. | ||
| 94 | |||
| 95 | The purpose is to read a file of module names and classify them as found (already in the db) | ||
| 96 | and not found (new). This makes updating Perl.Wiki.html much easier since I can ignore the former. | ||
| 97 | |||
| 98 | This module is used via check.module.names.pl. | ||
| 99 | |||
| 100 | =head1 Author | ||
| 101 | |||
| 102 | L<CPAN::MetaCurator> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2025. | ||
| 103 | |||
| 104 | My homepage: L<https://savage.net.au/>. | ||
| 105 | |||
| 106 | =head1 Copyright | ||
| 107 | |||
| 108 | Australian copyright (c) 2026, Ron Savage. | ||
| 109 | |||
| 110 | All Programs of mine are 'OSI Certified Open Source Software'; | ||
| 111 | you can redistribute them and/or modify them under the terms of | ||
| 112 | The Perl License, a copy of which is available at: | ||
| 113 | http://dev.perl.org/licenses/ | ||
| 114 | |||
| 115 | =cut |