Merge branch 'master' into save_change
[MojoFacets.git] / script / changes
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use Storable;
7 use Mojo::Client;
8 use Data::Dump qw(dump);
9
10 my $url = 'http://localhost:3000/data/edit';
11 my $max = 1;
12
13 my @changes = @ARGV;
14
15 my $t = Mojo::Client->new;
16 $t->max_redirects( 1 );
17
18 foreach my $c ( @changes ) {
19
20         print "# $c\n";
21
22         my $params = retrieve $c;
23         my $hash = $params->to_hash;
24         $hash->{time} = $1 if $c =~ m{/(\d+\.\d+)\.data\.edit};
25
26         warn "# hash ",dump($hash);
27
28         my $tx = $t->post_form( $url => $hash );
29         if ( my $res = $tx->success) { print $res->body }
30         else {
31                 my ($code, $message) = $tx->error;
32                 die "Error: $message";
33         }
34
35 #       last if $max-- == 0;
36 }