This question was asked some time ago, but I had to deal with it today, so I decided to share my solution based on the changes made to this module at the moment. If you scan PerlTidy documents for -format-skipping, you will see that you can give PerlTidy instructions about which code should not be used. Start and end markers indicate # <<<and # →>, respectively. Thus, the default settings look something like this:
# tidy my code my $foo = 'bar'; #<<< # don't tidy the code below my $baz = 'foo'; # start to tidy again #>>> $foo .= 'stuff';
It is easy enough. Now you just need Loader to wrap the generated code with these markers. It might look something like this:
my %args = ( components => [ 'InflateColumn::DateTime', 'TimeStamp' ], debug => 1, dump_directory => './lib', filter_generated_code => sub { my ( $type, $class, $text ) = @_; return "#<<<\n$text#>>>"; }, generate_pod => 0, naming => 'current', overwrite_modifications => 0, skip_load_external => 1, use_moose => 1, use_namespaces => 1, ); make_schema_at( 'My::Schema', \%args, [$dsn, $user, $pass] );
The important part is filter_generated_code , which allows you to generate the generated code. Now you can generate your schema files and still use PerlTidy. This will allow you to arrange the custom code that you add at the bottom of the generated files without triggering errors that occur when the generated code is changed by something other than make_schema_at ().
In my case, I decided to disable generate_pod because PerlTidy still (for some reason) inserted some newlines into the created Pod. I do not quite understand why this is so, but disabling Pod fixes it, and I can live without it.
oalders
source share