4 use YAML::Syck qw(LoadFile);
 
  11 locale-diff - Compare two YAML files and print how their datastructures differ
 
  15     locale-diff en.yml is.yml
 
  16     locale-diff en.yml is.yml | grep '*'
 
  20 This utility prints the differences between two YAML files using
 
  21 L<Test::Differences>. The purpose of it is to diff the files is
 
  22 F<config/locales> to find out what keys need to be added to the
 
  23 translated files when F<en.yml> changes.
 
  31 Print this help message.
 
  37 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@f-prot.com>
 
  41 # Get the command-line options
 
  42 Getopt::Long::Parser->new(
 
  43     config => [ qw< bundling no_ignore_case no_require_order pass_through > ],
 
  45     'h|help' => \my $help,
 
  51 # If we're not given two .yml files
 
  52 help() if @ARGV != 2 or (!-f $ARGV[0] or !-f $ARGV[1]);
 
  54 my ($from, $to) = @ARGV;
 
  56 my $from_data = LoadFile($from);
 
  57 my $to_data   = LoadFile($to);
 
  59 my $from_parsed = { iterate($from_data->{basename($from)}) };
 
  60 my $to_parsed = { iterate($to_data->{basename($to)}) };
 
  63 #walkdepth \&delete_hash_values, $_ for $from_data, $to_data;
 
  65 # Hack around Test::Differences wanting a Test::* module loaded
 
  67 sub Test::ok { print shift }
 
  70 eq_or_diff([ sort keys %$from_parsed ], [ sort keys %$to_parsed ]);
 
  76     my ($hash, @path) = @_;
 
  79     while (my ($k, $v) = each %$hash)
 
  83              push @ret => iterate($v, @path, $k);
 
  87             push @ret => join(".",@path, $k), $v;
 
 105     Pod::Usage::pod2usage(
 
 106         -verbose => $arg{ verbose },
 
 107         -exitval => $arg{ exitval } || 0,