[Bps-public-commit] r13895 - in Lorzy/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 8 17:24:51 EDT 2008


Author: sartak
Date: Tue Jul  8 17:24:51 2008
New Revision: 13895

Modified:
   Lorzy/trunk/   (props changed)
   Lorzy/trunk/lib/Lorzy/Builder.pm

Log:
 r63894 at onn:  sartak | 2008-07-08 17:24:47 -0400
 Don't require YAML, just use YAML::Dump if we can (otherwise, Data::Dumper)


Modified: Lorzy/trunk/lib/Lorzy/Builder.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Builder.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Builder.pm	Tue Jul  8 17:24:51 2008
@@ -41,9 +41,19 @@
     elsif (ref($tree) eq 'HASH') {
         return $self->build_op_expression($tree->{name}, $tree->{args});
     } else {
-        require YAML;
-        confess "Don't know what to do with a tree that looks like "
-              . YAML::Dump($tree);
+        my $dump;
+
+        # if they have YAML, use it
+        if (eval { require YAML; 1 }) {
+            $dump = YAML::Dump($tree);
+        }
+        # otherwise, go with the old fogey
+        else {
+            require Data::Dumper;
+            $dump = Data::Dumper->Dump($tree);
+        }
+
+        confess "Invalid tree $tree. Expected string or hashref. Got $dump.";
     }
 }
 



More information about the Bps-public-commit mailing list