Algorithm-Dependency
view release on metacpan or search on metacpan
CONTRIBUTING view on Meta::CPAN
This is a good place to send your questions about the usage of this distribution.
If you send me a patch or pull request, your name and email address will be
included in the documentation as a contributor (using the attribution on the
commit or patch), unless you specifically request for it not to be. If you
wish to be listed under a different name or address, you should submit a pull
request to the .mailmap file to contain the correct mapping.
This file was generated via Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.014
from a template file originating in Dist-Zilla-PluginBundle-Author-ETHER-0.154.
0.4 2003-06-21 10:19:21
- Added the missing_dependencies method to the Source class
0.3 2003-05-11 08:13:42
- Made a stupid mistake in ->schedule_all
0.2 2003-05-11 06:54:32
- Added the ->schedule_all method
0.1 2003-04-16 21:01:52
- original version
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
}
},
"name" : "@Author::ETHER/@Git::VersionManager/prereqs for @Git::VersionManager",
"version" : "6.014"
},
{
"class" : "Dist::Zilla::Plugin::Git::Push",
"config" : {
"Dist::Zilla::Plugin::Git::Push" : {
"push_to" : [
"origin"
],
"remotes_must_exist" : 1
},
"Dist::Zilla::Role::Git::Repo" : {
"git_version" : "2.25.0",
"repo_root" : "."
}
},
"name" : "@Author::ETHER/Git::Push",
"version" : "2.046"
Dist::Zilla::Plugin::Prereqs:
phase: x_Dist_Zilla
type: requires
name: '@Author::ETHER/@Git::VersionManager/prereqs for @Git::VersionManager'
version: '6.014'
-
class: Dist::Zilla::Plugin::Git::Push
config:
Dist::Zilla::Plugin::Git::Push:
push_to:
- origin
remotes_must_exist: 1
Dist::Zilla::Role::Git::Repo:
git_version: 2.25.0
repo_root: .
name: '@Author::ETHER/Git::Push'
version: '2.046'
-
class: Dist::Zilla::Plugin::GitHub::Update
config:
Dist::Zilla::Plugin::GitHub::Update:
lib/Algorithm/Dependency.pm view on Meta::CPAN
or $self->{ignore_orphans} ? next : return undef;
# Skip if selected or checked
next if $checked{$id};
# Add its depends to the stack
push @stack, $Item->depends;
$checked{$id} = 1;
# Add anything to the final output that wasn't one of
# the original input.
unless ( scalar grep { $id eq $_ } @_ ) {
push @depends, $id;
}
}
# Remove any items already selected
my $s = $self->{selected};
return [ sort grep { ! $s->{$_} } @depends ];
}
#pod =pod
#pod
#pod =head2 schedule $name1, ..., $nameN
#pod
#pod Given a list of one or more item names, the C<depends> method will
#pod return, as a reference to an array, the ordered list of items you
#pod should act upon in whichever order this particular dependency handler
#pod uses - see L<Algorithm::Dependency::Ordered> for one that implements
#pod the most common ordering (process sequence).
#pod
#pod This would be the original names provided, plus those added to satisfy
#pod dependencies, in the preferred order of action. For the normal algorithm,
#pod where order it not important, this is alphabetical order. This makes it
#pod easier for someone watching a program operate on the items to determine
#pod how far you are through the task and makes any logs easier to read.
#pod
#pod If any of the names you provided in the arguments is already selected, it
#pod will not be included in the list.
#pod
#pod The method returns a reference to an array of item names on success, a
#pod reference to an empty array if no items need to be acted upon, or C<undef>
lib/Algorithm/Dependency.pm view on Meta::CPAN
common ordering (process sequence)
=head2 schedule $name1, ..., $nameN
Given a list of one or more item names, the C<depends> method will
return, as a reference to an array, the ordered list of items you
should act upon in whichever order this particular dependency handler
uses - see L<Algorithm::Dependency::Ordered> for one that implements
the most common ordering (process sequence).
This would be the original names provided, plus those added to satisfy
dependencies, in the preferred order of action. For the normal algorithm,
where order it not important, this is alphabetical order. This makes it
easier for someone watching a program operate on the items to determine
how far you are through the task and makes any logs easier to read.
If any of the names you provided in the arguments is already selected, it
will not be included in the list.
The method returns a reference to an array of item names on success, a
reference to an empty array if no items need to be acted upon, or C<undef>
lib/Algorithm/Dependency/Source/Invert.pm view on Meta::CPAN
our @ISA = 'Algorithm::Dependency::Source::HoA';
#####################################################################
# Constructor
sub new {
my $class = shift;
my $source = _INSTANCE(shift, 'Algorithm::Dependency::Source') or return undef;
# Derive a HoA from the original source
my @items = $source->items;
my %hoa = map { $_->id => [ ] } @items;
foreach my $item ( @items ) {
my $id = $item->id;
my @deps = $item->depends;
foreach my $dep ( @deps ) {
push @{ $hoa{$dep} }, $id;
}
}
t/03_basics.t view on Meta::CPAN
ok( $Source->item('A')->id eq 'A', "Item ->id appears to work ok" );
ok( scalar $Source->item('A')->depends == 0, "Item ->depends for 0 depends returns ok" );
ok( scalar $Source->item('B')->depends == 1, "Item ->depends for 1 depends returns ok" );
ok( scalar $Source->item('D')->depends == 2, "Item ->depends for 2 depends returns ok" );
my @items = $Source->items;
ok( scalar @items == 6, "Source ->items returns a list" );
isa_ok( $items[0], 'Algorithm::Dependency::Item' );
isa_ok( $items[1], 'Algorithm::Dependency::Item' );
isa_ok( $items[3], 'Algorithm::Dependency::Item' );
ok( ($items[0]->id eq 'A' and $items[1]->id eq 'B' and $items[3]->id eq 'D'), "Source ->items returns in original database order" );
ok( $items[0] eq $Source->item('A'), "Hash and list refer to the same object" );
# Try to create a basic unordered dependency
my $Dep = Algorithm::Dependency->new( source => $Source );
ok( $Dep, "Algorithm::Dependency->new returns true" );
ok( ref $Dep, "Algorithm::Dependency->new returns reference" );
isa_ok( $Dep, 'Algorithm::Dependency');
ok( $Dep->source, "Dependency->source returns true" );
ok( $Dep->source eq $Source, "Dependency->source returns the original source" );
ok( $Dep->item('A'), "Dependency->item returns true" );
ok( $Dep->item('A') eq $Source->item('A'), "Dependency->item returns the same as Source->item" );
my @tmp;
ok( scalar( @tmp = $Dep->selected_list ) == 0, "Dependency->selected_list returns empty list" );
ok( ! $Dep->selected('Foo'), "Dependency->selected returns false on bad input" );
ok( ! $Dep->selected('A'), "Dependency->selected returns false when not selected" );
ok( ! defined $Dep->depends('Foo'), "Dependency->depends fails correctly on bad input" );
foreach my $data ( [
['A'], [], ['A'] ], [
['B'], ['C'], ['B','C'] ], [
t/03_basics.t view on Meta::CPAN
# Try a bad creation
ok( ! defined Algorithm::Dependency->new(), "Dependency->new fails correctly" );
# Create with one selected
$Dep = Algorithm::Dependency->new( source => $Source, selected => [ 'F' ] );
ok( $Dep, "Algorithm::Dependency->new returns true" );
ok( ref $Dep, "Algorithm::Dependency->new returns reference" );
isa_ok( $Dep, 'Algorithm::Dependency');
ok( $Dep->source, "Dependency->source returns true" );
ok( $Dep->source eq $Source, "Dependency->source returns the original source" );
ok( $Dep->item('A'), "Dependency->item returns true" );
ok( $Dep->item('A') eq $Source->item('A'), "Dependency->item returns the same as Source->item" );
ok( scalar( @tmp = $Dep->selected_list ) == 1, "Dependency->selected_list returns empty list" );
ok( ! $Dep->selected('Foo'), "Dependency->selected returns false when wrong" );
ok( ! $Dep->selected('A'), "Dependency->selected returns false when expected" );
ok( $Dep->selected('F'), "Dependency->selected return true" );
ok( ! defined $Dep->depends('Foo'), "Dependency->depends fails correctly on bad input" );
foreach my $data ( [
['A'], [], ['A'] ], [
['B'], ['C'], [qw{B C}] ], [
t/05_ordered.t view on Meta::CPAN
# Test the creation of a basic ordered dependency tree
my $BDep = Algorithm::Dependency::Ordered->new( source => $BSource, selected => ['B'] );
ok( $BDep, "Algorithm::Dependency::Ordered->new returns true" );
ok( ref $BDep, "Algorithm::Dependency::Ordered->new returns reference" );
isa_ok( $BDep, 'Algorithm::Dependency::Ordered');
isa_ok( $BDep, 'Algorithm::Dependency');
ok( $BDep->source, "Dependency->source returns true" );
ok( $BDep->source eq $BSource, "Dependency->source returns the original source" );
ok( $BDep->item('A'), "Dependency->item returns true" );
ok( $BDep->item('A') eq $BSource->item('A'), "Dependency->item returns the same as Basic->item" );
my @tmp;
ok( scalar( @tmp = $BDep->selected_list ) == 1, "Dependency->selected_list returns empty list" );
ok( $tmp[0] eq 'B', "Dependency->selected_list returns as expected" );
ok( ! $BDep->selected('Foo'), "Dependency->selected returns false on bad input" );
ok( ! $BDep->selected('A'), "Dependency->selected returns false when not selected" );
ok( $BDep->selected('B'), "Dependency->selected returns true when selected" );
ok( ! defined $BDep->depends('Foo'), "Dependency->depends fails correctly on bad input" );
# Try to create a basic unordered dependency
my $Dep = Algorithm::Dependency->new( source => $Source );
ok( $Dep, "Algorithm::Dependency->new returns true" );
ok( ref $Dep, "Algorithm::Dependency->new returns reference" );
isa_ok( $Dep, 'Algorithm::Dependency');
ok( $Dep->source, "Dependency->source returns true" );
ok( $Dep->source eq $Source, "Dependency->source returns the original source" );
ok( $Dep->item('A'), "Dependency->item returns true" );
ok( $Dep->item('A') eq $Source->item('A'), "Dependency->item returns the same as Source->item" );
my @tmp;
ok( scalar( @tmp = $Dep->selected_list ) == 0, "Dependency->selected_list returns empty list" );
ok( ! $Dep->selected('Foo'), "Dependency->selected returns false on bad input" );
ok( ! $Dep->selected('A'), "Dependency->selected returns false when not selected" );
ok( ! defined $Dep->depends('Foo'), "Dependency->depends fails correctly on bad input" );
foreach my $data ( [
['A'], [], ['A'] ], [
['B'], ['C'], ['B','C'] ], [
ok( $rv, "Dependency->schedule($args) returns something" );
is_deeply( $rv, $data->[2], "Dependency->schedule($args) returns expected values" );
}
# Create with one selected
$Dep = Algorithm::Dependency->new( source => $Source, selected => [ 'F::G' ] );
ok( $Dep, "Algorithm::Dependency->new returns true" );
ok( ref $Dep, "Algorithm::Dependency->new returns reference" );
isa_ok( $Dep, 'Algorithm::Dependency');
ok( $Dep->source, "Dependency->source returns true" );
ok( $Dep->source eq $Source, "Dependency->source returns the original source" );
ok( $Dep->item('A'), "Dependency->item returns true" );
ok( $Dep->item('A') eq $Source->item('A'), "Dependency->item returns the same as Source->item" );
ok( scalar( @tmp = $Dep->selected_list ) == 1, "Dependency->selected_list returns empty list" );
ok( ! $Dep->selected('Foo'), "Dependency->selected returns false when wrong" );
ok( ! $Dep->selected('A'), "Dependency->selected returns false when expected" );
ok( $Dep->selected('F::G'), "Dependency->selected return true" );
ok( ! defined $Dep->depends('Foo'), "Dependency->depends fails correctly on bad input" );
foreach my $data ( [
['A'], [], ['A'] ], [
['B'], ['C'], [qw{B C}] ], [
( run in 0.292 second using v1.01-cache-2.11-cpan-1c8d708658b )