use Moo;
+ with 'DX::Role::Fact';
+
has path => (is => 'ro', required => 1);
has info => (is => 'ro', predicate => 1);
use Moo;
+ with 'DX::Role::Fact';
+
has is_directory => (is => 'ro', default => 0);
has is_file => (is => 'ro', default => 0);
has mode => (is => 'ro', required => 1);
[ path => [ qw(PS P) ],
[ prop => 'PS', \'path', 'P' ] ],
[ info_prop => [ qw(PS N V) ],
- [ exists => [ qw(PSI) ],
- [ prop => 'PS', \'info', 'PSI' ],
- [ prop => 'PSI', 'N', 'V' ] ] ],
+ [ prop => 'PS', \'info', 'PSI' ],
+ [ prop => 'PSI', 'N', 'V' ] ],
[ mode => [ qw(PS M) ],
[ info_prop => 'PS', \'mode', 'M' ] ],
[ exists_path => [ qw(PS) ],
[ not => [ exists_path => 'PS' ] ],
[ act => [ 'PS' ],
sub {
- my ($ps_var) = @_;
- my ($id, $value) = ($ps_var->id, $ps_var->bound_value);
+ my ($value) = @_;
DX::Action::FromCode->new(
expect => sub {
- ($id => My::PathStatus->new(
+ (path_status => My::PathStatus->new(
path => $value->path,
info => My::PathStatusInfo->new(
is_directory => 1, mode => ''
scalar(my ($action) = $res[0]->actions), 1
);
-my ($type, $value) = $action->run;
-
-$solver->facts->{$type}->remove_value($value);
+$solver->run_action($action);
ok(!$path_status{'.ssh'}, 'Empty retracted');
ok(!$res[0]->actions, 'No action');
+$solver->add_predicate(
+ catfile => [ qw(DirPath FileName FilePath) ],
+ [ qw(+ + -) ] => sub {
+ +(FilePath => [ value => File::Spec->catfile($_{DirPath}, $_{FileName}) ])
+ },
+);
+
$solver->add_rule(@$_) for (
- [ catfile => [ qw(DirPath FileName FilePath) ],
- DX::Op::FromCode->new(code => sub {
- my ($self, $state) = @_;
- my ($dir_path, $file_name, $file_path)
- = map $state->scope_var($_), qw(DirPath FileName FilePath);
- die "No." unless $dir_path->is_bound;
- die "No." unless $file_name->is_bound;
- die "No." if $file_path->is_bound;
- my $cat_file = File::Spec->catfile(
- map $_->bound_value, $dir_path, $file_name
- );
- $state->bind_value($file_path->id, $cat_file)
- ->add_dependencies(
- $file_path->id => $dir_path->id,
- $file_path->id => $file_name->id,
- )
- ->then($self->next);
- }) ],
[ file_in => [ qw(DirStatus FileName FileStatus) ],
[ is_directory => qw(DirStatus) ],
- [ exists => [ qw(DirPath) ],
- [ path => qw(DirStatus DirPath) ],
- [ exists => [ qw(FilePath) ],
- [ catfile => qw(DirPath FileName FilePath) ],
- [ file_at => qw(FileStatus FilePath) ] ] ] ],
+ [ path => qw(DirStatus DirPath) ],
+ [ catfile => qw(DirPath FileName FilePath) ],
+ [ file_at => qw(FileStatus FilePath) ] ],
[ is_file => [ qw(PS) ],
[ not => [ exists_path => 'PS' ] ],
[ act => [ 'PS' ],
sub {
- my ($ps_var) = @_;
- my ($id, $value) = ($ps_var->id, $ps_var->bound_value);
+ my ($value) = @_;
DX::Action::FromCode->new(
expect => sub {
- ($id => My::PathStatus->new(
+ (path_status => My::PathStatus->new(
path => $value->path,
info => My::PathStatusInfo->new(
is_file => 1, mode => ''
is(scalar(my @act = $res[0]->actions), 2, 'Two actions');
-is(scalar(my ($poss) = grep !@{$_->dependencies}, @act), 1, 'One possible');
+#::Dwarn(\@act);
-($type, $value) = $poss->run;
+is(scalar(my ($poss) = grep !@{$_->dependencies}, @act), 1, 'One possible');
-$solver->facts->{$type}->remove_value($value);
+$solver->run_action($poss);
@res = keys_file()->results;
'One possible'
);
-($type, $value) = $poss->run;
-
-$solver->facts->{$type}->remove_value($value);
+$solver->run_action($poss);
@res = keys_file()->results;