File Coverage

blib/lib/FalkorDB/Path.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 6 0.0
condition n/a
subroutine 2 7 28.5
pod 3 5 60.0
total 11 44 25.0


line stmt bran cond sub pod time code
1             package FalkorDB::Path;
2              
3 6     6   28 use strict;
  6         8  
  6         188  
4 6     6   20 use warnings;
  6         7  
  6         2116  
5              
6             sub new {
7 0     0 0   my ( $class, %args ) = @_;
8 0           return bless \%args, $class;
9             }
10              
11 0     0 1   sub nodes { shift->{nodes} }
12 0     0 1   sub edges { shift->{edges} }
13 0     0 1   sub elements { shift->{elements} }
14              
15             sub new_from_string {
16 0     0 0   my ( $class, $path_str ) = @_;
17 0           my @nodes;
18             my @edges;
19 0           my @elements;
20              
21 0 0         if ( $path_str =~ /^\[(.*)\]$/ ) {
22 0           my $content = $1;
23 0           while ( $content =~ /(\(\d+\)|\[\d+\])/g ) {
24 0           my $token = $1;
25 0 0         if ( $token =~ /^\((\d+)\)$/ ) {
    0          
26 0           my $node_id = 0 + $1;
27 0           push @nodes, $node_id;
28 0           push @elements, { type => 'node', id => $node_id };
29             }
30             elsif ( $token =~ /^\[(\d+)\]$/ ) {
31 0           my $edge_id = 0 + $1;
32 0           push @edges, $edge_id;
33 0           push @elements, { type => 'edge', id => $edge_id };
34             }
35             }
36             }
37              
38 0           return $class->new(
39             nodes => \@nodes,
40             edges => \@edges,
41             elements => \@elements,
42             );
43             }
44              
45             1;
46             __END__