[Bps-public-commit] r14846 - in Shipwright/trunk: lib/Shipwright/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Aug 6 06:18:37 EDT 2008


Author: sunnavy
Date: Wed Aug  6 06:18:35 2008
New Revision: 14846

Added:
   Shipwright/trunk/lib/Shipwright/Source/Shipwright.pm
Modified:
   Shipwright/trunk/   (props changed)

Log:
 r15303 at sunnavys-mb:  sunnavy | 2008-08-06 18:15:11 +0800
 added Shipwright Source


Added: Shipwright/trunk/lib/Shipwright/Source/Shipwright.pm
==============================================================================
--- (empty file)
+++ Shipwright/trunk/lib/Shipwright/Source/Shipwright.pm	Wed Aug  6 06:18:35 2008
@@ -0,0 +1,101 @@
+package Shipwright::Source::Shipwright;
+use strict;
+use warnings;
+
+use Carp;
+use File::Spec;
+
+use base qw/Shipwright::Source::Base/;
+
+=head2 run
+
+=cut
+
+sub run {
+    my $self = shift;
+
+    $self->log->info( "prepare to run source: " . $self->source );
+    my ( $base, $dist ) = $self->source =~ m{(.*)/(.+)};
+
+    my $source_shipwright = Shipwright->new( repository => $base );
+    $self->name( $dist ) unless $self->name;
+
+    $source_shipwright->backend->export(
+        target => File::Spec->catfile( $self->directory, $self->name ),
+        path   => "/dists/$dist",
+    );
+
+    $source_shipwright->backend->export(
+        target => File::Spec->catfile( $self->scripts_directory, $self->name ),
+        path   => "/scripts/$dist",
+    );
+    
+    my $source_version = $source_shipwright->backend->version->{$dist};
+    $self->_update_version( $self->name || $dist, $source_version );
+    $self->_update_url( $self->name || $dist, $self->source );
+
+# follow
+    if ( $self->follow ) {
+        my $out = Shipwright::Util->run(
+            $source_shipwright->backend->_cmd(
+                'cat', path => "/scripts/$dist/require.yml"
+            ),
+            1
+        );
+        my $require = Shipwright::Util::Load( $out ) || {};
+
+        for my $type ( keys %$require ) {
+            for my $req ( keys %{ $require->{$type} } ) {
+                unless ( -e File::Spec->catfile( $self->directory, $req ) ) {
+                    my $s = Shipwright::Source->new(
+                        %$self,
+                        source => "shipwright:$base/$req",
+                        name   => $req
+                    );
+                    $s->run;
+                }
+            }
+        }
+    }
+
+    return File::Spec->catfile( $self->directory, $self->name );
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Shipwright::Source::Shipwright - shipwright source
+
+
+=head1 DESCRIPTION
+
+
+=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.
+
+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