blib/lib/App/Kramerius/URI.pm

filter: Statementstmt 100% 31 / 31 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 90.3% 47 / 52 CC 5 SCAR 11.1
CC
5
Cov
93%
run
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
↑ Summary
1 package App::Kramerius::URI;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Data::Kramerius;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Getopt::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = 0.03;
10  
11 # Constructor.
12 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
13 3 my ($class, @params) = @_;
14  
15 # Create object.
16 3 my $self = bless {}, $class;
17  
18 # Load data.
19 3 $self->{'kramerius'} = Data::Kramerius->new;
20  
21 # Object.
22 3 return $self;
23 }
24  
25 # Run.
26 2 ▶sub run {
Subroutine run: called CC=5 SCAR=16.2
Pod documented
27 2 my $self = shift;
28  
29 # Process arguments.
30 2 $self->{'_opts'} = {
31 'h' => 0,
32 };
33 2 ▶ if (! getopts('h', $self->{'_opts'}) || @ARGV < 1
Branch: 1 branch
BranchTrueFalseTotal
if (not &getopts("h", $self->{"_opts"}) or @ARGV < 1 or $self->{"_opts"}{"h"}) 1 1 2
Condition66%4/6
not &getopts("h", $self->{"_opts"}) or @ARGV < 1 or $self->{"_opts"}{"h"}
l!l&&r!l&&!r
101
not &getopts("h", $self->{"_opts"}) or @ARGV < 1
l!l&&r!l&&!r
011
MC/DC33%1/3
not &getopts("h", $self->{"_opts"}) or @ARGV < 1 or $self->{"_opts"}{"h"}
not &getopts("h", $self->{"_opts"}) @ARGV < 1 $self->{"_opts"}{"h"}
Truth table50%2/4
not(A) or B or C
A= not &getopts("h", $self->{"_opts"})B= @ARGV < 1C= $self->{"_opts"}{"h"}
ABCresult
1XX1
01X1
0011
0000
34 || $self->{'_opts'}->{'h'}) {
35  
36 1 print STDERR "Usage: $0 [-h] [--version] kramerius_id\n";
37 1 print STDERR "\t-h\t\tHelp.\n";
38 1 print STDERR "\t--version\tPrint version.\n";
39 1 print STDERR "\tkramerius_id\tKramerius system id. e.g. ".
40 "mzk\n";
41 1 return 1;
42 }
43 1 my $kramerius_id = shift @ARGV;
44  
45 1 my $kramerius_obj = $self->{'kramerius'}->get($kramerius_id);
46  
47 # Print URL.
48 1 ▶ if (defined $kramerius_obj) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $kramerius_obj) 1 0 1
49 1 print $kramerius_obj->url.' '.$kramerius_obj->version."\n";
50 }
51  
52 1 return 0;
53 }
54  
55 4 1;
56  
57 =pod
58  
59 =encoding utf8
60  
61 =head1 NAME
62  
63 App::Kramerius::URI - Base class for kramerius-uri script.
64  
65 =head1 SYNOPSIS
66  
67 use App::Kramerius::URI;
68  
69 my $app = App::Kramerius::URI->new;
70 my $exit_code = $app->run;
71  
72 =head1 METHODS
73  
74 =head2 C<new>
75  
76 my $app = App::Kramerius::URI->new;
77  
78 Constructor.
79  
80 Returns instance of object.
81  
82 =head2 C<run>
83  
84 my $exit_code = $app->run;
85  
86 Run.
87  
88 Returns 1 for error, 0 for success.
89  
90 =head1 EXAMPLE
91  
92 use strict;
93 use warnings;
94  
95 use App::Kramerius::URI;
96  
97 # Arguments.
98 @ARGV = (
99 'mzk',
100 );
101  
102 # Run.
103 exit App::Kramerius::URI->new->run;
104  
105 # Output like:
106 # http://kramerius.mzk.cz/ 4
107  
108 =head1 DEPENDENCIES
109  
110 L<Data::Kramerius>,
111 L<Getopt::Std>.
112  
113 =head1 REPOSITORY
114  
115 L<https://github.com/michal-josef-spacek/App-Kramerius-URI>
116  
117 =head1 AUTHOR
118  
119 Michal Josef Špaček L<mailto:skim@cpan.org>
120  
121 L<http://skim.cz>
122  
123 =head1 LICENSE AND COPYRIGHT
124  
125 © 2021 Michal Josef Špaček
126  
127 BSD 2-Clause License
128  
129 =head1 VERSION
130  
131 0.03
132  
133 =cut
↑ Summary