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_list => 'run_cmd_list',
17 _get_gpp_object => 'get_gpp_object',
20 has sha1 => ( isa => NonEmptySimpleStr,
24 has type => ( isa => NonEmptySimpleStr,
28 has $_ => ( isa => NonEmptySimpleStr,
34 has _gpp_obj => ( isa => 'Git::PurePerl::Object',
38 handles => [ 'content',
42 # objects can't determine their mode or filename
43 has file => ( isa => NonEmptySimpleStr,
46 has mode => ( isa => Int,
51 method BUILD { $self->$_() for qw/_gpp_obj size modestr/ }
56 method _build__gpp_obj {
57 return $self->_get_gpp_object($self->sha1)
60 method "_build_size" {
61 my $v = $self->_cat_file_with_flag('s');
66 method _build_modestr {
67 my $modestr = mode_to_string($self->mode);
71 method _cat_file_with_flag ($flag) {
72 $self->_run_cmd('cat-file', '-' . $flag, $self->{sha1})