From: Robert 'phaylon' Sedlacek Date: Thu, 31 May 2012 00:08:56 +0000 (+0000) Subject: switched to JSON::Diffable as file format X-Git-Tag: v0.001_001~55 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a11cf83a358aeac94e51bc316146b50d98a82cc;p=scpubgit%2FSystem-Introspector.git switched to JSON::Diffable as file format --- diff --git a/lib/System/Introspector/State.pm b/lib/System/Introspector/State.pm index 064006a..3506a1c 100644 --- a/lib/System/Introspector/State.pm +++ b/lib/System/Introspector/State.pm @@ -5,6 +5,8 @@ use Object::Remote; use Object::Remote::Future; use System::Introspector::Gatherer; +use JSON::Diffable qw( encode_json ); + has config => (is => 'ro', required => 1); has introspectors => (is => 'lazy'); @@ -46,11 +48,10 @@ sub _build_introspectors { sub _store { my ($self, $data) = @_; - my $yaml = Data::YAML::Writer->new; my $storage = $self->storage; my @files; for my $class (sort keys %$data) { - my $file = sprintf '%s.yml', join '/', + my $file = sprintf '%s.json', join '/', node => $self->node_path, map lc, map { s{([a-z0-9])([A-Z])}{${1}_${2}}g; @@ -58,7 +59,7 @@ sub _store { } split m{::}, $class; my $fh = $storage->open('>:utf8', $file, mkpath => 1); print "Writing $file\n"; - $yaml->write($data->{$class}, $fh); + print $fh encode_json($data->{$class}); push @files, $storage->file($file); } $self->_cleanup(\@files);