NAME

App::FuguSeed::ListFile - read a word list file and prove its digest

SYNOPSIS

use App::FuguSeed::ListFile;

my $list = App::FuguSeed::ListFile->read($path);
my @words  = @{ $list->{words} };
my $digest = $list->{digest};

DESCRIPTION

App::FuguSeed::ListFile is the one reader of a word list file. Both verbs of fuguseed-words take such a file, and each one reads it through this module.

The module computes the SHA-256 of the bytes of the file and refuses every digest but the one that App::FuguSeed::List pins. That digest proves the whole file, so the module makes no other check: the source list holds 2048 lines, and each line holds one word and one line feed.

Every method is a class method. The module keeps no state.

read

read($path) reads the word list file $path. The result is a hash reference with the 2048 words under words, in list order, and the SHA-256 of the file as lower-case hex under digest.

RETURN VALUES

read() returns undef for a file that it cannot read, and for a file with another digest than the source list. It reports the reason through the default logger of Fugu::Log.

ERRORS

A file that no directory holds, and a file that the process cannot open, are recoverable errors. A list with another digest is one too: the caller prints no sheet and gives the failure exit code.

SEE ALSO

App::FuguSeed::List, which pins the digest of the source list, and share/fuguseed/english.txt, the copy that ships with the distribution.

AUTHORS

Dick Olsson <hi@senzilla.io>