[Bps-public-commit] r9705 - in bpsbuilder/BPB: . bin lib lib/BPB lib/BPB/Backend lib/BPB/Script t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Nov 20 15:37:04 EST 2007


Author: sunnavy
Date: Tue Nov 20 15:36:56 2007
New Revision: 9705

Added:
   bpsbuilder/BPB/
   bpsbuilder/BPB/Changes
   bpsbuilder/BPB/MANIFEST
   bpsbuilder/BPB/Makefile.PL
   bpsbuilder/BPB/README
   bpsbuilder/BPB/bin/
   bpsbuilder/BPB/bin/bpb   (contents, props changed)
   bpsbuilder/BPB/examples/
   bpsbuilder/BPB/examples/config.yml
   bpsbuilder/BPB/lib/
   bpsbuilder/BPB/lib/BPB/
   bpsbuilder/BPB/lib/BPB.pm
   bpsbuilder/BPB/lib/BPB/Backend/
   bpsbuilder/BPB/lib/BPB/Backend.pm
   bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
   bpsbuilder/BPB/lib/BPB/Config.pm
   bpsbuilder/BPB/lib/BPB/Script/
   bpsbuilder/BPB/lib/BPB/Script.pm
   bpsbuilder/BPB/lib/BPB/Script/Export.pm
   bpsbuilder/BPB/lib/BPB/Script/Import.pm
   bpsbuilder/BPB/t/
   bpsbuilder/BPB/t/00.load.t
   bpsbuilder/BPB/t/01-BPB-Config.t
   bpsbuilder/BPB/t/config.yml
   bpsbuilder/BPB/t/perlcritic.t
   bpsbuilder/BPB/t/pod-coverage.t
   bpsbuilder/BPB/t/pod.t

Log:
initial BPB

Added: bpsbuilder/BPB/Changes
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/Changes	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,5 @@
+Revision history for BPB
+
+0.0.1  Tue Nov 20 16:28:55 2007
+       Initial release.
+

Added: bpsbuilder/BPB/MANIFEST
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/MANIFEST	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,17 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/BPB.pm
+lib/BPB/Backend.pm
+lib/BPB/Backend/SVK.pm
+lib/BPB/Config.pm
+lib/BPB/Export.pm
+lib/BPB/Import.pm
+lib/BPB/Import/CPAN.pm
+lib/BPB/Import/SVK.pm
+t/00.load.t
+t/perlcritic.t
+t/pod-coverage.t
+t/pod.t

Added: bpsbuilder/BPB/Makefile.PL
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/Makefile.PL	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use inc::Module::Install 0.46;
+name 'BPB';
+auto_install;
+WriteAll;

Added: bpsbuilder/BPB/README
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/README	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,25 @@
+BPB version 0.0.1
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+
+
+DEPENDENCIES
+
+None.
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2007, sunnavy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.

Added: bpsbuilder/BPB/bin/bpb
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/bin/bpb	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use BPB;
+use BPB::Script;
+
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+BPB::Script->dispatch();

Added: bpsbuilder/BPB/examples/config.yml
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/examples/config.yml	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,4 @@
+project: test
+backend:
+    module: SVK
+    command: '/usr/bin/svk'

