Updated to Mojolicious 7.20
Change-Id: I3a194d4a4bc912950619a77e7a743c3f930eb544
diff --git a/Changes b/Changes
index e08e227..42d30ad 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+0.25 2017-01-18
+ - Updated to Mojolicious 7.20.
+
0.24 2016-12-21
- Added --base-sentences and --base-paragraphs options
diff --git a/lib/KorAP/XML/Krill.pm b/lib/KorAP/XML/Krill.pm
index 1f5fad8..29b1291 100644
--- a/lib/KorAP/XML/Krill.pm
+++ b/lib/KorAP/XML/Krill.pm
@@ -2,6 +2,7 @@
use Mojo::Base -base;
use Mojo::ByteStream 'b';
use Mojo::Util qw/encode/;
+use Mojo::File;
use Scalar::Util qw/weaken/;
use XML::Fast;
use Try::Tiny;
@@ -67,7 +68,7 @@
else {
# Load file
- $file = b($data_xml)->slurp;
+ $file = b(Mojo::File->new($data_xml)->slurp);
try {
local $SIG{__WARN__} = sub {
$error = 1;
@@ -159,7 +160,7 @@
next unless -e $_;
# Slurp data and probably decode
- my $slurp = b($_)->slurp;
+ my $slurp = b(Mojo::File->new($_)->slurp);
$slurp =~ $ENC_RE;
my $file = $slurp->decode($2 // 'UTF-8');
@@ -405,7 +406,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2015-2016, L<IDS Mannheim|http://www.ids-mannheim.de/>
+Copyright (C) 2015-2017, L<IDS Mannheim|http://www.ids-mannheim.de/>
Author: L<Nils Diewald|http://nils-diewald.de/>
KorAP::XML::Krill is developed as part of the
diff --git a/lib/KorAP/XML/Meta/I5.pm b/lib/KorAP/XML/Meta/I5.pm
index 41fcbe6..a683489 100644
--- a/lib/KorAP/XML/Meta/I5.pm
+++ b/lib/KorAP/XML/Meta/I5.pm
@@ -24,9 +24,9 @@
if ($v) {
$self->{_text_sigle} = _squish $v->text;
if ($self->{_text_sigle} =~ $SIGLE_RE) {
- $self->{_text_sigle} = join('/', $1, $2, $3);
- $self->{_doc_sigle} = join('/', $1, $2);
- $self->{_corpus_sigle} = $1;
+ $self->{_text_sigle} = join('/', $1, $2, $3);
+ $self->{_doc_sigle} = join('/', $1, $2);
+ $self->{_corpus_sigle} = $1;
};
}
}
@@ -37,8 +37,8 @@
if ($v) {
$self->{_doc_sigle} = $v->text;
if ($self->{_doc_sigle} =~ $SIGLE_RE) {
- $self->{_doc_sigle} = join('/', $1, $2);
- $self->{_corpus_sigle} = $1;
+ $self->{_doc_sigle} = join('/', $1, $2);
+ $self->{_corpus_sigle} = $1;
};
}
}
@@ -95,25 +95,24 @@
# Corpus title not yet given
unless ($self->{corpus_title}) {
if ($title = $dom->at('fileDesc > titleStmt > c\.title')) {
- $title = $title->all_text;
+ $title = $title->all_text;
- if ($title) {
- $self->{corpus_title} = _remove_prefix($title, $self->corpus_sigle);
- };
+ if ($title) {
+ $self->{corpus_title} = _remove_prefix($title, $self->corpus_sigle);
+ };
};
};
-
}
# doc title
elsif ($type eq 'doc') {
unless ($self->{doc_title}) {
if ($title = $dom->at('fileDesc > titleStmt > d\.title')) {
- $title = $title->all_text;
+ $title = $title->all_text;
- if ($title) {
- $self->{doc_title} = _remove_prefix($title, $self->doc_sigle);
- };
+ if ($title) {
+ $self->{doc_title} = _remove_prefix($title, $self->doc_sigle);
+ };
};
};
}
@@ -122,10 +121,10 @@
elsif ($type eq 'text') {
unless ($self->{title}) {
if ($title = $dom->at('fileDesc > titleStmt > t\.title')) {
- $title = $title->all_text;
- if ($title) {
- $self->{title} = _remove_prefix($title, $self->text_sigle);
- };
+ $title = $title->all_text;
+ if ($title) {
+ $self->{title} = _remove_prefix($title, $self->text_sigle);
+ };
}
};
};
@@ -210,7 +209,7 @@
};
unless ($create_date =~ s{^(\d{4})$}{$1\.00\.00}) {
unless ($create_date =~ s{^(\d{4})\.(\d{2})$}{$1\.$2\.00}) {
- $create_date =~ /^\d{4}\.\d{2}\.\d{2}$/;
+ $create_date =~ /^\d{4}\.\d{2}\.\d{2}$/;
};
};
if ($create_date =~ /^\d{4}(?:\.\d{2}(?:\.\d{2})?)?$/) {
@@ -226,8 +225,8 @@
$temp->find("catRef")->each(
sub {
- my ($ign, @ttopic) = split('\.', $_->attr('target'));
- push(@topic, @ttopic);
+ my ($ign, @ttopic) = split('\.', $_->attr('target'));
+ push(@topic, @ttopic);
}
);
$self->{text_class} = [@topic] if @topic > 0;
@@ -266,8 +265,8 @@
if ($temp = $dom->at('sourceDesc reference[type=complete]')) {
if (my $ref_text = _squish $temp->all_text) {
- $ref_text =~ s!$REF_RE!!;
- $self->{reference} = $ref_text;
+ $ref_text =~ s!$REF_RE!!;
+ $self->{reference} = $ref_text;
};
};
@@ -279,7 +278,7 @@
if ($temp = $dom->at('biblStruct biblScope[type=pp]')) {
$temp = _squish $temp->all_text;
if ($temp && $temp =~ m/(\d+)\s*-\s*(\d+)/) {
- $self->{pages} = $1 . '-' . $2;
+ $self->{pages} = $1 . '-' . $2;
};
};
};
diff --git a/lib/KorAP/XML/Tokenizer.pm b/lib/KorAP/XML/Tokenizer.pm
index f5c2f8f..b89f92c 100644
--- a/lib/KorAP/XML/Tokenizer.pm
+++ b/lib/KorAP/XML/Tokenizer.pm
@@ -1,6 +1,7 @@
package KorAP::XML::Tokenizer;
use Mojo::Base -base;
use Mojo::ByteStream 'b';
+use Mojo::File;
use XML::Fast;
use Try::Tiny;
use Carp qw/croak/;
@@ -54,7 +55,7 @@
return;
};
- my $file = b($path)->slurp;
+ my $file = b(Mojo::File->new($path)->slurp);
my $doc = $self->doc;
diff --git a/lib/KorAP/XML/Tokenizer/Spans.pm b/lib/KorAP/XML/Tokenizer/Spans.pm
index c144bf5..fa91bc5 100644
--- a/lib/KorAP/XML/Tokenizer/Spans.pm
+++ b/lib/KorAP/XML/Tokenizer/Spans.pm
@@ -4,6 +4,7 @@
use KorAP::XML::Log;
use Data::Dumper;
use Mojo::Base 'KorAP::XML::Tokenizer::Units';
+use Mojo::File;
use KorAP::XML::Tokenizer::Span;
use Mojo::ByteStream 'b';
use XML::Fast;
@@ -30,7 +31,7 @@
return;
};
- my $file = b($path)->slurp;
+ my $file = b(Mojo::File->new($path)->slurp);
my ($spans, $error);
try {
diff --git a/lib/KorAP/XML/Tokenizer/Tokens.pm b/lib/KorAP/XML/Tokenizer/Tokens.pm
index 49ca7b6..3881979 100644
--- a/lib/KorAP/XML/Tokenizer/Tokens.pm
+++ b/lib/KorAP/XML/Tokenizer/Tokens.pm
@@ -1,6 +1,7 @@
package KorAP::XML::Tokenizer::Tokens;
use Mojo::Base 'KorAP::XML::Tokenizer::Units';
use Mojo::ByteStream 'b';
+use Mojo::File;
use KorAP::XML::Tokenizer::Token;
use Carp qw/croak carp/;
use File::Spec::Functions qw/catdir catfile/;
@@ -32,7 +33,7 @@
};
};
- my $file = b($path)->slurp;
+ my $file = b(Mojo::File->new($path)->slurp);
# Bug workaround
if ($self->foundry eq 'glemm') {
diff --git a/script/korapxml2krill b/script/korapxml2krill
index 7974c76..b60eb59 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -930,7 +930,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2015-2016, L<IDS Mannheim|http://www.ids-mannheim.de/>
+Copyright (C) 2015-2017, L<IDS Mannheim|http://www.ids-mannheim.de/>
Author: L<Nils Diewald|http://nils-diewald.de/>
Contributor: Eliza Margaretha
diff --git a/t/batch_file.t b/t/batch_file.t
index ccfa62f..ed32401 100644
--- a/t/batch_file.t
+++ b/t/batch_file.t
@@ -5,7 +5,7 @@
use File::Basename 'dirname';
use File::Spec::Functions 'catdir';
use File::Temp qw/ :POSIX /;
-use Mojo::Util qw/slurp/;
+use Mojo::File;
use Mojo::JSON qw/decode_json/;
use IO::Uncompress::Gunzip;
use Data::Dumper;
@@ -25,7 +25,7 @@
ok(-f $output, 'File exists');
-ok(my $file = slurp $output, 'Slurp data');
+ok(my $file = Mojo::File->new($output)->slurp, 'Slurp data');
ok(my $json = decode_json $file, 'decode json');
@@ -66,7 +66,7 @@
];
$output = tmpnam();
ok($bf->process($path => $output), 'Process file');
-ok($file = slurp $output, 'Slurp data');
+ok($file = Mojo::File->new($output)->slurp, 'Slurp data');
ok($json = decode_json $file, 'decode json');
is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
@@ -99,7 +99,7 @@
ok($bf->process($path => $output), 'Process file');
ok(-f $output, 'File exists');
-ok($file = slurp $output, 'Slurp data');
+ok($file = Mojo::File->new($output)->slurp, 'Slurp data');
ok($json = decode_json $file, 'decode json');
ok(!$json->{data}->{text}, 'No Primary text');
@@ -111,7 +111,7 @@
$bf->{pretty} = 1;
ok($bf->process($path => $output), 'Process file');
ok(-f $output, 'File exists');
-ok($file = slurp $output, 'Slurp data');
+ok($file = Mojo::File->new($output)->slurp, 'Slurp data');
like($file, qr/^\{[\n\s]+"/, 'No pretty printing');
# Check overwriting
diff --git a/t/meta.t b/t/meta.t
index a775cbd..54d5ce8 100644
--- a/t/meta.t
+++ b/t/meta.t
@@ -4,6 +4,7 @@
use Test::More;
use Benchmark ':hireswallclock';
use Mojo::DOM;
+use Mojo::File;
use Mojo::ByteStream 'b';
use Data::Dumper;
use lib 'lib', '../lib';
@@ -392,7 +393,7 @@
$path = catdir(dirname(__FILE__), 'corpus', 'I5', 'rei-example.i5');
ok($meta = KorAP::XML::Meta::I5->new, 'Construct meta object');
-my $dom = Mojo::DOM->new->parse(b($path)->slurp);
+my $dom = Mojo::DOM->new->parse(Mojo::File->new($path)->slurp);
ok($meta->parse($dom->at('idsHeader'), 'corpus'), 'Parse corpus header');
my $hash = $meta->to_hash;
diff --git a/t/script/archive.t b/t/script/archive.t
index a0b4dd6..be959a2 100644
--- a/t/script/archive.t
+++ b/t/script/archive.t
@@ -4,7 +4,7 @@
use File::Basename 'dirname';
use File::Spec::Functions qw/catdir catfile/;
use File::Temp qw/tempdir/;
-use Mojo::Util qw/slurp/;
+use Mojo::File;
use Mojo::JSON qw/decode_json/;
use IO::Uncompress::Gunzip;
use Test::More;
@@ -66,7 +66,7 @@
};
ok(-f $json, 'Json file exists');
-ok((my $file = slurp $json), 'Slurp data');
+ok((my $file = Mojo::File->new($json)->slurp), 'Slurp data');
ok(($json = decode_json $file), 'decode json');
is($json->{data}->{tokenSource}, 'base#tokens_aggr', 'Title');
@@ -111,7 +111,7 @@
my $json_2 = catfile($output, 'corpus-doc-0002.json');
ok(-f $json_2, 'Json file exists 2');
- ok(($file = slurp $json_1), 'Slurp data');
+ ok(($file = Mojo::File->new($json_1)->slurp), 'Slurp data');
ok(($json_1 = decode_json $file), 'decode json');
is($json_1->{data}->{tokenSource}, 'tree_tagger#tokens', 'TokenSource');
@@ -119,7 +119,7 @@
is($json_1->{textSigle}, 'Corpus/Doc/0001', 'Sigle');
ok(-f $json_2, 'Json file exists');
- ok(($file = slurp $json_2), 'Slurp data');
+ ok(($file = Mojo::File->new($json_2)->slurp), 'Slurp data');
ok(($json_2 = decode_json $file), 'decode json');
is($json_2->{data}->{tokenSource}, 'tree_tagger#tokens', 'TokenSource');
diff --git a/t/script/base.t b/t/script/base.t
index bd2d8e5..252404b 100644
--- a/t/script/base.t
+++ b/t/script/base.t
@@ -4,7 +4,7 @@
use File::Basename 'dirname';
use File::Spec::Functions qw/catdir catfile/;
use File::Temp qw/ :POSIX /;
-use Mojo::Util qw/slurp/;
+use Mojo::File;
use Mojo::JSON qw/decode_json/;
use IO::Uncompress::Gunzip;
use Test::More;
@@ -43,7 +43,7 @@
);
ok(-f $output, 'Output does exist');
-ok((my $file = slurp $output), 'Slurp data');
+ok((my $file = Mojo::File->new($output)->slurp), 'Slurp data');
ok((my $json = decode_json $file), 'decode json');
is($json->{textType}, 'Autobiographie', 'text type');
is($json->{title}, 'Autobiographische Einzelheiten', 'Title');
diff --git a/t/script/single.t b/t/script/single.t
index 40b7940..486e1b6 100644
--- a/t/script/single.t
+++ b/t/script/single.t
@@ -4,7 +4,7 @@
use File::Basename 'dirname';
use File::Spec::Functions qw/catdir catfile/;
use File::Temp qw/ :POSIX /;
-use Mojo::Util qw/slurp/;
+use Mojo::File;
use Mojo::JSON qw/decode_json/;
use IO::Uncompress::Gunzip;
use Test::More;
@@ -41,7 +41,7 @@
);
ok(-f $output, 'Output does exist');
-ok((my $file = slurp $output), 'Slurp data');
+ok((my $file = Mojo::File->new($output)->slurp), 'Slurp data');
ok((my $json = decode_json $file), 'decode json');
is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
is($json->{title}, 'Beispiel Text', 'Title');
@@ -110,7 +110,7 @@
);
ok(-f $output, 'Output does exist');
-ok(($file = slurp $output), 'Slurp data');
+ok(($file = Mojo::File->new($output)->slurp), 'Slurp data');
ok(($json = decode_json $file), 'decode json');
is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
@@ -184,7 +184,7 @@
);
ok(-f $output, 'Output does exist');
-ok(($file = slurp $output), 'Slurp data');
+ok(($file = Mojo::File->new($output)->slurp), 'Slurp data');
ok(($json = decode_json $file), 'decode json');
is($json->{data}->{text}, 'Selbst ist der Jeck', 'Text');