Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kentnl/cpan-meta-prereqs-diff

Compare dependencies between releases using CPAN Meta
https://github.com/kentnl/cpan-meta-prereqs-diff

perl

Last synced: about 2 months ago
JSON representation

Compare dependencies between releases using CPAN Meta

Awesome Lists containing this project

README

        

# NAME

CPAN::Meta::Prereqs::Diff - Compare dependencies between releases using CPAN::Meta.

# VERSION

version 0.001005

# SYNOPSIS

use CPAN::Meta::Prereqs::Diff;

my $diff = CPAN::Meta::Prereqs::Diff->new(
new_prereqs => CPAN::Meta->load_file('Dist-Foo-1.01/META.json')->effective_prereqs
old_prereqs => CPAN::Meta->load_file('Dist-Foo-1.00/META.json')->effective_prereqs
);
my @changes = $diff->diff(
phases => [qw( runtime build configure test )],
types => [qw( requires suggests configures conflicts )],
);

## Here, the examples with printf are not needed because ->describe exists
## But they're there any way for example reasons.

for my $dep (@prereqs) {
if ( $dep->is_addition ) {
# runtime.requires: + Foo::Bar 0.4
printf "%s.%s : + %s %s",
$dep->phase, $dep->type, $dep->module, $dep->requirement;
next;
}
if ( $dep->is_removal ) {
# runtime.requires: - Foo::Bar 0.4
printf "%s.%s : - %s %s",
$dep->phase, $dep->type, $dep->module, $dep->requirement;
next;
}
if ( $dep->is_change ) {
if ( $dep->is_upgrade ) {
# runtime.requires: ↑ Foo::Bar 0.4 → 0.5
printf "%s.%s : \x{2191} %s \x{2192} %s",
$dep->phase, $dep->type, $dep->module, $dep->old_requirement, $dep->new_requirement;
next;
}
if ( $dep->is_downgrade ) {
# runtime.requires: ↓ Foo::Bar 0.5 → 0.4
printf "%s.%s : \x{2193} %s %s \x{2192} %s",
$dep->phase, $dep->type, $dep->module, $dep->old_requirement, $dep->new_requirement;
next;
}
# changes that can't be easily determined upgrades or downgrades
# runtime.requires: ~ Foo::Bar >=0.5, <=0.7 → >=0.4, <=0.8
printf "%s.%s : ~ %s %s \x{2192} %s",
$dep->phase, $dep->type, $dep->module, $dep->old_requirement, $dep->new_requirement;
next;
}
}

# DESCRIPTION

This module allows relatively straight forward routines for comparing and itemizing
two sets of `CPAN::Meta` prerequisites, plucking out kinds of changes that are interesting.

# METHODS

## `diff`

my @out = $diff->diff( %options );

Returns a list of `Objects` that `do` [`CPAN::Meta::Prereqs::Diff::Role::Change`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Role::Change), describing the changes between `old_prereqs` and `new_prereqs`

- [`Addition`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Addition)
- [`Change`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Change)
- [`Upgrade`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Upgrade)
- [`Downgrade`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Downgrade)
- [`Removal`](https://metacpan.org/pod/CPAN::Meta::Prereqs::Diff::Removal)

### `diff.%options`

#### `diff.options.phases`

my @out = $diff->diff(
phases => [ ... ]
);

ArrayRef
default = [qw( configure build runtime test )]
valid options = [qw( configure build runtime test develop )]

#### `diff.options.types`

my @out = $diff->diff(
types => [ ... ]
);

ArrayRef
default = [qw( requires recommends suggests conflicts )]
valid options = [qw( requires recommends suggests conflicts )]

# ATTRIBUTES

## `new_prereqs`

required
HashRef | CPAN::Meta::Prereqs | CPAN::Meta

## `old_prereqs`

required
HashRef | CPAN::Meta::Prereqs | CPAN::Meta

# AUTHOR

Kent Fredric

# COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Kent Fredric .

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.