ExtUtils::MakeMaker::JSONMETA - (deprecated) write META.json instead of META.yml


JSON-CPAN-Meta documentation Contained in the JSON-CPAN-Meta distribution.

Index


Code Index:

NAME

Top

ExtUtils::MakeMaker::JSONMETA - (deprecated) write META.json instead of META.yml

SYNOPSIS

Top

Achtung! This library will soon be obsolete as EUMM moves to use the official CPAN::Meta::Spec JSON files.

In your Makefile.PL:

  use ExtUtils::MakeMaker;
  eval { require ExtUtils::MakeMaker::JSONMETA; };

  WriteMakefile(...);

If EU::MM::JSONMETA cannot be loaded (for example, because a user who is installing your module does not have it or JSON installed), things will continue as usual. If it can be loaded, a META.json file will be produced, containing JSON.

SEE ALSO

Top

JSON::CPAN::META

AUTHOR AND COPYRIGHT

Top


JSON-CPAN-Meta documentation Contained in the JSON-CPAN-Meta distribution.
use strict;
use warnings;

package ExtUtils::MakeMaker::JSONMETA;
our $VERSION = '7.001';

use ExtUtils::MM_Any;
use JSON 2;

no warnings qw(once redefine);
my $orig_m_t = ExtUtils::MM_Any->can('metafile_target');
*ExtUtils::MM_Any::metafile_target = sub {
  my $self = shift;
  my $output = $self->$orig_m_t(@_);
  $output =~ s{META\.yml}{META.json}g;
  return $output;
};

*ExtUtils::MM_Any::metafile_file = sub {
  my ($self, %pairs) = @_;

  $pairs{generated_by} = join ' version ', __PACKAGE__, __PACKAGE__->VERSION;

  return JSON->new->ascii(1)->pretty->encode(\%pairs) . "\n";
};

my $orig_d_t = ExtUtils::MM_Any->can('distmeta_target');
*ExtUtils::MM_Any::distmeta_target = sub {
  my $self = shift;
  my $output = $self->$orig_d_t(@_);
  $output =~ s{META\.yml}{META.json}g;
  return $output;
};

1;