-
Notifications
You must be signed in to change notification settings - Fork 5
/
diff.pl
executable file
·65 lines (52 loc) · 1.58 KB
/
diff.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env perl
use v5.20.1;
use Mojo::UserAgent;
use Gcis::Client;
use YAML::XS qw/Dump/;
use Text::Diff qw/diff/;
use Data::Dumper;
my $src_url = q[http://data.gcis-dev-front.joss.ucar.edu];
my $dst_url = q[http://data-stage.globalchange.gov];
my $what = $ARGV[0] || q[organization];
my $verbose = 1;
my $src = Gcis::Client->new(url => $src_url );
my $dst = Gcis::Client->new(url => $dst_url );
sub same {
my ($x,$y) = @_;
return !( Dump($x) cmp Dump($y) );
}
say "src : ".$src->url;
say "dst : ".$dst->url;
say "resource : $what";
my @src = $src->get("/$what?all=1");
my @dst = $dst->get("/$what?all=1");
delete $_->{href} for @src, @dst;
say "counts :";
say " src : ".@src;
say " dst : ".@dst;
# key on uri
my %src = map {$_->{uri} => $_} @src;
my %dst = map {$_->{uri} => $_} @dst;
say "identifiers :";
my @only_in_src = grep !exists($dst{$_}), keys %src;
my @only_in_dst = grep !exists($src{$_}), keys %dst;
my @common = grep exists($dst{$_}), keys %src;
say " common : ".@common;
say " only in src : ".@only_in_src;
say " only in dst : ".@only_in_dst;
say "content : ";
my @same = grep same($src{$_},$dst{$_}), @common;
my @different = grep !same($src{$_},$dst{$_}), @common;
say " same : ".@same;
say " different : ".@different;
if ($verbose) {
say "\nOnly in $src_url : ";
say " ".$_ for @only_in_src;
say "\nOnly in $dst_url : ";
say " ".$_ for @only_in_dst;
say "\nDifferences between resources in both places : ";
for (@different) {
say "uri : ".$_;
say diff(\Dump($src{$_}), \Dump($dst{$_}));
}
}