From: Matt S Trout Date: Tue, 9 Aug 2016 19:10:37 +0000 (+0000) Subject: move dependency expansion earlier in the process X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b413e0b9824bc3fe25ea78462c38b87ac2ef5121;p=scpubgit%2FDX.git move dependency expansion earlier in the process --- diff --git a/lib/DX/DependencyMap.pm b/lib/DX/DependencyMap.pm index 22b09a0..1a34208 100644 --- a/lib/DX/DependencyMap.pm +++ b/lib/DX/DependencyMap.pm @@ -18,13 +18,12 @@ sub new_empty { sub with_entry_for { my ($self, $for_id, $deps_for) = @_; - my @expanded = $self->_expand_deps($deps_for); my $new_revdeps = { %{$self->revdeps}, - $for_id => \@expanded, + $for_id => $deps_for, }; my $new_deps = $self->_merge_deps_for( - $self->deps, $for_id, map @{$_}[1..$#$_], @expanded + $self->deps, $for_id, map @{$_}[1..$#$_], @$deps_for ); ref($self)->new( deps => $new_deps, @@ -78,24 +77,6 @@ sub _mangle_deps { return $root->[0]; } -sub _expand_deps { - my ($self, $dep_groups) = @_; - my @exp; - assert_DependencyGroupList $dep_groups; - map { - my ($on, @deps) = @$_; - my @exp; - DEP: foreach my $dep (@deps) { - my ($type, @path) = @$dep; - push @exp, [ - $type, - map { ref() ? @{$_->identity_path or next DEP} : $_ } @path - ]; - } - (@exp ? [ $on, @exp ] : ()); - } @$dep_groups; -} - sub _dependents_of { my ($self, $event) = @_; my ($type, @path) = @$event; diff --git a/lib/DX/Step/ResolveProposition.pm b/lib/DX/Step/ResolveProposition.pm index cb236d8..9efd8b3 100644 --- a/lib/DX/Step/ResolveProposition.pm +++ b/lib/DX/Step/ResolveProposition.pm @@ -12,7 +12,25 @@ with 'DX::Role::Step'; has actions => (is => 'ro', isa => ArrayRef[Action], required => 1); -has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1); +#has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1); + +has depends_on => (is => 'ro', required => 1, coerce => sub { + my ($dep_groups) = @_; + my @exp; + assert_DependencyGroupList $dep_groups; + [ map { + my ($on, @deps) = @$_; + my @exp; + DEP: foreach my $dep (@deps) { + my ($type, @path) = @$dep; + push @exp, [ + $type, + map { ref() ? @{$_->identity_path or next DEP} : $_ } @path + ]; + } + (@exp ? [ $on, @exp ] : ()); + } @$dep_groups ]; +}); has resolves => (is => 'ro', isa => Proposition);