File Coverage

lib/SIRTX/VM/Chunk/Type/OctetStream.pm
Criterion Covered Total %
statement 17 30 56.6
branch 0 8 0.0
condition n/a
subroutine 6 11 54.5
pod 2 2 100.0
total 25 51 49.0


line stmt bran cond sub pod time code
1             # Copyright (c) 2025 Philipp Schafft
2              
3             # licensed under Artistic License 2.0 (see LICENSE file)
4              
5             # ABSTRACT: module for interacting with SIRTX VM chunks
6              
7              
8             package SIRTX::VM::Chunk::Type::OctetStream;
9              
10 1     1   1498 use v5.16;
  1         4  
11 1     1   8 use strict;
  1         2  
  1         34  
12 1     1   6 use warnings;
  1         2  
  1         48  
13              
14 1     1   38 use Carp;
  1         3  
  1         101  
15 1     1   7 use Scalar::Util qw(blessed);
  1         15  
  1         73  
16              
17 1     1   7 use parent 'SIRTX::VM::Chunk::Type';
  1         1  
  1         6  
18              
19             our $VERSION = v0.03;
20              
21             sub attach_data {
22 0     0 1   my ($self, @opts) = @_;
23 0           return $self->SIRTX::VM::Chunk::attach_data(@opts);
24             }
25              
26              
27             sub ingest_object {
28 0     0 1   my ($self, $obj, @opts) = @_;
29 0           my $blob;
30              
31 0 0         croak 'Stray options passed' if scalar @opts;
32              
33 0 0         croak 'Object is not blessed' unless blessed $obj;
34              
35 0 0         if ($obj->isa('String::Super')) {
36 0           $blob = $obj->result;
37             }
38              
39 0 0         croak 'Not a supported object or no data found' unless defined $blob;
40              
41             {
42 0           open(my $fh, '<:raw', \$blob);
  0            
43 0           $self->attach_data($fh);
44             }
45             }
46              
47             # ---- Private helpers ----
48              
49             sub _create_data {
50 0     0     my ($self) = @_;
51             }
52              
53       0     sub _parse {
54             # no-op
55             }
56              
57       0     sub _render {
58             # no-op
59             }
60              
61             1;
62              
63             __END__
64              
65             =pod
66              
67             =encoding UTF-8
68              
69             =head1 NAME
70              
71             SIRTX::VM::Chunk::Type::OctetStream - module for interacting with SIRTX VM chunks
72              
73             =head1 VERSION
74              
75             version v0.03
76              
77             =head1 SYNOPSIS
78              
79             use SIRTX::VM::Chunk::Type::OctetStream;
80              
81             my SIRTX::VM::Chunk $chunk = SIRTX::VM::Chunk::Type::OctetStream->new;
82              
83             (since v0.02)
84              
85             This represends an octet stream chunk.
86             Such a chunk is used to store unstructured data.
87              
88             This inherits from L<SIRTX::VM::Chunk>.
89              
90             =head2 ingest_object
91              
92             $chunk->ingest_object($obj);
93              
94             (experimental since v0.02)
95              
96             Ingests an object as the data source for this chunk.
97             This is similar to L<SIRTX::VM::Chunk/attach_data>
98             but works with Perl objects.
99              
100             Currently only L<String::Super> is supported.
101              
102             =head1 AUTHOR
103              
104             Philipp Schafft <lion@cpan.org>
105              
106             =head1 COPYRIGHT AND LICENSE
107              
108             This software is Copyright (c) 2025 by Philipp Schafft <lion@cpan.org>.
109              
110             This is free software, licensed under:
111              
112             The Artistic License 2.0 (GPL Compatible)
113              
114             =cut