4 class Gitalist::Git::Object {
5 use MooseX::Types::Moose qw/Str Int Bool Maybe ArrayRef/;
6 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
7 use File::Stat::ModeString qw/mode_to_string/;
9 # project and sha1 are required initargs
10 has project => ( isa => 'Gitalist::Git::Project',
15 _run_cmd => 'run_cmd',
16 _run_cmd_fh => 'run_cmd_fh',
17 _run_cmd_list => 'run_cmd_list',
18 _get_gpp_object => 'get_gpp_object',
21 has sha1 => ( isa => NonEmptySimpleStr,
25 has type => ( isa => NonEmptySimpleStr,
29 has $_ => ( isa => NonEmptySimpleStr,
35 has _gpp_obj => ( isa => 'Git::PurePerl::Object',
39 handles => [ 'content',
43 # objects can't determine their mode or filename
44 has file => ( isa => NonEmptySimpleStr,
47 has mode => ( isa => Int,
52 method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
57 method _build__gpp_obj {
58 return $self->_get_gpp_object($self->sha1)
61 method "_build_size" {
62 my $v = $self->_cat_file_with_flag('s');
67 method _build_modestr {
68 my $modestr = mode_to_string($self->mode);
72 method _cat_file_with_flag ($flag) {
73 $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})
82 See L<Gitalist> for authors.
86 See L<Gitalist> for the license.