Packages/Package.pm

filter: Statementstmt 70.4% 31 / 44 Branchbran 50.0% 3 / 6 Conditioncond 27.7% 5 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 64.2% 9 / 14 Podpod 90.0% 9 / 10 totaltotal 56.4% 57 / 101 CC 14 SCAR 16.3
CC
14
Cov
57%
dependencies
10.1
published_versions
6.0
identifiers
6.0
CRAP 5.1
« Packages.pm ↑ Summary
1 package Bioconda::Packages::Package;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.01';
7  
8 =head1 NAME
9  
10 Bioconda::Packages::Package - A single Bioconda package record.
11  
12 =head1 SYNOPSIS
13  
14 my $pkg = $bp->get('samtools');
15 print $pkg->name, ' ', $pkg->current_version, "\n";
16 print "removed!\n" if $pkg->is_removed;
17 my @run = $pkg->dependencies('run');
18  
19 =head1 DESCRIPTION
20  
21 A thin, read-only wrapper around the hashref stored in the database. It exists so
22 callers get stable accessor methods instead of reaching into hash keys. The
23 underlying data is available via L</data> if you need a field without an
24 accessor.
25  
26 =cut
27  
28 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
29 4 my ($class, $data) = @_;
30 4 ▶ return bless { data => $data || {} }, $class;
Condition50%1/2
$data || {}
l!l
40
MC/DC0%0/1
$data || {}
$data
Truth table50%1/2
A
A= $data
Aresult
11
00
31 }
32  
33 =head2 data
34  
35 Returns the raw underlying hashref.
36  
37 =cut
38  
39 0 ▶sub data { $_[0]{data} }
Subroutine data: not called CC=1 SCAR=6.9
Pod documented
40  
41 # Simple scalar accessors generated from the record keys.
42 3 for my $field (qw(
43 name current_version build_number noarch
44 summary license license_family home dev_url doc_url
45 downloads recipe_path removed_at first_seen last_seen
46 )) {
47 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 ▶ *{$field} = sub { $_[0]{data}{$field} };
Subroutine __ANON__: called CC=1 SCAR=0.0
49 }
50  
51 =head2 is_removed
52  
53 True if the package is no longer present in bioconda-recipes but retained in the
54 database.
55  
56 =cut
57  
58 2 ▶sub is_removed { $_[0]{data}{is_removed} ? 1 : 0 }
Subroutine is_removed: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'data'}{'is_removed'} ? : 1 1 2
59  
60 =head2 recipe_versions
61  
62 List of recipe versions found in the repo (current plus any pinned version
63 subdirectories).
64  
65 =head2 published_versions
66  
67 List of versions actually published on anaconda.org (only populated when the
68 database was built with API enrichment).
69  
70 =head2 identifiers
71  
72 List of external identifiers (e.g. C<biotools:samtools>, C<doi:...>).
73  
74 =head2 outputs
75  
76 List of package names this recipe produces (for multi-output recipes).
77  
78 =cut
79  
80 1 ▶sub recipe_versions { @{ $_[0]{data}{recipe_versions} || [] } }
Subroutine recipe_versions: called CC=2 SCAR=7.2
Pod documented
Condition50%1/2
$_[0]{'data'}{'recipe_versions'} || []
l!l
10
MC/DC0%0/1
$_[0]{'data'}{'recipe_versions'} || []
$_[0]{'data'}{'recipe_versions'}
Truth table50%1/2
A
A= $_[0]{'data'}{'recipe_versions'}
Aresult
11
00
81 0 ▶sub published_versions { @{ $_[0]{data}{published_versions} || [] } }
Subroutine published_versions: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]{'data'}{'published_versions'} || []
l!l
00
MC/DC0%0/1
$_[0]{'data'}{'published_versions'} || []
$_[0]{'data'}{'published_versions'}
Truth table0%0/2
A
A= $_[0]{'data'}{'published_versions'}
Aresult
11
00
82 0 ▶sub identifiers { @{ $_[0]{data}{identifiers} || [] } }
Subroutine identifiers: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]{'data'}{'identifiers'} || []
l!l
00
MC/DC0%0/1
$_[0]{'data'}{'identifiers'} || []
$_[0]{'data'}{'identifiers'}
Truth table0%0/2
A
A= $_[0]{'data'}{'identifiers'}
Aresult
11
00
83 0 ▶sub outputs { @{ $_[0]{data}{outputs} || [] } }
Subroutine outputs: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]{'data'}{'outputs'} || []
l!l
00
MC/DC0%0/1
$_[0]{'data'}{'outputs'} || []
$_[0]{'data'}{'outputs'}
Truth table0%0/2
A
A= $_[0]{'data'}{'outputs'}
Aresult
11
00
84  
85 =head2 versions
86  
87 The best available list of versions: published versions when known, otherwise
88 recipe versions.
89  
90 =cut
91  
92 0 ▶sub versions {
Subroutine versions: not called CC=2 SCAR=17.9
Pod documented
93 0 my ($self) = @_;
94 0 my @pub = $self->published_versions;
95 0 ▶ return @pub if @pub;
Branch: 1 branch
BranchTrueFalseTotal
if @pub 0 0 0
96 0 return $self->recipe_versions;
97 }
98  
99 =head2 dependencies
100  
101 my @run = $pkg->dependencies('run'); # default is 'run'
102 my @host = $pkg->dependencies('host');
103 my @build = $pkg->dependencies('build');
104 my @all = $pkg->dependencies('all');
105  
106 In list context returns dependency hashrefs
107 (C<< { name, constraint, platform } >>). In scalar context returns the count.
108  
109 =cut
110  
111 2 ▶sub dependencies {
Subroutine dependencies: called CC=7 SCAR=23.2
Pod documented
112 2 my ($self, $kind) = @_;
113 2 ▶ $kind ||= 'run';
Condition50%1/2
$kind ||= "run"
l!l
20
MC/DC0%0/1
$kind ||= "run"
$kind
Truth table50%1/2
A
A= $kind
Aresult
11
00
114 2 ▶ my $deps = $self->{data}{depends} || {};
Condition50%1/2
$self->{'data'}{'depends'} || {}
l!l
20
MC/DC0%0/1
$self->{'data'}{'depends'} || {}
$self->{'data'}{'depends'}
Truth table50%1/2
A
A= $self->{'data'}{'depends'}
Aresult
11
00
115 2 my @list;
116 2 ▶ if ($kind eq 'all') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq 'all') { } 0 2 2
117 0 ▶ push @list, @{ $deps->{$_} || [] } for qw(build host run);
Condition0%0/2
$deps->{$_} || []
l!l
00
MC/DC0%0/1
$deps->{$_} || []
$deps->{$_}
Truth table0%0/2
A
A= $deps->{$_}
Aresult
11
00
118 }
119 else {
120 2 ▶ @list = @{ $deps->{$kind} || [] };
Condition50%1/2
$deps->{$kind} || []
l!l
20
MC/DC0%0/1
$deps->{$kind} || []
$deps->{$kind}
Truth table50%1/2
A
A= $deps->{$kind}
Aresult
11
00
121 }
122 2 return @list;
123 }
124  
125 =head2 dependency_names
126  
127 As L</dependencies> but returns just the names.
128  
129 =cut
130  
131 1 ▶sub dependency_names {
Subroutine dependency_names: called CC=1 SCAR=0.0
Pod documented
132 1 my ($self, $kind) = @_;
133 1 return map { $_->{name} } $self->dependencies($kind);
134 }
135  
136 3 1;
« Packages.pm ↑ Summary