blib/lib/Software/Catalog/SW/bulwark/qt.pm

filter: Statementstmt 25.3% 17 / 67 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 40.0% 6 / 15 Podpod n/a totaltotal 20.0% 23 / 115 CC 14 SCAR 26.5
CC
14
Cov
18%
download_url
30.0
release_note
30.0
archive_info
12.0
CRAP 14.2
↑ Summary
1 package Software::Catalog::SW::bulwark::qt;
2  
3 our $DATE = '2020-10-02'; # DATE
4 our $VERSION = '0.008'; # VERSION
5  
6 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use PerlX::Maybe;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 with 'Versioning::Scheme::Dotted';
14 with 'Software::Catalog::Role::Software';
15  
16 1 ▶use Software::Catalog::Util qw(extract_from_url);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 0 ▶sub archive_info {
Subroutine archive_info: not called CC=3 SCAR=24.8
19 0 my ($self, %args) = @_;
20  
21 0 ▶ my $v = $args{version} // latest_version()->[2];
Condition0%0/3
$args{"version"} // latest_version()->[2]
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"version"} // latest_version()->[2]
$args{"version"} latest_version()->[2]
Truth table0%0/3
A // B
A= $args{"version"}B= latest_version()->[2]
ABresult
1X1
011
000
22  
23 0 ▶ [200, "OK", {
Branch: 1 branch
BranchTrueFalseTotal
$self->cmp_version($v, '2.0.0.0') == -1 ? : 0 0 0
24 programs => [
25 {name=>"bulwark-cli", path=>"/"},
26 {name=>"bulwark-qt", path=>"/"},
27 {name=>"bulwarkd", path=>"/"},
28 ],
29 unwrap => $self->cmp_version($v, '2.0.0.0') == -1 ? 1:0,
30 }];
31 }
32  
33 0 ▶sub available_versions {
Subroutine available_versions: not called CC=2 SCAR=17.9
34 0 my ($self, %args) = @_;
35  
36 0 my $res = extract_from_url(
37 url => "https://github.com/bulwark-crypto/Bulwark/releases",
38 re => qr!/bulwark-crypto/Bulwark/tree/([^"/]+)!,
39 all => 1,
40 );
41 0 ▶ return $res unless $res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 0 0
42 # sort versions from earliest
43 0 $res->[2] = [ sort { $self->cmp_version($a, $b) } @{$res->[2]}];
44 0 $res;
45 }
46  
47 0 ▶sub canon2native_arch_map {
Subroutine canon2native_arch_map: not called CC=1 SCAR=6.9
48 return +{
49 0 'linux-x86' => 'linux32',
50 'linux-x86_64' => 'linux64',
51 'win32' => 'win32',
52 'win64' => 'win64',
53 },
54 }
55  
56 0 ▶sub download_url {
Subroutine download_url: not called CC=5 SCAR=34.0
57 0 my ($self, %args) = @_;
58  
59 0 my $version = $args{version};
60 0 ▶ if (!$version) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version) 0 0 0
61 0 my $verres = $self->latest_version(maybe arch => $args{arch});
62 0 ▶ return [500, "Can't get latest version: $verres->[0] - $verres->[1]"]
Branch: 1 branch
BranchTrueFalseTotal
unless $verres->[0] == 200 0 0 0
63 unless $verres->[0] == 200;
64 0 $version = $verres->[2];
65 }
66  
67 0 my $v0;
68 0 ▶ if ($version =~ /\A(\d+\.\d+\.\d+)\.\d+\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version =~ /\A(\d+\.\d+\.\d+)\.\d+\z/) { } 0 0 0
69 0 $v0 = $1;
70 } else {
71 0 die "Can't recognize version format $version (not x.y.z.a)";
72 }
73  
74 0 my $ext;
75 0 ▶ if ($args{arch} =~ /linux/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'arch'} =~ /linux/) { } 0 0 0
76 0 $ext = ".tar.gz";
77 } else {
78 0 $ext = ".zip";
79 }
80  
81 my $filename = join(
82 "",
83 0 "bulwark-$version-", $self->_canon2native_arch($args{arch}), $ext);
84  
85 0 [200, "OK",
86 join(
87 "",
88 "https://github.com/bulwark-crypto/Bulwark/releases/download/$v0/$filename",
89 ), {
90 'func.filename' => $filename,
91 }];
92 }
93  
94 0 ▶sub homepage_url { "https://bulwarkcrypto.com/" }
Subroutine homepage_url: not called CC=1 SCAR=6.9
95  
96 0 ▶sub is_dedicated_profile { 0 }
Subroutine is_dedicated_profile: not called CC=1 SCAR=6.9
97  
98 0 ▶sub latest_version {
Subroutine latest_version: not called CC=1 SCAR=6.9
99 0 my ($self, %args) = @_;
100  
101 0 extract_from_url(
102 url => "https://github.com/bulwark-crypto/Bulwark/releases",
103 re => qr!/bulwark-crypto/Bulwark/releases/download/\d+(?:\.\d+)+/bulwark-(\d+(?:\.\d+)+)-linux64\.!,
104 );
105 }
106  
107 0 ▶sub release_note {
Subroutine release_note: not called CC=5 SCAR=34.0
108 0 require Mojo::DOM;
109  
110 0 my ($self, %args) = @_;
111 0 ▶ my $format = $args{format} // 'text';
Condition0%0/2
$args{"format"} // "text"
l!l
00
MC/DC0%0/1
$args{"format"} // "text"
$args{"format"}
Truth table0%0/2
A
A= $args{"format"}
Aresult
11
00
112  
113 # 2.1.1 tree means version 2.1.1.0
114 0 ▶ my $version = $args{version} // do {
Condition0%0/3
$args{"version"} // do { my $res = $self->latest_version(%args); return $res unless $res->[0] == 200; $res->[2] }
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"version"} // do { my $res = $self->latest_version(%args); return $res unless $res->[0] == 200; $res->[2] }
$args{"version"} do { my $res = $self->latest_version(%args); return $res unless $res->[0] == 200; $res->[2] }
Truth table0%0/3
A // B
A= $args{"version"}B= do { my $res = $self->latest_version(%args); return $res unless $res->[0] == 200; $res->[2] }
ABresult
1X1
011
000
115 0 my $res = $self->latest_version(%args);
116 0 ▶ return $res unless $res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 0 0
117 0 $res->[2];
118 };
119 0 ▶ $version =~ s/\.0\z// if $version =~ /\A\d+\.\d+\.\d+\.0\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $version =~ /\A\d+\.\d+\.\d+\.0\z/ 0 0 0
120  
121 0 my $url = "https://github.com/bulwark-crypto/Bulwark/releases/tag/$version";
122 my $res = extract_from_url(
123 url => $url,
124 0 ▶ code => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
125 0 my %cargs = @_;
126 0 my $dom = Mojo::DOM->new($cargs{content});
127 0 my $html = $dom->at(".markdown-body")->content;
128  
129 0 ▶ if ($html) {
Branch: 1 branch
BranchTrueFalseTotal
if ($html) { } 0 0 0
130 0 ▶ if ($format eq 'html') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format eq 'html') { } 0 0 0
131 0 return [200, "OK", $html];
132 } else {
133 0 require HTML::FormatText::Any;
134 0 return [200, "OK",
135 HTML::FormatText::Any::html2text(html => $html)->[2]];
136 }
137 } else {
138 0 return [543, "Cannot scrape release note text from $url"];
139 }
140 },
141 0 );
142 }
143  
144 1;
145 # ABSTRACT: Bulwark desktop GUI client
146  
147 __END__
↑ Summary