Created
May 3, 2014 03:01
-
-
Save thaljef/52840fd60dfabc94f151 to your computer and use it in GitHub Desktop.
Dump a cpanfile into targets for Pinto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# USAGE: cpanfile-dumper path/to/cpanfile | pinto -r path/to/repo pull | |
use strict; | |
use warnings; | |
use Module::CPANfile; | |
my $file = shift or die 'Must specify a cpanfile'; | |
my $cpanfile = Module::CPANfile->load($file); | |
my @types = qw(requires recommends suggests); | |
my @phases = qw(configure build test runtime develop); | |
my $prereqs = $cpanfile->prereqs->merged_requirements( \@phases, \@types )->as_string_hash; | |
for my $module (sort keys %{ $prereqs }) { | |
my $version_spec = $prereqs->{$module}; | |
$version_spec =~ s/\s//g; # Remove whitespace | |
$version_spec = "~$version_spec" unless $version_spec =~ m/[^v.\d_]/; | |
print $module . $version_spec . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment