[Bps-public-commit] r14724 - in Shipwright/trunk: lib/Shipwright/Backend lib/Shipwright/Script
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sat Aug 2 04:53:20 EDT 2008
Author: sunnavy
Date: Sat Aug 2 04:53:20 2008
New Revision: 14724
Modified:
Shipwright/trunk/ (props changed)
Shipwright/trunk/lib/Shipwright/Backend/Base.pm
Shipwright/trunk/lib/Shipwright/Script/Delete.pm
Log:
r15224 at sunnavys-mb: sunnavy | 2008-08-02 16:44:53 +0800
refactor a bit: move "delete dists" func to Backend as trim
Modified: Shipwright/trunk/lib/Shipwright/Backend/Base.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/Base.pm (original)
+++ Shipwright/trunk/lib/Shipwright/Backend/Base.pm Sat Aug 2 04:53:20 2008
@@ -515,8 +515,64 @@
}
}
+=item trim
+
+trim dists
+
+=cut
+
+sub trim {
+ my $self = shift;
+ my %args = @_;
+ my @names_to_trim;
+
+ if ( ref $args{name} ) {
+ @names_to_trim = @{ $args{name} };
+ }
+ else {
+ @names_to_trim = $args{name};
+ }
+
+ my $order = $self->order;
+ my $map = $self->map;
+ my $version = $self->version || {};
+ my $source = $self->source || {};
+ my $flags = $self->flags || {};
+
+ for my $name (@names_to_trim) {
+ $self->delete( path => "/dists/$name" );
+ $self->delete( path => "/scripts/$name" );
+
+ # clean order.yml
+ @$order = grep { $_ ne $name } @$order;
+
+ # clean map.yml
+ for ( keys %$map ) {
+ delete $map->{$_} if $map->{$_} eq $name;
+ }
+
+ # clean version.yml, source.yml and flags.yml
+
+ for my $hashref ( $source, $flags, $version ) {
+ for ( keys %$hashref ) {
+ if ( $_ eq $name ) {
+ delete $hashref->{$_};
+ last;
+ }
+ }
+ }
+
+ }
+ $self->version($version);
+ $self->map($map);
+ $self->source($source);
+ $self->flags($flags);
+ $self->order($order);
+}
+
*_cmd = *_update_file = *_subclass_method;
+
=back
=cut
Modified: Shipwright/trunk/lib/Shipwright/Script/Delete.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Delete.pm (original)
+++ Shipwright/trunk/lib/Shipwright/Script/Delete.pm Sat Aug 2 04:53:20 2008
@@ -17,49 +17,13 @@
die "need name arg\n" unless $name;
my $shipwright = Shipwright->new( repository => $self->repository, );
-
my $map = $shipwright->backend->map || {};
-
if ( $map->{$name} ) {
-
# it's a cpan module
$name = $map->{$name};
}
- my $order = $shipwright->backend->order;
-
- die "no such dist: $name\n" unless grep { $_ eq $name } @$order;
-
- $shipwright->backend->delete( path => "/dists/$name" );
- $shipwright->backend->delete( path => "/scripts/$name" );
-
- # clean order.yml
- @$order = grep { $_ ne $name } @$order;
- $shipwright->backend->order($order);
-
- # clean map.yml
- for ( keys %$map ) {
- delete $map->{$_} if $map->{$_} eq $name;
- }
-
- # clean version.yml, source.yml and flags.yml
- my $version = $shipwright->backend->version || {};
- my $source = $shipwright->backend->source || {};
- my $flags = $shipwright->backend->flags || {};
-
- for my $hashref ( $source, $flags, $version ) {
- for ( keys %$hashref ) {
- if ( $_ eq $name ) {
- delete $hashref->{$_};
- last;
- }
- }
- }
-
- $shipwright->backend->version($version);
- $shipwright->backend->map($map);
- $shipwright->backend->source($source);
- $shipwright->backend->flags($flags);
+ $shipwright->backend->trim( name => $name );
print "deleted $name with success\n";
}
More information about the Bps-public-commit
mailing list