Revision history for MooseX-Storage
+0.04
+ * MooseX::Storage::Util
+ - made this more robust when it tries
+ to use YAML and JSON loaders and fails
+ to find one
+ - fixed tests to reflect this
+
0.03 Wed. June 27, 2007
* MooseX::Storage::Util
- this is a collection of useful tools
use MooseX::Storage::Engine ();
-our $VERSION = '0.01';
+our $VERSION = '0.02';
our $AUTHORITY = 'cpan:STEVAN';
sub peek {
my ($class, $json) = @_;
require JSON::Any;
- JSON::Any->import;
+ eval { JSON::Any->import };
+ confess "Could not load JSON module because : $@" if $@;
my $data = eval { JSON::Any->jsonToObj($json) };
if ($@) {
my ($class, $yaml) = @_;
require Best;
- Best->import([[ qw[YAML::Syck YAML] ]]);
+ eval { Best->import([[ qw[YAML::Syck YAML] ]]) };
+ confess "Could not load YAML module because : $@" if $@;
+
my $inflater = Best->which('YAML::Syck')->can('Load');
string: foo
};
-is(
-'Foo',
-MooseX::Storage::Util->peek($packed),
-'... got the right class name from the packed item');
+is('Foo', MooseX::Storage::Util->peek($packed),
+ '... got the right class name from the packed item');
-is(
-'Foo',
-MooseX::Storage::Util->peek($json => ('format' => 'JSON')),
-'... got the right class name from the json item');
+SKIP: {
+ my $classname = eval {
+ MooseX::Storage::Util->peek($json => ('format' => 'JSON'))
+ };
+ if ($@ =~ /^Could not load JSON module because/) {
+ skip "No JSON module found", 1;
+ }
-is(
-'Foo',
-MooseX::Storage::Util->peek($yaml => ('format' => 'YAML')),
-'... got the right class name from the yaml item');
+ is('Foo', $classname,
+ '... got the right class name from the json item');
+}
+
+SKIP: {
+ my $classname = eval {
+ MooseX::Storage::Util->peek($yaml => ('format' => 'YAML'))
+ };
+ if ($@ =~ /^Could not load YAML module because/) {
+ skip "No YAML module found", 1;
+ }
+
+ is('Foo', $classname,
+ '... got the right class name from the yaml item');
+}