Skip to content

Commit

Permalink
Changed JSON module pre-requisite to JSON::PP to be compatible with C…
Browse files Browse the repository at this point in the history
…PAN Toolchain

#12
  • Loading branch information
giterlizzi committed Apr 19, 2024
1 parent 4629019 commit 605279f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ WriteMakefile(
MIN_PERL_VERSION => 5.010,
PL_FILES => {},
CONFIGURE_REQUIRES => {'ExtUtils::MakeMaker' => '0'},
TEST_REQUIRES => {'Test::More' => '0', 'JSON' => '0'},
PREREQ_PM => {'JSON' => '0'},
TEST_REQUIRES => {'Test::More' => '0', 'JSON::PP' => '0'},
PREREQ_PM => {'JSON::PP' => '0'},
META_MERGE => {
'meta-spec' => {version => 2},
'resources' => {
Expand Down
18 changes: 9 additions & 9 deletions lib/URI/PackageURL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use constant PURL_DEBUG => $ENV{PURL_DEBUG};

use overload '""' => 'to_string', fallback => 1;

our $VERSION = '2.04_03';
our $VERSION = '2.04_04';
our @EXPORT = qw(encode_purl decode_purl);

my $PURL_REGEXP = qr{^pkg:[A-Za-z\\.\\-\\+][A-Za-z0-9\\.\\-\\+]*/.+};
Expand Down Expand Up @@ -367,21 +367,21 @@ URI::PackageURL - Perl extension for Package URL (aka "purl")
type => cpan,
namespace => 'GDT',
name => 'URI-PackageURL',
version => '2.04'
version => '2.10'
);
say $purl; # pkg:cpan/GDT/URI-PackageURL@2.04
say $purl; # pkg:cpan/GDT/URI-PackageURL@2.10
# Parse Package URL string
$purl = URI::PackageURL->from_string('pkg:cpan/GDT/URI-PackageURL@2.04');
$purl = URI::PackageURL->from_string('pkg:cpan/GDT/URI-PackageURL@2.10');
# exported functions
$purl = decode_purl('pkg:cpan/GDT/URI-PackageURL@2.04');
$purl = decode_purl('pkg:cpan/GDT/URI-PackageURL@2.10');
say $purl->type; # cpan
$purl_string = encode_purl(type => cpan, name => 'URI::PackageURL', version => '2.04');
say $purl_string; # pkg:cpan/URI::PackageURL@2.04
$purl_string = encode_purl(type => cpan, name => 'URI::PackageURL', version => '2.10');
say $purl_string; # pkg:cpan/URI::PackageURL@2.10
=head1 DESCRIPTION
Expand Down Expand Up @@ -497,7 +497,7 @@ Helper method for JSON modules (L<JSON>, L<JSON::PP>, L<JSON::XS>, L<Mojo::JSON>
use Mojo::JSON qw(encode_json);
say encode_json($purl); # {"name":"URI-PackageURL","namespace":"GDT","qualifiers":null,"subpath":null,"type":"cpan","version":"2.04"}
say encode_json($purl); # {"name":"URI-PackageURL","namespace":"GDT","qualifiers":null,"subpath":null,"type":"cpan","version":"2.10"}
=item $purl = URI::PackageURL->from_string($purl_string);
Expand Down Expand Up @@ -535,7 +535,7 @@ L<https://github.com/giterlizzi/perl-URI-PackageURL>
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2022-2023 by Giuseppe Di Terlizzi.
This software is copyright (c) 2022-2024 by Giuseppe Di Terlizzi.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Expand Down
8 changes: 4 additions & 4 deletions lib/URI/PackageURL/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Carp;

use URI::PackageURL;

our $VERSION = '2.04_03';
our $VERSION = '2.04_04';

sub cli_error {
my ($error) = @_;
Expand Down Expand Up @@ -134,8 +134,8 @@ VERSION

if ($options{format} eq 'json') {

if (eval { require JSON }) {
print JSON->new->canonical->pretty(1)->convert_blessed(1)->encode($purl);
if (eval { require JSON::PP }) {
print JSON::PP->new->canonical->pretty(1)->convert_blessed(1)->encode($purl);
return 0;
}

Expand Down Expand Up @@ -254,7 +254,7 @@ L<Giuseppe Di Terlizzi|https://metacpan.org/author/gdt>
=head1 COPYRIGHT AND LICENSE
Copyright © 2022-2023 L<Giuseppe Di Terlizzi|https://metacpan.org/author/gdt>
Copyright © 2022-2024 L<Giuseppe Di Terlizzi|https://metacpan.org/author/gdt>
You may use and distribute this module according to the same terms
that Perl is distributed under.
Expand Down
10 changes: 5 additions & 5 deletions lib/URI/PackageURL/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use warnings;
use Carp;
use Exporter qw(import);

our $VERSION = '2.04_03';
our $VERSION = '2.04_04';
our @EXPORT = qw(purl_to_urls);

sub purl_to_urls {
Expand Down Expand Up @@ -446,13 +446,13 @@ C<cpan>, C<docker>, C<gem>, C<github>, C<gitlab>, C<luarocks>, C<maven>, C<npm>,
(*) Only with B<version> component
(**) Only if B<download_url> qualifier is provided
$urls = purl_to_urls('pkg:cpan/GDT/URI-PackageURL@2.04');
$urls = purl_to_urls('pkg:cpan/GDT/URI-PackageURL@2.10');
print Dumper($urls);
# $VAR1 = {
# 'repository' => 'https://metacpan.org/release/GDT/URI-PackageURL-2.04',
# 'download' => 'http://www.cpan.org/authors/id/G/GD/GDT/URI-PackageURL-2.04.tar.gz'
# 'repository' => 'https://metacpan.org/release/GDT/URI-PackageURL-2.10',
# 'download' => 'http://www.cpan.org/authors/id/G/GD/GDT/URI-PackageURL-2.10.tar.gz'
# };
=back
Expand Down Expand Up @@ -486,7 +486,7 @@ L<https://github.com/giterlizzi/perl-URI-PackageURL>
=head1 LICENSE AND COPYRIGHT
This software is copyright (c) 2022-2023 by Giuseppe Di Terlizzi.
This software is copyright (c) 2022-2024 by Giuseppe Di Terlizzi.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Expand Down

0 comments on commit 605279f

Please sign in to comment.