| 1 | package Sweet::File::Config; | ||
| 2 | use latest; | ||
| 3 | use Moose; | ||
| 4 | |||
| 5 | use Carp; | ||
| 6 | use MooseX::AttributeShortcuts; | ||
| 7 | use Sweet::HomeDir; | ||
| 8 | use YAML; | ||
| 9 | use namespace::autoclean; | ||
| 10 | |||
| 11 | extends 'Sweet::File'; | ||
| 12 | |||
| 13 | sub _build_dir { Sweet::HomeDir->new } | ||
| 14 | |||
| 15 | has content => ( | ||
| 16 | is => 'lazy', | ||
| 17 | isa => 'HashRef', | ||
| 18 | ); | ||
| 19 | |||
| 20 | sub _build_content { | ||
| 21 | my $self = shift; | ||
| 22 | |||
| 23 | my $path = $self->path; | ||
| 24 | |||
| 25 | my $content = YAML::LoadFile( $path ) | ||
| 26 | or croak "Cannot load YAML file $path\n"; | ||
| 27 | |||
| 28 | return $content; | ||
| 29 | } | ||
| 30 | |||
| 31 | __PACKAGE__->meta->make_immutable; | ||
| 32 | |||
| 33 | __END__ |