diff options
author | René Scheibe <rene.scheibe@gmail.com> | 2015-06-04 15:33:01 +0200 |
---|---|---|
committer | René Scheibe <rene.scheibe@gmail.com> | 2015-06-04 16:24:47 +0200 |
commit | 3b40e6d7979b517b9f3cb3ae09bf7354fef950a4 (patch) | |
tree | b6541810ded0e7aeb7707ef74a2dabb63a6873b9 | |
parent | 9059d97db02001b60ed70260b2c33c4b9875f54b (diff) | |
download | ninka-3b40e6d7979b517b9f3cb3ae09bf7354fef950a4.tar.gz |
include ninka-excel & ninka-sqlite in the distribution
* now calling ninka with option "-i" to generate the required intermediary files
* possible improvement: use the Ninka::* modules to get the infos without creating files
* not using the evil "Switch" module anymore
* referencing Ninka version to reduce duplication and maintenance hell
-rw-r--r-- | MANIFEST | 2 | ||||
-rw-r--r-- | Makefile.PL | 5 | ||||
-rw-r--r-- | README | 6 | ||||
-rwxr-xr-x | bin/ninka-excel (renamed from ninka-excel.pl) | 15 | ||||
-rwxr-xr-x | bin/ninka-sqlite (renamed from ninka-sqlite.pl) | 87 |
5 files changed, 58 insertions, 57 deletions
@@ -1,4 +1,6 @@ bin/ninka +bin/ninka-excel +bin/ninka-sqlite Changes lib/Ninka.pm lib/Ninka/abbreviations.dict diff --git a/Makefile.PL b/Makefile.PL index af4730c..20ea9fd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,10 +17,15 @@ WriteMakefile( 'ExtUtils::MakeMaker' => '6.52', }, PREREQ_PM => { + 'DBI' => '0', + 'DBD::SQLite' => '0', 'File::Basename' => '0', + 'File::Find' => '0', 'File::Spec::Functions' => '0', + 'File::Temp' => '0', 'Getopt::Std' => '0', 'IPC::Open3' => '0', + 'Spreadsheet::WriteExcel' => '0', }, TEST_REQUIRES => { 'File::Temp' => '0', @@ -62,9 +62,9 @@ the above paper. * Requirements - Perl version 5 or above -- for ninka-excel.pl: Perl module Spreadsheet::WriteExcel - https://metacpan.org/release/Spreadsheet-WriteExcel/ -- for ninka-sqlite.pl: Perl module DBD::SQLite +- for ninka-excel: Perl module Spreadsheet::WriteExcel + https://metacpan.org/release/Spreadsheet-WriteExcel +- for ninka-sqlite: Perl module DBD::SQLite https://metacpan.org/release/DBD-SQLite * How to install diff --git a/ninka-excel.pl b/bin/ninka-excel index 71adddf..2e2d35d 100755 --- a/ninka-excel.pl +++ b/bin/ninka-excel @@ -17,20 +17,17 @@ # use strict; -use Switch; use File::Temp; use File::Find; use File::Basename; -use Scalar::Util qw(looks_like_number); +use Ninka; use Spreadsheet::WriteExcel; - - -if(scalar(@ARGV) != 2){ - print STDERR "Ninka 1.3. sqlite wrapper\n"; +if (scalar(@ARGV) != 2) { + print STDERR "Ninka v${Ninka::VERSION}. sqlite wrapper\n"; print STDERR "Processes package file (.tar.gz, zip, jar. etc) and outputs to excel file\n"; print STDERR "Incorrect number of arguments\n"; - print STDERR "Correct usage is: $0 <path to package file> <excel-file>\n"; + print STDERR "Usage: $0 <path to package file> <excel-file>\n"; exit 1; } @@ -85,11 +82,10 @@ print "***** Beginning Execution of Ninka *****\n"; foreach my $file (@files) { if (-T $file) { print "Running ninka on file [$file]\n"; - execute("perl ${path}/ninka.pl '$file'"); + execute("perl ${path}/ninka -i '$file'"); } } - print "***** Entering Ninka Data into excell file [$excelFile] *****\n"; my $row = 1; @@ -116,7 +112,6 @@ foreach my $file (@files) { my @columns = parseLicenseData($filedata); - my $originalFile = $file; $originalFile =~ s/\.license$//; diff --git a/ninka-sqlite.pl b/bin/ninka-sqlite index d53f60f..6b27ea9 100755 --- a/ninka-sqlite.pl +++ b/bin/ninka-sqlite @@ -17,20 +17,17 @@ # use strict; -use Switch; use DBI; use File::Temp; use File::Find; use File::Basename; -use Scalar::Util qw(looks_like_number); +use Ninka; - - -if(scalar(@ARGV) != 2){ - print STDERR "Ninka 1.3. sqlite wrapper\n"; +if (scalar(@ARGV) != 2) { + print STDERR "Ninka v${Ninka::VERSION}. sqlite wrapper\n"; print STDERR "Processes package file (.tar.gz, zip, jar. etc) and outputs to sqlite file\n"; print STDERR "Incorrect number of arguments\n"; - print STDERR "Correct usage is: $0 <path to package file> <database name>\n"; + print STDERR "Usage: $0 <path to package file> <database name>\n"; exit 1; } @@ -88,7 +85,7 @@ find( print "***** Beginning Execution of Ninka *****\n"; foreach my $file (@files) { print "Running ninka on file [$file]\n"; - execute("perl ${path}/ninka.pl '$file'"); + execute("perl ${path}/ninka -i '$file'"); } my @ninkafiles; @@ -116,44 +113,46 @@ foreach my $file (@ninkafiles) { my $filedata = do { local $/; <$fh> }; my $sth; - switch (getExtension($basefile)){ - -# case ".comments" { -# print "Inserting [$basefile] into table comments\n"; -# $sth = $dbh->prepare("INSERT INTO comments VALUES -# ('$rootfile', '$filepath', '$packname', ?)"); -# } - case ".sentences" { - print "Inserting [$basefile] into table sentences\n"; - $sth = $dbh->prepare("INSERT INTO sentences VALUES - ('$rootfile', '$filepath', '$packname', ?)"); - } - case ".goodsent" { - print "Inserting [$basefile] into table goodsents\n"; - $sth = $dbh->prepare("INSERT INTO goodsents VALUES - ('$rootfile', '$filepath', '$packname', ?)"); - } - case ".badsent" { - print "Inserting [$basefile] into table goodsents\n"; - $sth = $dbh->prepare("INSERT INTO badsents VALUES - ('$rootfile', '$filepath', '$packname', ?)"); - } - case ".senttok" { - print "Inserting [$basefile] into table senttoks\n"; - $sth = $dbh->prepare("INSERT INTO senttoks VALUES - ('$rootfile', '$filepath', '$packname', ?)"); - } - case ".license" { - print "Inserting [$basefile] into table licenses\n"; - my @columns = parseLicenseData($filedata); - $sth = $dbh->prepare("INSERT INTO licenses VALUES - ('$rootfile', '$filepath', '$packname', '$columns[0]', '$columns[1]', - '$columns[2]', '$columns[3]', '$columns[4]', '$columns[5]', '$columns[6]')"); - } + my $ext = getExtension($basefile); + + if ($ext eq ".comments") { + print "Inserting [$basefile] into table comments\n"; + $sth = $dbh->prepare("INSERT INTO comments VALUES + ('$rootfile', '$filepath', '$packname', ?)"); + } + if ($ext eq ".sentences") { + print "Inserting [$basefile] into table sentences\n"; + $sth = $dbh->prepare("INSERT INTO sentences VALUES + ('$rootfile', '$filepath', '$packname', ?)"); + } + if ($ext eq ".goodsent") { + print "Inserting [$basefile] into table goodsents\n"; + $sth = $dbh->prepare("INSERT INTO goodsents VALUES + ('$rootfile', '$filepath', '$packname', ?)"); + } + if ($ext eq ".badsent") { + print "Inserting [$basefile] into table badsents\n"; + $sth = $dbh->prepare("INSERT INTO badsents VALUES + ('$rootfile', '$filepath', '$packname', ?)"); + } + if ($ext eq ".senttok") { + print "Inserting [$basefile] into table senttoks\n"; + $sth = $dbh->prepare("INSERT INTO senttoks VALUES + ('$rootfile', '$filepath', '$packname', ?)"); + } + if ($ext eq ".license") { + print "Inserting [$basefile] into table licenses\n"; + my @columns = parseLicenseData($filedata); + $sth = $dbh->prepare("INSERT INTO licenses VALUES + ('$rootfile', '$filepath', '$packname', '$columns[0]', '$columns[1]', + '$columns[2]', '$columns[3]', '$columns[4]', '$columns[5]', '$columns[6]')"); + } + + if (defined $sth) { + $sth->bind_param(1, $filedata); + $sth->execute; } - $sth->bind_param(1, $filedata); - $sth->execute; close($fh); } |