Move all POD below the code, for ::Repo and ::Project.
[catagits/Gitalist.git] / lib / Gitalist / Git / Object.pm
index b47ab93..544b473 100644 (file)
@@ -2,9 +2,10 @@ use MooseX::Declare;
 use Moose::Autobox;
 
 class Gitalist::Git::Object {
-    use MooseX::Types::Moose qw/Str Int/;
+    use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
     use File::Stat::ModeString qw/mode_to_string/;
+
     # project and sha1 are required initargs
     has project => ( isa => 'Gitalist::Git::Project',
                      required => 1,
@@ -12,31 +13,30 @@ class Gitalist::Git::Object {
                      weak_ref => 1,
                      handles => {
                          _run_cmd => 'run_cmd',
+                         _run_cmd_fh => 'run_cmd_fh',
+                         _run_cmd_list => 'run_cmd_list',
                          _get_gpp_object => 'get_gpp_object',
                      },
                  );
     has sha1 => ( isa => NonEmptySimpleStr,
-               required => 1,
-               is => 'ro' );
-
-    has $_ => ( isa => NonEmptySimpleStr,
                   required => 1,
+                  is => 'ro' );
+
+    has type => ( isa => NonEmptySimpleStr,
                   is => 'ro',
-                  lazy_build => 1 )
-        for qw/type modestr size/;
+                  required => 1 );
+
+    has $_ => ( isa => NonEmptySimpleStr,
+                required => 1,
+                is => 'ro',
+                lazy_build => 1 )
+        for qw/modestr size/;
 
     has _gpp_obj => ( isa => 'Git::PurePerl::Object',
                       required => 1,
                       is => 'ro',
                       lazy_build => 1,
-                      handles => [ 'parents',
-                                   'parent_sha1',
-                                   'comment',
-                                   'author',
-                                   'authored_time',
-                                   'committer',
-                                   'committed_time',
-                                   'tree_sha1',
+                      handles => [ 'content',
                                ],
                   );
 
@@ -45,22 +45,23 @@ class Gitalist::Git::Object {
                   required => 0,
                   is => 'ro' );
     has mode => ( isa => Int,
-                required => 1,
-                default => 0,
-                is => 'ro' );
+                  required => 1,
+                  default => 0,
+                  is => 'ro' );
+
+    method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
 
-    method BUILD { $self->$_() for qw/_gpp_obj type size modestr/ }
+## Private methods
 
+## Builders
     method _build__gpp_obj {
         return $self->_get_gpp_object($self->sha1)
     }
 
-    foreach my $key (qw/ type size /) {
-        method "_build_$key" {
-            my $v = $self->_cat_file_with_flag(substr($key, 0, 1));
-            chomp($v);
-            return $v;
-        }
+    method "_build_size" {
+        my $v = $self->_cat_file_with_flag('s');
+        chomp($v);
+        return $v;
     }
 
     method _build_modestr {
@@ -72,19 +73,16 @@ class Gitalist::Git::Object {
         $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
     }
 
-=head2 contents
+} # end class
 
-Return the contents of a given file.
 
-=cut
 
-    # FIXME - Should be an attribute so it gets cached?
-    method contents {
-        if ( $self->type ne 'blob' ) {
-            die "object $self->sha1 is not a file\n"
-        }
+=head1 AUTHORS
 
-        $self->_cat_file_with_flag('p');
-    }
+See L<Gitalist> for authors.
 
-} # end class
+=head1 LICENSE
+
+See L<Gitalist> for the license.
+
+=cut