Added: bpsbuilder/BPB/lib/BPB.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,90 @@
+package BPB;
+
+use warnings;
+use strict;
+use Carp;
+
+use version; our $VERSION = qv('0.0.1');
+
+use base qw/Class::Accessor::Fast/;
+
+__PACKAGE__->mk_accessors(qw/config backend/);
+
+use BPB::Config;
+use BPB::Backend;
+
+=head2 new
+
+=cut
+
+sub new {
+    my $class = shift;
+
+    my %args = @_;
+    croak "need config option" unless $args{config};
+
+    my $self = {};
+    bless $self, $class;
+
+    $self->config( BPB::Config->new( $args{config} ) );
+    $self->backend(
+        BPB::Backend->new(
+            %{ $self->config->stash->{backend} },
+        )
+    );
+
+    return $self;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB - 
+
+
+=head1 VERSION
+
+This document describes BPB version 0.0.1
+
+
+=head1 SYNOPSIS
+
+    use BPB;
+
+=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 (c) 2007, sunnavy C<< <sunnavy at bestpractical.com> >>. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+

Added: bpsbuilder/BPB/lib/BPB/Backend.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Backend.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,82 @@
+package BPB::Backend;
+
+use warnings;
+use strict;
+use Carp;
+use UNIVERSAL::require;
+
+=head2 new
+
+accept the backend part(hash instead of hashref) and project part
+in the config.yml as args. returns the individual Backend objects.
+
+=cut
+
+sub new {
+    my $class = shift;
+    my %args  = @_;
+
+    my $module = delete $args{module};
+
+    croak "need a backend module, please check your config" unless $module;
+    croak "need project option" unless $args{project};
+
+    $module = 'BPB::Backend::' . $module if $module !~ /::/;
+
+    $module->require or die $@;
+
+    return $module->new(%args);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Backend - 
+
+
+=head1 VERSION
+
+This document describes BPB::Backend version 0.0.1
+
+
+=head1 SYNOPSIS
+
+    use BPB::Backend;
+
+=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 (c) 2007, sunnavy C<< <sunnavy at bestpractical.com> >>. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+

Added: bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Backend/SVK.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,137 @@
+package BPB::Backend::SVK;
+
+use warnings;
+use strict;
+use Carp;
+
+# command option is svk's path info, e.g. '/usr/bin/svk'
+# path is under repository/project/, e.g.
+# our project's own files will be in //local/test/main
+# all the dependance packages will be in //local/test/deps
+# the bpb's stuff will be in //local/test/bpb
+
+our %DEFAULT = (
+    command    => 'svk',
+    repository => '//local',
+    project    => 'test',
+    path       => {
+        dependance => 'deps',
+        bpb        => 'bpb',
+        project    => 'main',
+    }
+);
+
+use base qw/Class::Accessor::Fast/;
+__PACKAGE__->mk_accessors(qw/command repository project path/);
+
+=head2 new
+
+=cut
+
+sub new {
+    my $class = shift;
+    my %args  = @_;
+
+    bless { %DEFAULT, %args }, $class;
+}
+
+=head2 import
+
+=cut
+
+sub import {
+    my $self = shift;
+    my %args = @_;
+
+    # category is 'project', 'dependance' or 'bpb'
+
+    for (qw/source category/) {
+        croak "need $_ option" unless $args{$_};
+    }
+
+    $args{comment} ||= 'import';
+
+    my $cmd = join ' ', $self->command, 'import', '-m', $args{comment},
+      $args{source}, join '/', $self->repository, $self->project,
+      $self->path->{ $args{category} };
+
+    system($cmd );
+}
+
+=head2 export
+
+=cut
+
+sub export {
+    my $self = shift;
+    my %args = @_;
+
+    for (qw/target/) {
+        croak "need $_ option" unless $args{$_};
+    }
+
+    $args{category} ||= '';   # category with '' will export the whole project
+    $args{path}     ||= '';   # path with '' will export the whole category part
+
+    my $cmd = join ' ', $self->command, 'checkout', '--export',
+      join( '/',
+        $self->repository, $self->project,
+        $args{category} && $self->path->{ $args{category} },
+        $args{path} ),
+      $args{target};
+
+    system($cmd );
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Backend::SVK - 
+
+
+=head1 VERSION
+
+This document describes BPB::Backend::SVK version 0.0.1
+
+
+=head1 SYNOPSIS
+
+    use BPB::Backend::SVK;
+
+=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 (c) 2007, sunnavy C<< <sunnavy at bestpractical.com> >>. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+

Added: bpsbuilder/BPB/lib/BPB/Config.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Config.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,106 @@
+package BPB::Config;
+
+use warnings;
+use strict;
+use Carp;
+
+use base qw/Class::Accessor::Fast/;
+__PACKAGE__->mk_accessors(qw/stash/);
+
+BEGIN {
+    local $@;
+    eval { require YAML::Syck; };
+    if ($@) {
+        require YAML;
+        *LoadFile = *YAML::LoadFile;
+    }
+    else {
+        *LoadFile = *YAML::Syck::LoadFile;
+    }
+}
+
+=head2 new
+
+=cut
+
+sub new {
+    my $class = shift;
+    my $file = shift;
+
+    my $self = {};
+    bless $self, $class;
+
+    if ( $file ) {
+        $self->load( $file );
+    }
+    else {
+        $self->stash( {} );
+    }
+
+    return $self;
+}
+
+=head2 load
+
+=cut
+
+sub load {
+    my $self = shift;
+    $self->stash( LoadFile(shift) );
+    $self->_tidy;
+}
+
+sub _tidy {
+    my $self = shift;
+
+    # we want the backend part also has project
+    $self->stash->{backend}{project} ||= $self->stash->{project};
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Config - 
+
+
+=head1 SYNOPSIS
+
+    use BPB::Config;
+
+=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 (c) 2007, sunnavy C<< <sunnavy at bestpractical.com> >>. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+

Added: bpsbuilder/BPB/lib/BPB/Script.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Script.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,7 @@
+package BPB::Script;
+use strict;
+use warnings;
+use App::CLI;
+use base qw/App::CLI/;
+
+1;

Added: bpsbuilder/BPB/lib/BPB/Script/Export.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Script/Export.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,33 @@
+package BPB::Script::Export;
+
+use warnings;
+use strict;
+use Carp;
+
+use base qw/App::CLI::Command Class::Accessor::Fast/;
+__PACKAGE__->mk_accessors(qw/config category path target/);
+
+use BPB;
+
+sub options {
+    ( 'c|config=s' => 'config',
+      'g|category=s' => 'category',
+      'p|path=s' => 'path',
+      't|target=s' => 'target',
+    )
+}
+
+
+sub run {
+    my $self = shift;
+    my $bpb = BPB->new( config => $self->config );
+    $bpb->backend->export( map { $_, $self->$_ } qw/category path target/ );
+
+}
+
+
+
+
+
+
+1;

Added: bpsbuilder/BPB/lib/BPB/Script/Import.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Script/Import.pm	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,29 @@
+package BPB::Script::Import;
+
+use strict;
+use warnings;
+use Carp;
+
+use base qw/App::CLI::Command Class::Accessor::Fast/;
+__PACKAGE__->mk_accessors(qw/config category comment source/);
+
+use BPB;
+
+sub options {
+    ( 'c|config=s' => 'config',
+      'g|category=s' => 'category',
+      'm|comment=s' => 'comment',
+      's|source=s' => 'source',
+    )
+}
+
+
+sub run {
+    my $self = shift;
+    my $bpb = BPB->new( config => $self->config );
+    $bpb->backend->import( map { $_, $self->$_ } qw/category comment source/ );
+
+}
+
+
+1;

Added: bpsbuilder/BPB/t/00.load.t
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/00.load.t	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,14 @@
+use Test::More tests => 8;
+
+BEGIN {
+use_ok( 'BPB' );
+use_ok( 'BPB::Config' );
+use_ok( 'BPB::Import' );
+use_ok( 'BPB::Import::CPAN' );
+use_ok( 'BPB::Import::SVK' );
+use_ok( 'BPB::Backend' );
+use_ok( 'BPB::Backend::SVK' );
+use_ok( 'BPB::Export' );
+}
+
+diag( "Testing BPB $BPB::VERSION" );

Added: bpsbuilder/BPB/t/01-BPB-Config.t
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/01-BPB-Config.t	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use BPB::Config;
+use FindBin;
+
+my $config = BPB::Config->new( $FindBin::Bin . '/config.yml' );
+
+is( $config->stash->{project}, 'test', 'project is test' );
+is( $config->stash->{backend}{project}, 'test', 'tidy successfully' );
+
+
+

Added: bpsbuilder/BPB/t/config.yml
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/config.yml	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,4 @@
+project: test
+backend:
+    module: SVK
+    command: '/usr/bin/svk'

Added: bpsbuilder/BPB/t/perlcritic.t
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/perlcritic.t	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+
+use Test::More;
+eval "use Test::Perl::Critic 0.0.8";
+plan skip_all => "Test::Perl::Critic 0.0.8 required for testing PBP compliance" if $@;
+
+Test::Perl::Critic::all_critic_ok();

Added: bpsbuilder/BPB/t/pod-coverage.t
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/pod-coverage.t	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

Added: bpsbuilder/BPB/t/pod.t
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/t/pod.t	Tue Nov 20 15:36:56 2007
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();



More information about the Bps-public-commit mailing list