[Bps-public-commit] r9763 - in bpsbuilder/BPB/lib/BPB: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Nov 29 10:22:30 EST 2007
Author: sunnavy
Date: Thu Nov 29 10:22:25 2007
New Revision: 9763
Added:
bpsbuilder/BPB/lib/BPB/Source/Directory.pm
Modified:
bpsbuilder/BPB/lib/BPB/Source.pm
Log:
added directory support as source
Modified: bpsbuilder/BPB/lib/BPB/Source.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source.pm (original)
+++ bpsbuilder/BPB/lib/BPB/Source.pm Thu Nov 29 10:22:25 2007
@@ -10,7 +10,8 @@
our %DEFAULT = (
directory => '/tmp',
- command => { compressed => 'tar', http => 'wget', ftp => 'wget' }
+ command =>
+ { compressed => 'tar', http => 'wget', ftp => 'wget', directory => 'cp' }
);
=head2 new
Added: bpsbuilder/BPB/lib/BPB/Source/Directory.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Source/Directory.pm Thu Nov 29 10:22:25 2007
@@ -0,0 +1,94 @@
+package BPB::Source::Directory;
+use strict;
+use warnings;
+use Carp;
+use File::Spec;
+use File::Basename;
+
+use base qw/Class::Accessor::Fast BPB::Source/;
+__PACKAGE__->mk_accessors(qw/source directory command/);
+
+=head2 new
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = {@_};
+ $self->{source} =~ s{/$}{}; # trim the last / to let cp work as we like
+ bless $self, $class;
+}
+
+=head2 run
+
+=cut
+
+sub run {
+ my $self = shift;
+ my $cmd = $self->_cmd;
+ $self->_run($cmd);
+ $self->SUPER::run( $self->path );
+}
+
+sub path {
+ my $self = shift;
+ return basename $self->source;
+}
+
+sub _cmd {
+ my $self = shift;
+ return join ' ', $self->command->{directory}, '-r', $self->source,
+ $self->directory;
+}
+
+sub _run {
+ my $self = shift;
+ my $cmd = shift;
+ system($cmd);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+ -
+
+
+=head1 SYNOPSIS
+
+
+=head1 DESCRIPTION
+
+
+=head1 INTERFACE
+
+
+=head1 DEPENDENCIES
+
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007 Best Practical Solutions LLC.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
More information about the Bps-public-commit
mailing list