File Coverage

blib/lib/SBOM/CycloneDX/Dependency.pm
Criterion Covered Total %
statement 28 28 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 39 40 97.5


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Dependency;
2              
3 16     16   317 use 5.010001;
  16         90  
4 16     16   91 use strict;
  16         30  
  16         518  
5 16     16   115 use warnings;
  16         64  
  16         1003  
6 16     16   120 use utf8;
  16         99  
  16         107  
7              
8 16     16   850 use Types::Standard qw(Str InstanceOf);
  16         33  
  16         134  
9 16     16   46335 use Types::TypeTiny qw(ArrayLike);
  16         38  
  16         99  
10              
11 16     16   7668 use Moo;
  16         29  
  16         104  
12 16     16   5815 use namespace::autoclean;
  16         36  
  16         171  
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 393 my $self = shift;
33              
34 120         3336 my $json = {ref => $self->ref, dependsOn => $self->depends_on};
35              
36 120 50       4694 $json->{provides} = $self->provides if @{$self->provides};
  120         2515  
37              
38 120         885 return $json;
39              
40             }
41              
42             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 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 inherits all methods from L
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, The bom-ref identifiers of the components or services
80             that are dependencies of this dependency object.
81              
82             =item * C, 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, 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.
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
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
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