### An object like this...
my $obj = bless( {
this_object_has_some_long_keys => {
and_some_of_them_are_nested => {
fairly_deeply => 'Foo!',
}
},
}, 'Some::Random::ClassName' );
### Will end up like this with Data::Dumper...
bless({
"this_object_has_some_long_keys" => { "and_some_of_them_are_nested" => { fairly_deeply => "Foo!" } },
}, "Some::Random::ClassName")
### YAML output is more readable, IMHO
--- !!perl/hash:Some::Random::ClassName
this_object_has_some_long_keys:
and_some_of_them_are_nested:
fairly_deeply: Foo!
####
$fh->print(
"package MyApp::TestData::$digest;\n",
"use parent 'Class::Data::Accessor';\n\n\n",
"use YAML qw( Load );\n",
'sub data($$) { __PACKAGE__->mk_classaccessor( @_ ) }'."\n\n",
"data filename => ".dump( $self->filename ).";\n\n",
"data store => Load( <<'$tag' );\n",
YAML::Dump( $store ),
"$tag\n\n",
"data content => <<'$tag';\n",
$self->content,
"$tag\n",
"return __PACKAGE__;\n",
);
####
package MyApp::TestData::PUHmx80zfPHoDloIOrexGA;
use parent 'Class::Data::Accessor';
use YAML qw( Load );
sub data($$) { __PACKAGE__->mk_classaccessor( @_ ) }
data filename => "test-data/some-filename";
data store => Load( <<'___END_OF_TEST_DATA_SECTION___' );
--- &1 !!perl/hash:MyApp::Store
children:
- &2 !!perl/hash:MyApp::Store
___END_OF_TEST_DATA_SECTION___
data content => <<'___END_OF_TEST_DATA_SECTION___';
Original file contents here...
___END_OF_TEST_DATA_SECTION___
return __PACKAGE__;
####
for my $file ( <*.pl> ) {
ok( my $class = do $file, "Loaded $file" );
my $p = MyApp::Processor->new(
filename => $class->filename,
content => $class->content,
);
eq_or_diff( $p->store, $class->store );
}