Module-Metadata

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.030.
CONTRIBUTING
Changes
INSTALL
LICENCE
MANIFEST
META.json
META.yml
Makefile.PL
README
corpus/BOMTest/UTF16BE.pm
corpus/BOMTest/UTF16LE.pm
corpus/BOMTest/UTF8.pm
dist.ini
lib/Module/Metadata.pm
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/contains_pod.t
t/encoding.t
t/endpod.t
t/extract-package.t
t/extract-version.t
t/lib/0_1/Foo.pm

corpus/BOMTest/UTF8.pm  view on Meta::CPAN

package Heart;

our $VERSION = 1;

package BOMTest::UTF8;

our $VERSION = 3;

package Cœur;

our $VERSION = 2;

1;

lib/Module/Metadata.pm  view on Meta::CPAN

    ( $sigil, $variable_name, $package) = $2 ? ( $1, $2, $3 ) : ( $4, $5, $6 );
    if ( $package ) {
      $package = ($package eq '::') ? 'main' : $package;
      $package =~ s/::$//;
    }
  }

  return ( $sigil, $variable_name, $package );
}

# Look for a UTF-8/UTF-16BE/UTF-16LE BOM at the beginning of the stream.
# If there's one, then skip it and set the :encoding layer appropriately.
sub _handle_bom {
  my ($self, $fh, $filename) = @_;

  my $pos = tell $fh;
  return unless defined $pos;

  my $buf = ' ' x 2;
  my $count = read $fh, $buf, length $buf;
  return unless defined $count and $count >= 2;

t/encoding.t  view on Meta::CPAN


my %versions = (
 UTF8    => 3,
 UTF16BE => 4,
 UTF16LE => 5,
);

plan tests => 4 * scalar(keys %versions);

for my $enc (sort keys %versions) {
  my $pkg  = "BOMTest::$enc";
  my $vers = $versions{$enc};
  my $pm   = File::Spec->catfile(qw<corpus BOMTest> => "$enc.pm");
  my $info = Module::Metadata->new_from_file($pm);
  is( $info->name, $pkg, "$enc: default package was found" );
  is( $info->version, $vers, "$enc: version for default package" );
  is( $info->version('Heart'), '1', 'version for ASCII package' );
  is( $info->version("C\x{153}ur"), '2', 'version for Unicode package' );
}



( run in 0.952 second using v1.01-cache-2.11-cpan-e9daa2b36ef )