Created
September 30, 2014 18:20
-
-
Save alexm/bead30b6f5efed8d75b8 to your computer and use it in GitHub Desktop.
Check Act templates for missing strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use autodie; | |
use Test::More; | |
die "usage: $0 file1 file2\n" unless @ARGV == 2; | |
my ($file1, $file2) = @ARGV; | |
sub parse_file | |
{ | |
my ( $file, $loc_ref, $tt_ref ) = @_; | |
open my $fd, '<', $file; | |
my $content = do { local $/; <$fd> }; | |
close $fd; | |
$loc_ref->{$1}++ while $content =~ /(\{\{.*?\}\})/mg; | |
$tt_ref->{$1}++ while $content =~ /(\[%.*?%\])/mg; | |
} | |
parse_file( $file1, \my %loc1, \my %tt1 ); | |
parse_file( $file2, \my %loc2, \my %tt2 ); | |
is_deeply( \%loc2, \%loc1, 'loc' ); | |
is_deeply( \%tt2, \%tt1, 'tt' ); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: