Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions author/cpm/cpanfile.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,10 @@ DISTRIBUTIONS
strict 0
version 0.87
warnings 0
Module-cpmfile-0.002
pathname: S/SK/SKAJI/Module-cpmfile-0.002.tar.gz
Module-cpmfile-0.003
pathname: S/SK/SKAJI/Module-cpmfile-0.003.tar.gz
provides:
Module::cpmfile 0.002
Module::cpmfile 0.003
Module::cpmfile::Prereqs undef
Module::cpmfile::Util undef
requirements:
Expand Down
4 changes: 2 additions & 2 deletions bin/cpm
Original file line number Diff line number Diff line change
Expand Up @@ -2115,11 +2115,11 @@ $fatpacked{"Module/Metadata.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<
MODULE_METADATA

$fatpacked{"Module/cpmfile.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'MODULE_CPMFILE';
package Module::cpmfile;use 5.008001;use strict;use warnings;our$VERSION='0.002';use Module::cpmfile::Prereqs;use Module::cpmfile::Util 'merge_version';use YAML::PP ();sub load {my ($class,$file)=@_;my ($hash)=YAML::PP->new->load_file($file);$class->new($hash)}sub new {my ($class,$hash)=@_;my$prereqs=Module::cpmfile::Prereqs->new($hash->{prereqs});my%feature;for my$id (sort keys %{$hash->{features}|| +{}}){my$description=$hash->{features}{$id}{description};my$prereqs=Module::cpmfile::Prereqs->new($hash->{features}{$id}{prereqs});$feature{$id}={description=>$description,prereqs=>$prereqs }}bless {prereqs=>$prereqs,features=>\%feature,_mirrors=>[],},$class}sub from_cpanfile {my ($class,$cpanfile)=@_;my%feature;for my$feature ($cpanfile->features){my$id=$feature->{identifier};my$description=$feature->{description};my$prereqs=Module::cpmfile::Prereqs->from_cpanmeta($feature->{prereqs});$feature{$id}={description=>$description,prereqs=>$prereqs }}my$prereqs=Module::cpmfile::Prereqs->from_cpanmeta($cpanfile->prereqs);for my$p ($prereqs,map {$_->{prereqs}}values%feature){$p->walk(undef,undef,sub {my (undef,undef,$package,$original_options)=@_;my$additional_options=$cpanfile->options_for_module($package)|| +{};if (%$additional_options){%$original_options=(%$original_options,%$additional_options)}})}my$mirrors=$cpanfile->mirrors;bless {prereqs=>$prereqs,features=>\%feature,_mirrors=>$mirrors },$class}sub prereqs {my$self=shift;$self->{prereqs}}sub features {my$self=shift;$self->{features}}sub _feature_prereqs {my ($self,$ids)=@_;my@prereqs;for my$id (@{$ids || []}){my$feature=$self->{features}{$id};next if!$feature ||!$feature->{prereqs};push@prereqs,$feature->{prereqs}}@prereqs}sub effective_requirements {my ($self,$feature_ids,$phases,$types)=@_;my%requirement;for my$prereqs ($self->{prereqs},$self->_feature_prereqs($feature_ids)){$prereqs->walk($phases,$types,sub {my (undef,undef,$package,$options)=@_;if (exists$requirement{$package}){my$v1=$requirement{$package}{version}|| 0;my$v2=$options->{version}|| 0;my$version=merge_version$v1,$v2;$requirement{$package}=+{%{$requirement{$package}},%$options,$version ? (version=>$version): (),}}else {$requirement{$package}=$options}})}\%requirement}1;
package Module::cpmfile;use 5.008001;use strict;use warnings;our$VERSION='0.003';use Module::cpmfile::Prereqs;use Module::cpmfile::Util 'merge_version';use YAML::PP ();sub load {my ($class,$file)=@_;my ($hash)=YAML::PP->new->load_file($file);$class->new($hash)}sub new {my ($class,$hash)=@_;my$prereqs=Module::cpmfile::Prereqs->new($hash->{prereqs});my%feature;for my$id (sort keys %{$hash->{features}|| +{}}){my$description=$hash->{features}{$id}{description};my$prereqs=Module::cpmfile::Prereqs->new($hash->{features}{$id}{prereqs});$feature{$id}={description=>$description,prereqs=>$prereqs }}bless {prereqs=>$prereqs,features=>\%feature,_mirrors=>[],},$class}sub from_cpanfile {my ($class,$cpanfile)=@_;my%feature;for my$feature ($cpanfile->features){my$id=$feature->{identifier};my$description=$feature->{description};my$prereqs=Module::cpmfile::Prereqs->from_cpanmeta($feature->{prereqs});$feature{$id}={description=>$description,prereqs=>$prereqs }}my$prereqs=Module::cpmfile::Prereqs->from_cpanmeta($cpanfile->prereqs);for my$p ($prereqs,map {$_->{prereqs}}values%feature){$p->walk(undef,undef,sub {my (undef,undef,$package,$original_options)=@_;my$additional_options=$cpanfile->options_for_module($package)|| +{};if (%$additional_options){%$original_options=(%$original_options,%$additional_options)}})}my$mirrors=$cpanfile->mirrors;bless {prereqs=>$prereqs,features=>\%feature,_mirrors=>$mirrors },$class}sub prereqs {my$self=shift;$self->{prereqs}}sub features {my$self=shift;if (%{$self->{features}}){return$self->{features}}return}sub _feature_prereqs {my ($self,$ids)=@_;my@prereqs;for my$id (@{$ids || []}){my$feature=$self->{features}{$id};next if!$feature ||!$feature->{prereqs};push@prereqs,$feature->{prereqs}}@prereqs}sub effective_requirements {my ($self,$feature_ids,$phases,$types)=@_;my%req;for my$prereqs ($self->{prereqs},$self->_feature_prereqs($feature_ids)){$prereqs->walk($phases,$types,sub {my (undef,undef,$package,$options)=@_;if (exists$req{$package}){my$v1=$req{$package}{version}|| 0;my$v2=$options->{version}|| 0;my$version=merge_version$v1,$v2;$req{$package}=+{%{$req{$package}},%$options,$version ? (version=>$version): (),}}else {$req{$package}=$options}})}\%req}1;
MODULE_CPMFILE

$fatpacked{"Module/cpmfile/Prereqs.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'MODULE_CPMFILE_PREREQS';
package Module::cpmfile::Prereqs;use strict;use warnings;use CPAN::Meta::Prereqs;my@PHASE=qw(runtime configure build test develop);my@TYPE=qw(requires recommends suggests);sub new {my$class=shift;my$hash=shift || +{};my$self=+{};for my$phase (@PHASE){for my$type (@TYPE){next if!$hash->{$phase}||!$hash->{$phase}{$type};for my$package (sort keys %{$hash->{$phase}{$type}}){$self->{$phase}{$type}{$package}=$hash->{$phase}{$type}{$package}|| +{}}}}bless$self,$class}sub from_cpanmeta {my ($class,$cpanmeta)=@_;my$hash=$cpanmeta->as_string_hash;my$out={};for my$phase (sort keys %$hash){for my$type (sort keys %{$hash->{$phase}}){for my$package (sort keys %{$hash->{$phase}{$type}}){my$version=$hash->{$phase}{$type}{$package};my$options=+{$version ? (version=>$version): ()};$out->{$phase}{$type}{$package}=$options}}}$class->new($out)}sub cpanmeta {my$self=shift;my$hash=+{};for my$phase (sort keys %$self){for my$type (sort keys %{$self->{$phase}}){for my$package (sort keys %{$self->{$phase}{$type}}){my$options=$self->{$phase}{$type}{$package};$hash->{$phase}{$type}{$package}=$options->{version}|| 0}}}CPAN::Meta::Prereqs->new($hash)}sub walk {my ($self,$phases,$types,$cb)=@_;$phases ||= \@PHASE;$types ||= \@TYPE;for my$phase (@$phases){for my$type (@$types){next if!$self->{$phase}||!$self->{$phase}{$type};for my$package (sort keys %{$self->{$phase}{$type}}){my$options=$self->{$phase}{$type}{$package};my$ret=$cb->($phase,$type,$package,$options);return if ref($ret)eq 'SCALAR' &&!$$ret}}}}sub options_for {my ($self,$package,$phases,$types)=@_;my$options;$self->walk($phases,$types,sub {my ($_phase,$_type,$_package,$_options)=@_;if ($package eq $_package){$options=$_options;return \0}});return$options}1;
package Module::cpmfile::Prereqs;use strict;use warnings;use CPAN::Meta::Prereqs;my@PHASE=qw(runtime configure build test develop);my@TYPE=qw(requires recommends suggests);sub new {my$class=shift;my$hash=shift || +{};my$self=+{};for my$phase (@PHASE){for my$type (@TYPE){next if!$hash->{$phase}||!$hash->{$phase}{$type};for my$package (sort keys %{$hash->{$phase}{$type}}){$self->{$phase}{$type}{$package}=$hash->{$phase}{$type}{$package}|| +{}}}}bless$self,$class}sub from_cpanmeta {my ($class,$cpanmeta)=@_;my$hash=$cpanmeta->as_string_hash;my$out={};for my$phase (sort keys %$hash){for my$type (sort keys %{$hash->{$phase}}){for my$package (sort keys %{$hash->{$phase}{$type}}){my$version=$hash->{$phase}{$type}{$package};my$options=+{$version ? (version=>$version): ()};$out->{$phase}{$type}{$package}=$options}}}$class->new($out)}sub cpanmeta {my$self=shift;my$hash=+{};for my$phase (sort keys %$self){for my$type (sort keys %{$self->{$phase}}){for my$package (sort keys %{$self->{$phase}{$type}}){my$options=$self->{$phase}{$type}{$package};$hash->{$phase}{$type}{$package}=$options->{version}|| 0}}}CPAN::Meta::Prereqs->new($hash)}sub walk {my ($self,$phases,$types,$cb)=@_;$phases ||= \@PHASE;$types ||= \@TYPE;for my$phase (@$phases){for my$type (@$types){next if!$self->{$phase}||!$self->{$phase}{$type};for my$package (sort keys %{$self->{$phase}{$type}}){my$options=$self->{$phase}{$type}{$package};my$ret=$cb->($phase,$type,$package,$options);return if ref($ret)eq 'SCALAR' &&!$$ret}}}}1;
MODULE_CPMFILE_PREREQS

$fatpacked{"Module/cpmfile/Util.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'MODULE_CPMFILE_UTIL';
Expand Down