File Coverage

blib/lib/SBOM/CycloneDX/Dependency.pm
Criterion Covered Total %
statement 30 30 100.0
branch 3 4 75.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 43 44 97.7


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