Code-TidyAll-Plugin-YAMLFrontMatter
view release on metacpan or search on metacpan
"config" : {
"Dist::Zilla::Plugin::Test::PodSpelling" : {
"directories" : [
"bin",
"lib"
],
"spell_cmd" : "",
"stopwords" : [
"Alders",
"Alders'",
"BOM",
"Eilam",
"Eilam's",
"Jekyll",
"MAXMIND",
"MAXMIND's",
"MaxMind",
"MaxMind's",
"Oschwald",
"Oschwald's",
"PayPal",
class: Dist::Zilla::Plugin::Test::PodSpelling
config:
Dist::Zilla::Plugin::Test::PodSpelling:
directories:
- bin
- lib
spell_cmd: ''
stopwords:
- Alders
- "Alders'"
- BOM
- Eilam
- "Eilam's"
- Jekyll
- MAXMIND
- "MAXMIND's"
- MaxMind
- "MaxMind's"
- Oschwald
- "Oschwald's"
- PayPal
# DESCRIPTION
This is a validator plugin for [Code::TidyAll](https://metacpan.org/pod/Code::TidyAll) that can be used to check
that files have valid YAML Front Matter, like Jekyll et al use.
It will complain if:
- There's no YAML Front Matter
- The YAML Front Matter isn't valid YAML
- There's a UTF-8 BOM at the start of the file
- The file isn't encoded in the configured encoding (UTF-8 by default)
- The YAML Front Matter is missing one or more configured top level keys
- The YAML Front Matter contains circular references
## Options
- `required_top_level_keys`
Keys that must be present at the top level of the YAML Front Matter.
name = Code-TidyAll-Plugin-YAMLFrontMatter
author = Mark Fowler <mfowler@maxmind.com>
copyright_holder = MaxMind, Inc.
main_module = lib/Code/TidyAll/Plugin/YAMLFrontMatter.pm
[@MAXMIND]
dist = Code-TidyAll-Plugin-YAMLFrontMAtter
stopwords = al
stopwords = BOM
stopwords = Jekyll
stopwords = tidyall
stopwords = tidyallrc
stopwords = validator
-remove = Test::Synopsis
lib/Code/TidyAll/Plugin/YAMLFrontMatter.pm view on Meta::CPAN
# YAML::PP always expects things to be in UTF-8 bytes
my $encoding = $self->encoding;
try {
$src = decode( $encoding, $src, FB_CROAK );
$src = encode( 'UTF-8', $src, FB_CROAK );
}
catch {
die "File does not match encoding '$encoding': $_";
};
# is there a BOM? There's not meant to be a BOM!
if ( $src =~ /\A\x{EF}\x{BB}\x{BF}/ ) {
die "Starting document with UTF-8 BOM is not allowed\n";
}
# match the YAML front matter.
my $yaml;
unless ( ($yaml) = $src =~ $YAML_REGEX ) {
die "'$filename' does not start with valid YAML Front Matter\n";
}
# parse the YAML front matter.
my $ds = try {
lib/Code/TidyAll/Plugin/YAMLFrontMatter.pm view on Meta::CPAN
that files have valid YAML Front Matter, like Jekyll et al use.
It will complain if:
=over
=item There's no YAML Front Matter
=item The YAML Front Matter isn't valid YAML
=item There's a UTF-8 BOM at the start of the file
=item The file isn't encoded in the configured encoding (UTF-8 by default)
=item The YAML Front Matter is missing one or more configured top level keys
=item The YAML Front Matter contains circular references
=back
=head2 Options
t/lib/Test/Code/TidyAll/Plugin/YAMLFrontMatter.pm view on Meta::CPAN
$self->tidyall(
source => qq{---\n!!!!!\n---\nThis should not work},
expect_error => qr/Problem parsing YAML/,
desc => 'Bad YAML',
);
## encoding handling
$self->tidyall(
source => "\x{EF}\x{BB}\x{BF}---\n---\nSomeone set us up the BOM",
expect_error => qr/Starting document with UTF-8 BOM is not allowed/,
desc => 'BOM',
);
$self->tidyall(
source =>
"\x{fe}\x{ff}\x{00}-\x{00}-\x{00}-\x{00}\n\x{00}-\x{00}-\x{00}-\x{00}\n\x{00}!",
conf => { encoding => 'UTF-16' },
desc => 'UTF-16',
);
$self->tidyall(
xt/author/pod-spell.t view on Meta::CPAN
# generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007005
use Test::Spelling 0.12;
use Pod::Wordlist;
add_stopwords(<DATA>);
all_pod_files_spelling_ok( qw( bin lib ) );
__DATA__
Alders
Alders'
BOM
Code
Dave
Eilam
Eilam's
Fowler
Greg
Inc
Jekyll
MAXMIND
MAXMIND's
( run in 0.560 second using v1.01-cache-2.11-cpan-e9daa2b36ef )