Client/BuildResults.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« Client.pm ↑ Summary Client/Package.pm »
1 # Copyright (c) 2015 SUSE LLC
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2 as
5 # published by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program (see the file COPYING); if not, write to the
14 # Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
16 #
17 package Net::OBS::Client::BuildResults;
18  
19 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Net::OBS::Client;
Subroutine BEGIN: called CC=1 SCAR=2.6
21 use Net::OBS::Client::DTD;
22 use XML::Structured;
23 use Data::Dumper;
24  
25 with 'Net::OBS::Client::Roles::Client';
26  
27 =head1 NAME
28  
29 Net::OBS::Client::BuildResults - fetch binarylist and fileinfo
30  
31 =head1 SYNOPSIS
32  
33 use Net::OBS::Client::BuildResults;
34  
35 my $obj = Net::OBS::Client::BuildResults->new(
36 apiurl => $apiurl,
37 project => $project,
38 package => $package,
39 repository => $repo,
40 arch => $arch,
41 );
42  
43 my $bin = $obj->binarylist;
44  
45 my $inf = $obj->fileinfo($filename);
46  
47  
48 =head1 ATTRIBUTES
49  
50  
51 =head2 project
52  
53  
54 =head2 package
55  
56  
57 =head2 repository
58  
59  
60 =head2 arch
61  
62  
63 =cut
64  
65 has project => (
66 is => 'rw',
67 isa => 'Str',
68 );
69  
70 has repository => (
71 is => 'rw',
72 isa => 'Str',
73 );
74  
75 has arch => (
76 is => 'rw',
77 isa => 'Str',
78 );
79  
80 has package => (
81 is => 'rw',
82 isa => 'Str',
83 );
84  
85 =head1 SUBROUTINES/METHODS
86  
87 =head2 binarylist - fetch list of binary buildresults
88  
89 my $bin = $obj->binarylist();
90  
91 =cut
92  
93 sub binarylist {
94 my ($self) = @_;
95  
96 my $api_path = '/build/'
97 . join
98 q{/},
99 $self->project,
100 $self->repository,
101 $self->arch,
102 $self->package,
103 ;
104  
105 my $binarylist = $self->request(GET=>$api_path);
106  
107 my $dtd = Net::OBS::Client::DTD->new()->binarylist();
108  
109 return XMLin($dtd, $binarylist)->{binary};
110 }
111  
112 =head2 fileinfo - get detailed information about a specific package
113  
114 my $bin = $obj->fileinfo($filename);
115  
116 =cut
117  
118 sub fileinfo {
119 my ($self, $binary) = @_;
120  
121 # /build/OBS:Server:Unstable/images/x86_64/OBS-Appliance-qcow2/obs-server.x86_64-2.5.51-Build6.4.qcow2?view=fileinfo
122 #
123 my $api_path = '/build/'
124 . join
125 q{/},
126 $self->project,
127 $self->repository,
128 $self->arch,
129 $self->package,
130 $binary,
131 ;
132 $api_path .= '?view=fileinfo';
133  
134 my $binarylist = $self->request(GET=>$api_path);
135  
136 my $dtd = Net::OBS::Client::DTD->new()->fileinfo();
137  
138 return XMLin($dtd, $binarylist);
139 }
140  
141 __PACKAGE__->meta->make_immutable();
142  
143 =head1 AUTHOR
144  
145 Frank Schreiner, C<< <frank at samaxi.de> >>
146  
147 =head1 SEE ALSO
148  
149 You can find some examples in the L<contrib/> directory
150  
151  
152 =head1 COPYRIGHT
153  
154 Copyright 2016 Frank Schreiner <frank@samaxi.de>
155  
156 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
157  
158 =cut
159  
160 1;
« Client.pm ↑ Summary Client/Package.pm »