Skip to content

Commit

Permalink
Build results of 73d0c9c (on master)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Jun 28, 2015
1 parent ecc16e8 commit b51a119
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/Asset/Pack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ sub pack_asset {
my $packer = __PACKAGE__ . ' version ' . $VERSION;
my $version_statement = q[];
if ( defined $version ) {
## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
$version_statement = sprintf q[our $VERSION = '%s';], $version;
$version_statement = _pack_variable( 'our', 'VERSION', $version );
}
return <<"EOF";
package $module;
Expand All @@ -67,7 +66,6 @@ EOF

sub pack_index {
my ( $module, $index ) = @_;
require Data::Dumper;
for my $key ( keys %{$index} ) {
next unless ref $index->{$key};
if ( eval { $index->{$key}->isa('Path::Tiny') } ) {
Expand All @@ -76,16 +74,12 @@ sub pack_index {
}
die "Unsupported ref value in index for key $key: $index->{$key}";
}
my $dumper = Data::Dumper->new( [$index], ['index'] );
$dumper->Purity(1)->Sortkeys(1);
$dumper->Terse(0)->Indent(1);
my $index_text = $dumper->Dump();

my $index_text = _pack_variable( 'our', 'index', $index );
my $packer = __PACKAGE__ . ' version ' . $VERSION;
return <<"EOF";
package $module;
# Generated index by $packer
our $index_text;
$index_text;
1;
EOF

Expand Down Expand Up @@ -147,6 +141,15 @@ sub find_and_pack {
return { ok => \@ok, fail => \@fail, unchanged => \@unchanged };
}

sub _pack_variable {
my ( $context, $varname, $content ) = @_;
require Data::Dumper;
my $dumper = Data::Dumper->new( [$content], [$varname] );
$dumper->Purity(1)->Sortkeys(1);
$dumper->Terse(0)->Indent(1);
return sprintf '%s %s;', $context, $dumper->Dump();
}

1;

__END__
Expand Down

0 comments on commit b51a119

Please sign in to comment.