[libcatmandu-perl] 25/30: tidy
Jonas Smedegaard
dr at jones.dk
Tue Dec 19 11:10:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/1.0700-1
in repository libcatmandu-perl.
commit 26cb2f916ffcb3586ce4ed1ab8311a237c43ad00
Author: Nicolas Steenlant <nicolas.steenlant at ugent.be>
Date: Thu Nov 9 10:03:45 2017 +0100
tidy
---
Build.PL | 2 +-
lib/Catmandu/FileBag.pm | 4 +++-
lib/Catmandu/FileStore.pm | 10 ++++++----
lib/Catmandu/Importer/DKVP.pm | 8 ++++----
lib/Catmandu/Plugin/Readonly.pm | 16 +++++++++-------
lib/Catmandu/Store.pm | 2 +-
lib/Catmandu/Store/File/Multi/Bag.pm | 19 +++++++++++++------
lib/Catmandu/Store/File/Simple/Bag.pm | 8 +++++---
t/Catmandu-FileStore.t | 28 +++++++++++++++-------------
t/Catmandu-Plugin-Readonly.t | 18 +++++++++---------
t/Catmandu-Store-File-Memory-Bag.t | 6 +++---
t/Catmandu-Store-File-Memory.t | 2 +-
t/Catmandu-Store-File-Multi-Bag.t | 27 +++++++++++++++++----------
t/Catmandu-Store-File-Multi-Index.t | 5 ++---
t/Catmandu-Store-File-Simple-Bag.t | 24 +++++++++++++++---------
t/Catmandu-Store.t | 8 ++++----
16 files changed, 108 insertions(+), 79 deletions(-)
diff --git a/Build.PL b/Build.PL
index 8828940..ccd0099 100644
--- a/Build.PL
+++ b/Build.PL
@@ -18,7 +18,7 @@ my %module_build_args = (
"Nicolas Steenlant, C<< <nicolas.steenlant at ugent.be> >>"
],
"dist_name" => "Catmandu",
- "dist_version" => "1.0606",
+ "dist_version" => "1.07",
"license" => "perl",
"module_name" => "Catmandu",
"recommends" => {
diff --git a/lib/Catmandu/FileBag.pm b/lib/Catmandu/FileBag.pm
index 3bead5f..d7ff1c4 100644
--- a/lib/Catmandu/FileBag.pm
+++ b/lib/Catmandu/FileBag.pm
@@ -47,10 +47,12 @@ sub upload {
# file metadata. Use a get($id) when this inline update wasn't implemented
# by the Bag.
if (exists $file->{size}) {
+
# all ok
}
else {
- $self->log->warn("$self doesn't inline update \$data in add(\$data) method");
+ $self->log->warn(
+ "$self doesn't inline update \$data in add(\$data) method");
$file = $self->get($id);
}
diff --git a/lib/Catmandu/FileStore.pm b/lib/Catmandu/FileStore.pm
index 6c039f2..1217d73 100644
--- a/lib/Catmandu/FileStore.pm
+++ b/lib/Catmandu/FileStore.pm
@@ -19,11 +19,11 @@ sub _build_default_bag {
sub _build_index {
my ($self) = @_;
- my $name = $self->index_bag;
+ my $name = $self->index_bag;
my $inst;
try {
- my $opts = { store => $self , name => $name };
+ my $opts = {store => $self, name => $name};
my $default_opts = $self->default_options;
my $bag_opts = $self->bag_options->{$name} //= {};
$opts = {%$default_opts, %$bag_opts, %$opts};
@@ -57,13 +57,15 @@ sub bag {
if ($name eq $index_name) {
$self->index;
}
+
# Otherwise load the container for files
elsif ($self->index->exists($name)) {
- my $opts = { store => $self , name => $name };
+ my $opts = {store => $self, name => $name};
my $default_opts = $self->default_options;
my $bag_opts = $self->bag_options->{$name} //= {};
$opts = {%$default_opts, %$bag_opts, %$opts};
- my $pkg = Catmandu::Util::require_package(delete($opts->{class}) // $self->bag_class);
+ my $pkg = Catmandu::Util::require_package(delete($opts->{class})
+ // $self->bag_class);
my $default_plugins = $self->default_plugins;
my $plugins = delete($opts->{plugins}) // [];
diff --git a/lib/Catmandu/Importer/DKVP.pm b/lib/Catmandu/Importer/DKVP.pm
index 3abe2a6..1cda861 100644
--- a/lib/Catmandu/Importer/DKVP.pm
+++ b/lib/Catmandu/Importer/DKVP.pm
@@ -10,12 +10,12 @@ use namespace::clean;
with 'Catmandu::Importer';
has pair_sep_char => (is => 'ro', default => sub {'='});
-has sep_char => (is => 'ro', default => sub {','});
-has _re => (is => 'lazy');
+has sep_char => (is => 'ro', default => sub {','});
+has _re => (is => 'lazy');
sub _build__re {
- my ($self) = @_;
- my $sep_char = $self->sep_char;
+ my ($self) = @_;
+ my $sep_char = $self->sep_char;
my $pair_sep_char = $self->pair_sep_char;
qr/([^$pair_sep_char]+)$pair_sep_char([^$sep_char]+)(?:$sep_char|$)/;
}
diff --git a/lib/Catmandu/Plugin/Readonly.pm b/lib/Catmandu/Plugin/Readonly.pm
index 6eb0299..8288951 100644
--- a/lib/Catmandu/Plugin/Readonly.pm
+++ b/lib/Catmandu/Plugin/Readonly.pm
@@ -9,9 +9,10 @@ use namespace::clean;
sub BUILD {
my ($self) = @_;
- my $name = ref($self->store);
+ my $name = ref($self->store);
if ($self->store->does('Catmandu::Droppable')) {
+
# Overwrite the drop method of the Catmandu::Store implementation
my $stash = Package::Stash->new($name);
$stash->add_symbol(
@@ -19,12 +20,13 @@ sub BUILD {
$self->log->warn("trying to drop a readonly store");
my $err = Catmandu::NotImplemented->new("$name is readonly");
return undef, $err;
- });
+ }
+ );
}
-};
+}
around add => sub {
- my ($orig,$self,$data) = @_;
+ my ($orig, $self, $data) = @_;
my $name = ref($self);
$self->log->warn("trying to add to readonly store");
my $err = Catmandu::NotImplemented->new("$name is readonly");
@@ -32,7 +34,7 @@ around add => sub {
};
around delete => sub {
- my ($orig,$self) = @_;
+ my ($orig, $self) = @_;
my $name = ref($self);
$self->log->warn("trying to delete from readonly store");
my $err = Catmandu::NotImplemented->new("$name is readonly");
@@ -40,7 +42,7 @@ around delete => sub {
};
around delete_all => sub {
- my ($orig,$self) = @_;
+ my ($orig, $self) = @_;
my $name = ref($self);
$self->log->warn("trying to delete_all on readonly store");
my $err = Catmandu::NotImplemented->new("$name is readonly");
@@ -48,7 +50,7 @@ around delete_all => sub {
};
around drop => sub {
- my ($orig,$self) = @_;
+ my ($orig, $self) = @_;
my $name = ref($self);
$self->log->warn("trying to drop a readonly store");
my $err = Catmandu::NotImplemented->new("$name is readonly");
diff --git a/lib/Catmandu/Store.pm b/lib/Catmandu/Store.pm
index b1c06e2..a5e7abb 100644
--- a/lib/Catmandu/Store.pm
+++ b/lib/Catmandu/Store.pm
@@ -14,7 +14,7 @@ with 'Catmandu::Logger';
has bag_class => (is => 'ro', default => sub {ref($_[0]) . '::Bag'},);
-has default_bag => (is => 'lazy');
+has default_bag => (is => 'lazy');
has default_plugins => (is => 'ro', default => sub {[]},);
has default_options => (is => 'ro', default => sub {+{}},);
has bag_options => (is => 'ro', init_arg => 'bags', default => sub {+{}},);
diff --git a/lib/Catmandu/Store/File/Multi/Bag.pm b/lib/Catmandu/Store/File/Multi/Bag.pm
index 75b0d1e..0ac899f 100644
--- a/lib/Catmandu/Store/File/Multi/Bag.pm
+++ b/lib/Catmandu/Store/File/Multi/Bag.pm
@@ -30,13 +30,14 @@ sub add {
next unless $bag;
if ($rewind) {
+
# Rewind the stream after first use...
Catmandu::BadVal->throw("IO stream needs to seekable")
unless $stream->isa('IO::Seekable');
$stream->seek(0, 0);
}
- my $file = {_id => $id , _stream => $stream};
+ my $file = {_id => $id, _stream => $stream};
$bag->add($file);
for (keys %$file) {
@@ -49,12 +50,15 @@ sub add {
# Check if the returned record contains the minimum required fields
# (otherwise we have a File::Store implementation that doesn't inline
# update the passed $data in add($data))
- if (exists $new_data->{size} && exists $new_data->{created} &&
- exists $new_data->{modified}) {
+ if ( exists $new_data->{size}
+ && exists $new_data->{created}
+ && exists $new_data->{modified})
+ {
# all is ok
}
else {
- $self->log->warn("$self doesn't inline update \$data in add(\$data) method");
+ $self->log->warn(
+ "$self doesn't inline update \$data in add(\$data) method");
$new_data = $self->get($id);
}
@@ -83,13 +87,16 @@ sub upload {
my $bag = $store->bag($self->name);
next unless $bag;
if ($rewind) {
+
# Rewind the stream after first use...
Catmandu::BadVal->throw("IO stream needs to seekable")
unless $io->isa('IO::Seekable');
$io->seek(0, 0);
}
- $bytes = $store->bag($self->name)->upload($io, $id) ||
- $self->log->error("failed to upload $id to " . $self->name);
+ $bytes
+ = $store->bag($self->name)->upload($io, $id)
+ || $self->log->error(
+ "failed to upload $id to " . $self->name);
$rewind = 1;
}
else {
diff --git a/lib/Catmandu/Store/File/Simple/Bag.pm b/lib/Catmandu/Store/File/Simple/Bag.pm
index 8cb4650..fe8b966 100644
--- a/lib/Catmandu/Store/File/Simple/Bag.pm
+++ b/lib/Catmandu/Store/File/Simple/Bag.pm
@@ -119,16 +119,18 @@ sub add {
my $file = File::Spec->catfile($path, $packed_key);
if (Catmandu::Util::is_invocant($io)) {
- copy($io, $file) || Catmandu::Error->throw("failed to write file : $!");
+ copy($io, $file)
+ || Catmandu::Error->throw("failed to write file : $!");
}
else {
- Catmandu::Util::write_file($file, $io) || Catmandu::Error->throw("failed to write file : $!");
+ Catmandu::Util::write_file($file, $io)
+ || Catmandu::Error->throw("failed to write file : $!");
}
my $new_data = $self->get($id);
$data->{$_} = $new_data->{$_} for keys %$new_data;
-
+
1;
}
diff --git a/t/Catmandu-FileStore.t b/t/Catmandu-FileStore.t
index 39e4a00..a6ccfe9 100644
--- a/t/Catmandu-FileStore.t
+++ b/t/Catmandu-FileStore.t
@@ -14,6 +14,7 @@ BEGIN {
require_ok $pkg;
{
+
package T::Store;
use Moo;
with $pkg;
@@ -59,12 +60,15 @@ can_ok $s, 'bag_class';
can_ok $s, 'default_bag';
can_ok $s, 'bag';
can_ok $s, 'index';
-is $s->bag_class, 'T::Store::Bag';
+is $s->bag_class, 'T::Store::Bag';
is $s->default_bag, 'index';
note("create a custom store");
-$s = T::Store->new(bag_class => 'T::CustomBagClass', index_class => 'T::CustomIndexClass');
-is $s->bag_class, 'T::CustomBagClass';
+$s = T::Store->new(
+ bag_class => 'T::CustomBagClass',
+ index_class => 'T::CustomIndexClass'
+);
+is $s->bag_class, 'T::CustomBagClass';
is $s->index_class, 'T::CustomIndexClass';
my $b = $s->bag;
@@ -73,35 +77,34 @@ is $s->bag, $b;
is $b->store, $s;
is $b->name, 'index';
-ok ! $s->bag('foo') , 'unkown bag';
+ok !$s->bag('foo'), 'unkown bag';
note("options");
$s = T::Store->new(
- index_class => 'T::CustomIndexClass' ,
- bags => {index => {prop => 'val', store => 'junk', name => 'junk'}}
+ index_class => 'T::CustomIndexClass',
+ bags => {index => {prop => 'val', store => 'junk', name => 'junk'}}
);
-is $s->index->prop, 'val', "options are passed to bag";
+is $s->index->prop, 'val', "options are passed to bag";
isnt $s->index->store, 'junk', "store can't be overriden";
isnt $s->index->name, 'junk', "name can't be overriden";
note("default options");
$s = T::Store->new(
- index_class => 'T::CustomIndexClass' ,
+ index_class => 'T::CustomIndexClass',
default_options => {prop => 'bar'},
bags => {index => {store => 'junk', name => 'junk'}}
);
is $s->index->prop, 'bar';
$s = T::Store->new(
- index_class => 'T::CustomIndexClass' ,
+ index_class => 'T::CustomIndexClass',
default_options => {prop => 'bar'},
- bags => {index => {prop => 'baz', store => 'junk', name => 'junk'}}
+ bags => {index => {prop => 'baz', store => 'junk', name => 'junk'}}
);
is $s->index->prop, 'baz';
note("plugins");
-$b = T::Store->new(bags => {index => {plugins => [qw(Datestamps)]}})
- ->index;
+$b = T::Store->new(bags => {index => {plugins => [qw(Datestamps)]}})->index;
ok $b->does('Catmandu::Plugin::Datestamps'), 'apply plugins';
$b = T::Store->new(default_plugins => [qw(Datestamps)])->index;
@@ -114,5 +117,4 @@ $b = T::Store->new(
ok $b->does('Catmandu::Plugin::Datestamps')
&& $b->does('Catmandu::Plugin::Versioning'), 'prepend default plugins';
-
done_testing();
diff --git a/t/Catmandu-Plugin-Readonly.t b/t/Catmandu-Plugin-Readonly.t
index 8ad13ed..3c9f7cc 100644
--- a/t/Catmandu-Plugin-Readonly.t
+++ b/t/Catmandu-Plugin-Readonly.t
@@ -22,24 +22,24 @@ my $store = Catmandu::Store::Hash->new(
ok $store->does('Catmandu::Store'),
'create Catmandu-Store with Readonly plugin';
-my ($ret,$err) = $store->bag->add({_id => '001', name => 'Penguin'});
+my ($ret, $err) = $store->bag->add({_id => '001', name => 'Penguin'});
-ok !defined($ret) , 'add returned undef';
+ok !defined($ret), 'add returned undef';
isa_ok $err, 'Catmandu::NotImplemented';
-($ret,$err) = $store->bag->get('001');
+($ret, $err) = $store->bag->get('001');
-ok !defined($ret) , 'get returned undef';
-ok !defined($err) , 'no error thrown';
+ok !defined($ret), 'get returned undef';
+ok !defined($err), 'no error thrown';
-($ret,$err) = $store->bag->delete('001');
+($ret, $err) = $store->bag->delete('001');
-ok !defined($ret) , 'delete returned undef';
+ok !defined($ret), 'delete returned undef';
isa_ok $err, 'Catmandu::NotImplemented';
-($ret,$err) = $store->drop;
+($ret, $err) = $store->drop;
-ok !defined($ret) , 'drop returned undef';
+ok !defined($ret), 'drop returned undef';
isa_ok $err, 'Catmandu::NotImplemented';
done_testing;
diff --git a/t/Catmandu-Store-File-Memory-Bag.t b/t/Catmandu-Store-File-Memory-Bag.t
index 0551268..1df93ad 100644
--- a/t/Catmandu-Store-File-Memory-Bag.t
+++ b/t/Catmandu-Store-File-Memory-Bag.t
@@ -35,19 +35,19 @@ note("add");
ok $n1 , 'upload test1.txt';
- is $n1 , 16 , '16 bytes';
+ is $n1 , 16, '16 bytes';
my $n2 = $bag->upload(io('t/data2/000/000/002/test.txt'), 'test2.txt');
ok $n2 , 'upload test2.txt';
- is $n2 , 6 , '6 bytes';
+ is $n2 , 6, '6 bytes';
my $n3 = $bag->upload(io('t/data2/000/000/003/test.txt'), 'test3.txt');
ok $n3 , 'upload test3.txt';
- is $n3 , 6 , '6 bytes';
+ is $n3 , 6, '6 bytes';
}
note("list");
diff --git a/t/Catmandu-Store-File-Memory.t b/t/Catmandu-Store-File-Memory.t
index da5a78c..e545095 100644
--- a/t/Catmandu-Store-File-Memory.t
+++ b/t/Catmandu-Store-File-Memory.t
@@ -27,7 +27,7 @@ ok $bags , 'create memory store';
ok $bags->add({_id => '1234'}), 'adding `1234` bag';
-ok ! $store->bag('1235') , 'bag(1235) doesnt exist';
+ok !$store->bag('1235'), 'bag(1235) doesnt exist';
lives_ok {$store->bag('1234')} 'bag(1234) exists';
diff --git a/t/Catmandu-Store-File-Multi-Bag.t b/t/Catmandu-Store-File-Multi-Bag.t
index 0ef7a41..8d4c59a 100644
--- a/t/Catmandu-Store-File-Multi-Bag.t
+++ b/t/Catmandu-Store-File-Multi-Bag.t
@@ -35,41 +35,47 @@ ok $bag , 'got bag(1234)';
note("add");
{
- my $n1 = $bag->upload(IO::File->new('t/data2/000/000/001/test.txt'),'test1.txt');
+ my $n1 = $bag->upload(IO::File->new('t/data2/000/000/001/test.txt'),
+ 'test1.txt');
ok $n1 , 'upload test1.txt';
- is $n1 , 16 , '16 bytes';
+ is $n1 , 16, '16 bytes';
ok -f 't/data/000/001/234/test1.txt', 'test1.txt exists';
ok -f 't/data3/000/001/234/test1.txt', 'test1.txt exists';
- my $n2 = $bag->upload(IO::File->new('t/data2/000/000/002/test.txt'), 'test2.txt');
+ my $n2 = $bag->upload(IO::File->new('t/data2/000/000/002/test.txt'),
+ 'test2.txt');
ok $n2 , 'upload test2.txt';
- is $n2 , 6 , '6 bytes';
+ is $n2 , 6, '6 bytes';
ok -f 't/data/000/001/234/test2.txt', 'test2.txt exists';
ok -f 't/data3/000/001/234/test2.txt', 'test1.txt exists';
- my $n3 = $bag->upload(IO::File->new('t/data2/000/000/003/test.txt'),'test3.txt');
+ my $n3 = $bag->upload(IO::File->new('t/data2/000/000/003/test.txt'),
+ 'test3.txt');
ok $n3 , 'upload test3.txt';
- is $n3 , 6 , '6 bytes';
+ is $n3 , 6, '6 bytes';
ok -f 't/data/000/001/234/test3.txt', 'test3.txt exists';
ok -f 't/data3/000/001/234/test3.txt', 'test1.txt exists';
- my $data = { _id => 'test4.txt' , _stream => IO::File->new('t/data2/000/000/003/test.txt') };
+ my $data = {
+ _id => 'test4.txt',
+ _stream => IO::File->new('t/data2/000/000/003/test.txt')
+ };
- ok $bag->add($data) , 'add({ ..test4.. })';
+ ok $bag->add($data), 'add({ ..test4.. })';
- is $data->{size} , 6 , '$data->{size}';
+ is $data->{size}, 6, '$data->{size}';
}
note("list");
@@ -112,7 +118,8 @@ note("delete");
ok $array , 'list got a response';
- is_deeply $array , [qw(test2.txt test3.txt test4.txt)], 'got correct response';
+ is_deeply $array , [qw(test2.txt test3.txt test4.txt)],
+ 'got correct response';
}
note("...delete_all (index)");
diff --git a/t/Catmandu-Store-File-Multi-Index.t b/t/Catmandu-Store-File-Multi-Index.t
index abce12d..14b3859 100644
--- a/t/Catmandu-Store-File-Multi-Index.t
+++ b/t/Catmandu-Store-File-Multi-Index.t
@@ -15,9 +15,8 @@ BEGIN {
require_ok $pkg;
-my $stores = [
- Catmandu::Store::File::Simple->new(root => 't/data2', keysize => 9),
-];
+my $stores
+ = [Catmandu::Store::File::Simple->new(root => 't/data2', keysize => 9),];
my $store = Catmandu::Store::File::Multi->new(stores => $stores);
my $index;
diff --git a/t/Catmandu-Store-File-Simple-Bag.t b/t/Catmandu-Store-File-Simple-Bag.t
index 14a91aa..186dc0b 100644
--- a/t/Catmandu-Store-File-Simple-Bag.t
+++ b/t/Catmandu-Store-File-Simple-Bag.t
@@ -31,35 +31,41 @@ ok $bag , 'got bag(1234)';
note("add");
{
- my $n1 = $bag->upload(IO::File->new('t/data2/000/000/001/test.txt'),'test1.txt');
+ my $n1 = $bag->upload(IO::File->new('t/data2/000/000/001/test.txt'),
+ 'test1.txt');
ok $n1 , 'upload test1.txt';
- is $n1 , 16 , '16 bytes';
+ is $n1 , 16, '16 bytes';
ok -f 't/data/000/001/234/test1.txt', 'test1.txt exists';
- my $n2 = $bag->upload(IO::File->new('t/data2/000/000/002/test.txt'), 'test2.txt');
+ my $n2 = $bag->upload(IO::File->new('t/data2/000/000/002/test.txt'),
+ 'test2.txt');
ok $n2 , 'upload test2.txt';
- is $n2 , 6 , '6 bytes';
+ is $n2 , 6, '6 bytes';
ok -f 't/data/000/001/234/test2.txt', 'test2.txt exists';
- my $n3 = $bag->upload(IO::File->new('t/data2/000/000/003/test.txt'),'test3.txt');
+ my $n3 = $bag->upload(IO::File->new('t/data2/000/000/003/test.txt'),
+ 'test3.txt');
ok $n3 , 'upload test3.txt';
- is $n3 , 6 , '6 bytes';
+ is $n3 , 6, '6 bytes';
ok -f 't/data/000/001/234/test3.txt', 'test3.txt exists';
- my $data = { _id => 'test3.txt' , _stream => IO::File->new('t/data2/000/000/003/test.txt') };
+ my $data = {
+ _id => 'test3.txt',
+ _stream => IO::File->new('t/data2/000/000/003/test.txt')
+ };
- ok $bag->add($data) , 'add({ ..test3.. })';
+ ok $bag->add($data), 'add({ ..test3.. })';
- is $data->{size} , 6 , '$data->{size}';
+ is $data->{size}, 6, '$data->{size}';
}
note("list");
diff --git a/t/Catmandu-Store.t b/t/Catmandu-Store.t
index b66a7c7..f022b43 100644
--- a/t/Catmandu-Store.t
+++ b/t/Catmandu-Store.t
@@ -66,16 +66,16 @@ isnt $s->bag('foo')->name, 'junk', "name can't be overriden";
# default options
$s = T::Store->new(
- bag_class => 'T::CustomBagClass',
+ bag_class => 'T::CustomBagClass',
default_options => {prop => 'bar'},
- bags => {foo => {store => 'junk', name => 'junk'}}
+ bags => {foo => {store => 'junk', name => 'junk'}}
);
is $s->bag('foo')->prop, 'bar';
$s = T::Store->new(
- bag_class => 'T::CustomBagClass',
+ bag_class => 'T::CustomBagClass',
default_options => {prop => 'bar'},
- bags => {foo => {prop => 'baz', store => 'junk', name => 'junk'}}
+ bags => {foo => {prop => 'baz', store => 'junk', name => 'junk'}}
);
is $s->bag('foo')->prop, 'baz';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git
More information about the Pkg-perl-cvs-commits
mailing list