12 # |
12 # |
13 # You should have received a copy of the GNU General Public License |
13 # You should have received a copy of the GNU General Public License |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 |
15 |
16 use Mojo::Base -strict; |
16 use Mojo::Base -strict; |
|
17 use lib 'lib'; |
17 |
18 |
18 use lib 'lib'; |
|
19 use CrashTest::Storage::Sql; |
|
20 use Mojo::JSON; |
19 use Mojo::JSON; |
21 use Mojo::Util qw(decode slurp); |
20 use Mojo::Util qw(decode slurp); |
|
21 use Mojo::Loader; |
22 use File::Basename; |
22 use File::Basename; |
|
23 use Mojolicious; |
|
24 use Mojo::Home; |
|
25 |
|
26 if(scalar @ARGV == 0) { |
|
27 say "Usage: $0 <processed json files>"; |
|
28 exit 1; |
|
29 } |
23 |
30 |
24 sub load_config { |
31 sub load_config { |
25 my ($file) = @_; |
32 my $app = Mojolicious->new; |
26 my $code = decode('UTF-8', slurp $file); |
33 $app->home(Mojo::Home->new("$FindBin::Bin/../")); |
27 return eval($code); |
34 $app->moniker("CrashTest"); |
|
35 return $app->plugin('Config'); |
28 } |
36 } |
29 |
37 |
30 my $config = load_config("CrashTest.conf"); |
38 my $config = load_config(); |
31 |
39 |
32 eval "require $config->{Storage}->{Type}"; |
40 my $loader = Mojo::Loader->new; |
33 my $storage = $config->{Storage}->{Type}->new($config->{Storage}); |
|
34 |
41 |
|
42 my $storage_class = $config->{Storage}->{Type}; |
|
43 if (my $e = $loader->load($storage_class)) { |
|
44 die ref $e ? "Exception: $e" : 'Not found!'; |
|
45 } |
|
46 |
|
47 my $storage = $storage_class->new(config => $config->{Storage}); |
35 |
48 |
36 foreach my $arg (@ARGV) { |
49 foreach my $arg (@ARGV) { |
37 my $json = Mojo::JSON->new(); |
50 my $json = Mojo::JSON->new(); |
38 my $pjson = $json->decode(slurp $arg); |
51 my $pjson = $json->decode(slurp $arg); |
39 |
52 |