Merge branch 'master' of git.shadowcat.co.uk:Oyster
Graeme Lawton [Sat, 20 Nov 2010 16:32:59 +0000 (16:32 +0000)]
lib/Oyster/Deploy/Git.pm [new file with mode: 0644]
t/Deploy/git.t [new file with mode: 0644]

diff --git a/lib/Oyster/Deploy/Git.pm b/lib/Oyster/Deploy/Git.pm
new file mode 100644 (file)
index 0000000..37ff0a8
--- /dev/null
@@ -0,0 +1,24 @@
+package Oyster::Deploy::Git;
+
+use Moose;
+use Git::Wrapper;
+use Error::Simple;
+
+use Data::Dumper;
+
+sub create {
+  my $self = shift;
+  my $location = shift;
+  
+  if( -f $location || -d $location ) {
+    Error::Simple->throw("$location already exists");
+  }
+  
+  mkdir($location);
+  my $git = Git::Wrapper->new($location);
+  
+  return 1;
+}
+
+
+1;
\ No newline at end of file
diff --git a/t/Deploy/git.t b/t/Deploy/git.t
new file mode 100644 (file)
index 0000000..5ba2614
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More qw/no_plan/;
+use Test::Exception;
+
+use File::Temp qw/tempdir/;
+
+BEGIN { use_ok( 'Oyster::Deploy::Git' ); }
+
+my $tmpdir = tempdir();
+
+my $deploy = new_ok 'Oyster::Deploy::Git';
+
+#create
+is($deploy->create("${tmpdir}/testapp"), 1, 'Create returned okay');
+
+ok((-d "${tmpdir}/testapp"), "App directory created");
+
+throws_ok(sub {$deploy->create("${tmpdir}/testapp")}, 'Error::Simple', "Directory already exists");