CycloneDX/Dependency.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 100% 1 / 1 totaltotal 93.8% 46 / 49 CC 2 SCAR 2.2
CC
2
Cov
95%
TO_JSON
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« CycloneDX/Definitions.pm ↑ Summary CycloneDX/BomRef.pm »
1 package SBOM::CycloneDX::Dependency;
2  
3 16 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Types::Standard qw(Str InstanceOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use Types::TypeTiny qw(ArrayLike);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 16 extends 'SBOM::CycloneDX::Base';
15  
16 16 has ref => (is => 'rw', isa => Str | InstanceOf ['SBOM::CycloneDX::BomRef'], required => 1);
17  
18 has depends_on => (
19 is => 'rw',
20 isa => ArrayLike [Str | InstanceOf ['SBOM::CycloneDX::BomRef']],
21 0 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 16 );
23  
24 has provides => (
25 is => 'rw',
26 isa => ArrayLike [Str | InstanceOf ['SBOM::CycloneDX::BomRef']],
27 12 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
28 16 );
29  
30 36 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=2 SCAR=7.0
Pod documented
31  
32 36 my $self = shift;
33  
34 36 my $json = {ref => $self->ref, dependsOn => $self->depends_on};
35  
36 36 ▶ $json->{provides} = $self->provides if @{$self->provides};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->provides;} 0 36 36
37  
38 36 return $json;
39  
40 }
41  
42 16 1;
43  
44 =encoding utf-8
45  
46 =head1 NAME
47  
48 SBOM::CycloneDX::Dependency - Dependency
49  
50 =head1 SYNOPSIS
51  
52 SBOM::CycloneDX::Dependency->new();
53  
54  
55 =head1 DESCRIPTION
56  
57 L<SBOM::CycloneDX::Dependency> defines the direct dependencies of a
58 component, service, or the components provided/implemented by a given
59 component. Components or services that do not have their own dependencies
60 must be declared as empty elements within the graph. Components or services
61 that are not represented in the dependency graph may have unknown
62 dependencies. It is recommended that implementations assume this to be
63 opaque and not an indicator of an object being dependency-free. It is
64 recommended to leverage compositions to indicate unknown dependency graphs.
65  
66 =head2 METHODS
67  
68 L<SBOM::CycloneDX::Dependency> inherits all methods from L<SBOM::CycloneDX::Base>
69 and implements the following new ones.
70  
71 =over
72  
73 =item SBOM::CycloneDX::Dependency->new( %PARAMS )
74  
75 Properties:
76  
77 =over
78  
79 =item * C<depends_on>, The bom-ref identifiers of the components or services
80 that are dependencies of this dependency object.
81  
82 =item * C<provides>, The bom-ref identifiers of the components or services
83 that define a given specification or standard, which are provided or
84 implemented by this dependency object.
85 For example, a cryptographic library which implements a cryptographic
86 algorithm. A component which implements another component does not imply
87 that the implementation is in use.
88  
89 =item * C<ref>, References a component or service by its bom-ref attribute
90  
91 =back
92  
93 =item $dependency->depends_on
94  
95 =item $dependency->provides
96  
97 =item $dependency->ref
98  
99 =back
100  
101  
102 =head1 SUPPORT
103  
104 =head2 Bugs / Feature Requests
105  
106 Please report any bugs or feature requests through the issue tracker
107 at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>.
108 You will be notified automatically of any progress on your issue.
109  
110 =head2 Source Code
111  
112 This is open source software. The code repository is available for
113 public review and contribution under the terms of the license.
114  
115 L<https://github.com/giterlizzi/perl-SBOM-CycloneDX>
116  
117 git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
118  
119  
120 =head1 AUTHOR
121  
122 =over 4
123  
124 =item * Giuseppe Di Terlizzi <gdt@cpan.org>
125  
126 =back
127  
128  
129 =head1 LICENSE AND COPYRIGHT
130  
131 This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
132  
133 This is free software; you can redistribute it and/or modify it under
134 the same terms as the Perl 5 programming language system itself.
135  
136 =cut
« CycloneDX/Definitions.pm ↑ Summary CycloneDX/BomRef.pm »