Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow YAML implementation to be configurable.

  • Loading branch information...
commit 768becd9c324729aa9d1e7440b0d4b758e62d6a5 1 parent c3c9eb9
Ingy döt Net ingydotnet authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/App/PipeFilter/Role/Output/Yaml.pm
14 lib/App/PipeFilter/Role/Output/Yaml.pm
View
@@ -2,11 +2,13 @@ package App::PipeFilter::Role::Output::Yaml;
use Moose::Role;
-use YAML::Syck qw(Dump);
-
sub encode_output {
+ my $yaml_module = $ENV{PERL_APP_PIPEFILTER_YAML} || 'YAML::Syck';
+ eval "require $yaml_module; 1" or die $@;
+ my $dump = do { no strict 'refs'; \&{"${yaml_module}::Dump"} }
+ or die "$yaml_module has no Dump function";
# Skips $self in $_[0].
- return map { Dump($_) } @_[1..$#_];
+ return map { $dump->($_) } @_[1..$#_];
}
1;
@@ -42,6 +44,12 @@ that serializes data into YAML for output.
L<App::PipeFilter::Generic> uses encode_output() to determine the
format of the data it will write.
+=head1 CONFIGURATION
+
+App::PipeFilter::Role::Output::Yaml uses YAML::Syck by default. You can change
+the YAML implementation by setting the C<PERL_APP_PIPEFILTER_YAML> environment
+variable.
+
=head1 SEE ALSO
You may read this module's implementation in its entirety at
Please sign in to comment.
Something went wrong with that request. Please try again.