Rename Object->contents to ->content, and delegate to GPP.
Zachary Stevens [Thu, 12 Nov 2009 20:26:00 +0000 (20:26 +0000)]
lib/Gitalist/Controller/Root.pm
lib/Gitalist/Git/Object.pm

index 8a23613..b066b80 100644 (file)
@@ -172,7 +172,7 @@ sub blob : Local {
   my $filename = $c->req->param('f') || '';
 
   $c->stash(
-    blob     => $project->get_object($h)->contents,
+    blob     => $project->get_object($h)->content,
     head     => $project->get_object($hb),
     filename => $filename,
     # XXX Hack hack hack, see View::SyntaxHighlight
index ff33b8d..3addbb6 100644 (file)
@@ -40,14 +40,14 @@ class Gitalist::Git::Object {
 
     # This feels wrong, but current templates assume
     # these attributes are present on every object.
-    foreach my $key (qw/tree_sha1 comment/) {
+    foreach my $key (qw/tree_sha1 comment content/) {
         has $key => ( isa => Str,
                       required => 1,
                       is => 'ro',
                       lazy_build => 1,
                   );
         method "_build_$key" {
-            return '' unless $self->_gpp_obj->can($key);
+            confess("Object can't " . $key) unless $self->_gpp_obj->can($key);
             return $self->_gpp_obj->$key;
         }
     }
@@ -84,19 +84,4 @@ class Gitalist::Git::Object {
         $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
     }
 
-=head2 contents
-
-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"
-        }
-
-        $self->_cat_file_with_flag('p');
-    }
-
 } # end class