package DX::Lib::FS;
use DX::Lib::FS::Observation::PathStatus;
+use DX::Lib::FS::Observation::EnvDir;
use DX::Lib::FS::Action::CreateDirectory;
use DX::Lib::FS::Action::CreateFile;
use DX::Lib::FS::Action::SetPathMode;
[ catfile => qw(DirPath FileName FilePath) ],
[ is_directory => 'DirPath' ],
[ is_file => 'FilePath' ] ],
+
+ [ directory_in => [ qw(DirPath DirName SubdirPath) ],
+ [ catfile => qw(DirPath DirName SubdirPath) ],
+ [ is_directory => 'DirPath' ],
+ [ is_directory => 'SubdirPath' ] ],
+
+ [ env_dir => [ qw(ED) ],
+ [ member_of => 'ED', \'env_dir' ] ],
+
+ [ _env_dir_at => [ qw(ED P) ],
+ [ env_dir => 'ED' ],
+ [ prop => ED => \'path' => 'P' ] ],
+
+ [ env_dir_at => [ qw(ED P) ],
+ [ _env_dir_at => qw(ED P) ],
+ [ 'cut' ] ],
+
+ [ env_dir_at => [ 'ED', 'P' ],
+ [ observe => [ 'P' ], sub {
+ DX::Lib::FS::Observation::EnvDir->new(
+ path => $_[0]
+ )
+ } ],
+ [ _env_dir_at => qw(ED P) ] ],
+
+ [ home_dir_on => [ qw(A D) ],
+ [ path_on => 'A', \'HOME', 'P' ],
+ [ env_dir_at => ED => 'P' ],
+ [ prop => ED => \'value' => 'H' ],
+ [ path_on => 'A', 'H', 'D' ] ],
);
sub load_into {
my ($self, $solver) = @_;
$solver->facts->{path_status} = DX::SetOver->new(over => 'path');
$solver->facts->{file_content} = DX::SetOver->new(over => 'path');
+ $solver->facts->{env_dir} = DX::SetOver->new(over => 'path');
$solver->add_predicate(
catdir => [ qw(DirPath DirName SubDirPath) ],
[ qw(+ + -) ] => sub {
--- /dev/null
+package DX::Lib::FS::Role::RunOn;
+
+use DX::Lib::FS::Guts;
+use Moo::Role;
+
+my $local = DX::Lib::FS::Guts->new;
+my %conn_cache; # HEINOUS
+
+sub _call_guts {
+ my ($self, $type, @args) = @_;
+ my ($on, $path) = $self->path =~ /^(?:([^\/]+):)?(.*)$/;
+ my $guts = $on ? $self->_conn_to($on) : $local;
+ $guts->$type($path, @args);
+}
+
+sub _conn_to {
+ my ($self, $on) = @_;
+ $conn_cache{$on} ||= do {
+ require Object::Remote;
+ DX::Lib::FS::Guts->new::on($on);
+ };
+}
+
+1;