| 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 || {}
MC/DC0%0/1
$data || {}
$data
Truth table50%1/2
A
A= $data
| |||||||||||||
| 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
| |||||||||||||
| 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'} || []
MC/DC0%0/1
$_[0]{'data'}{'recipe_versions'} || []
$_[0]{'data'}{'recipe_versions'}
Truth table50%1/2
A
A= $_[0]{'data'}{'recipe_versions'}
| |||||||||||||
| 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'} || []
MC/DC0%0/1
$_[0]{'data'}{'published_versions'} || []
$_[0]{'data'}{'published_versions'}
Truth table0%0/2
A
A= $_[0]{'data'}{'published_versions'}
| |||||||||||||
| 82 | 0 | ▶ | sub identifiers { @{ $_[0]{data}{identifiers} || [] } } | ||||||||||
|
Subroutine
identifiers: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
$_[0]{'data'}{'identifiers'} || []
MC/DC0%0/1
$_[0]{'data'}{'identifiers'} || []
$_[0]{'data'}{'identifiers'}
Truth table0%0/2
A
A= $_[0]{'data'}{'identifiers'}
| |||||||||||||
| 83 | 0 | ▶ | sub outputs { @{ $_[0]{data}{outputs} || [] } } | ||||||||||
|
Subroutine
outputs: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
$_[0]{'data'}{'outputs'} || []
MC/DC0%0/1
$_[0]{'data'}{'outputs'} || []
$_[0]{'data'}{'outputs'}
Truth table0%0/2
A
A= $_[0]{'data'}{'outputs'}
| |||||||||||||
| 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
| |||||||||||||
| 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"
MC/DC0%0/1
$kind ||= "run"
$kind
Truth table50%1/2
A
A= $kind
| |||||||||||||
| 114 | 2 | ▶ | my $deps = $self->{data}{depends} || {}; | ||||||||||
|
Condition50%1/2
$self->{'data'}{'depends'} || {}
MC/DC0%0/1
$self->{'data'}{'depends'} || {}
$self->{'data'}{'depends'}
Truth table50%1/2
A
A= $self->{'data'}{'depends'}
| |||||||||||||
| 115 | 2 | my @list; | |||||||||||
| 116 | 2 | ▶ | if ($kind eq 'all') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 117 | 0 | ▶ | push @list, @{ $deps->{$_} || [] } for qw(build host run); | ||||||||||
|
Condition0%0/2
$deps->{$_} || []
MC/DC0%0/1
$deps->{$_} || []
$deps->{$_}
Truth table0%0/2
A
A= $deps->{$_}
| |||||||||||||
| 118 | } | ||||||||||||
| 119 | else { | ||||||||||||
| 120 | 2 | ▶ | @list = @{ $deps->{$kind} || [] }; | ||||||||||
|
Condition50%1/2
$deps->{$kind} || []
MC/DC0%0/1
$deps->{$kind} || []
$deps->{$kind}
Truth table50%1/2
A
A= $deps->{$kind}
| |||||||||||||
| 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; | |||||||||||