Clear questions and runnable code
get the best and fastest answer
Checking if your CPAN distributions need to bump their prereq versionsby stevieb (Abbot)
|on Jun 26, 2017 at 17:52 UTC||Need Help??|
I've made two 'updates' to this post, but I'm going to let it fly for a bit, then I'm going to come back and edit in my updates into the post itself...
Update: In v0.02, we now skip over prereqs where the version is listed as 0 (zero). This signifies that any version of a prereq is acceptable. To disable this and display all prereqs even if the version is zero, use the ignore_any => 0 parameter. /update
Update2: I've updated the distribution (v0.05) to install a binary, checkdep, so that you don't have to write your own to use the library:
I've got quite a few CPAN distributions that require one another, and it's gotten to the point that it's very easy to forget to bump prereq versions before uploading a new release to the CPAN.
As a stopgap, I wrote Module::CheckDep::Version (may not be indexed yet). What this module does is using MetaCPAN::Client, fetches all distributions by author, pulls out all prerequisite distributions and the version of it that your distribution has listed, checks if there's a newer version of it, and lists out the ones that need a bump in the prereq's version.
The most basic of runs takes a single parameter, a PAUSE ID (CPAN username), and lists the discrepancies of prereq version mismatches for that author's own prereq distributions *only*. Here's an example of that:
Here's the full output of that function call:
Using the all => 1 param, we'll check against *all* prereqs, the author's own ones and those of any other author. If it's listed as a dependency, we'll check it:
Example (snipped) output:
You can look up only a single distribution instead of listing all of them (this works with all => 1 as well):
You can request the data back (a hashref of hashrefs) instead of displaying it to STDOUT:
...and finally, you can send in a code reference to handle the data within the module instead of getting it returned or printed. This sub can do anything you want it to. You get passed a single parameter, a hashref of hashrefs, same as with the return functionality:
I was going to hook this into an automation script using other tools I have written, but I just don't have the time. Just knowing what needs to be updated is fine for me for now.
Next version will have the ability to optionally skip prereqs that the author has set to 0 (ie. any version is acceptable).
As always, have fun!