Abstracted kludges a little more.
[catagits/Gitalist.git] / lib / Gitalist / Git / Repository.pm
index 4aee01e..0269853 100644 (file)
@@ -10,7 +10,16 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     use List::MoreUtils qw/any zip/;
     use DateTime;
     use Encode qw/decode/;
-    use I18N::Langinfo qw/langinfo CODESET/;
+
+    use if $^O ne 'MSWin32', 'I18N::Langinfo', => qw/langinfo CODESET/;
+    BEGIN {
+        no strict 'subs';
+        *__owner = defined &langinfo
+            ? sub { map { decode(langinfo(CODESET), $_) } (getpwuid $_[0]->path->stat->uid)[6,0] }
+            : sub { return qw/OwnEr GroUp/ }
+        ;
+    }
+
     use Gitalist::Git::Object::Blob;
     use Gitalist::Git::Object::Tree;
     use Gitalist::Git::Object::Commit;
@@ -96,7 +105,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
         chomp($type);
         my $class = 'Gitalist::Git::Object::' . ucfirst($type);
         $class->new(
-            project => $self,
+            repository => $self,
             sha1 => $sha1,
             type => $type,
         );
@@ -227,7 +236,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     ## BUILDERS
     method _build_util {
         Gitalist::Git::Util->new(
-            project => $self,
+            repository => $self,
         );
     }
 
@@ -241,7 +250,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     }
 
     method _build_owner {
-        my ($gecos, $name) = map { decode(langinfo(CODESET), $_) } (getpwuid $self->path->stat->uid)[6,0];
+        my ($gecos, $name) = $self->__owner;
         $gecos =~ s/,+$//;
         return length($gecos) ? $gecos : $name;
     }
@@ -339,10 +348,10 @@ Gitalist::Git::Repository - Model of a git repository
 =head1 SYNOPSIS
 
     my $gitrepo = dir('/repo/base/Gitalist');
-    my $project = Gitalist::Git::Repository->new($gitrepo);
-     $project->name;        # 'Gitalist'
-     $project->path;        # '/repo/base/Gitalist/.git'
-     $project->description; # 'Unnamed repository.'
+    my $repository = Gitalist::Git::Repository->new($gitrepo);
+     $repository->name;        # 'Gitalist'
+     $repository->path;        # '/repo/base/Gitalist/.git'
+     $repository->description; # 'Unnamed repository.'
 
 =head1 DESCRIPTION