| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Daje::Tools::Datasections; |
|
2
|
2
|
|
|
2
|
|
327757
|
use Mojo::Base -base; |
|
|
2
|
|
|
|
|
24236
|
|
|
|
2
|
|
|
|
|
11
|
|
|
3
|
2
|
|
|
2
|
|
500
|
use v5.42; |
|
|
2
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1061
|
use Mojo::Loader qw {data_section load_class}; |
|
|
2
|
|
|
|
|
551119
|
|
|
|
2
|
|
|
|
|
1702
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Daje::Tools::Datasections - Load and store data sections in memory from a named *.pm |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Abstract |
|
11
|
|
|
|
|
|
|
# ======== |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# Get and store data sections from perl classes |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# Synopsis |
|
17
|
|
|
|
|
|
|
# ========= |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# use Daje::Tools::Datasections; |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# my $data = Daje::Tools::Datasections->new( |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
# data_sections => ['c1','c2','c3'], |
|
24
|
|
|
|
|
|
|
# |
|
25
|
|
|
|
|
|
|
# source => 'Class::Containing::Datasections |
|
26
|
|
|
|
|
|
|
# |
|
27
|
|
|
|
|
|
|
# )->load_data_sections(); |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
# METHODS |
|
30
|
|
|
|
|
|
|
# ======= |
|
31
|
|
|
|
|
|
|
# Get one section of loaded data |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
# my $c1 = $data->get_data_section('c1'); |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
# Add a section of data |
|
36
|
|
|
|
|
|
|
# |
|
37
|
|
|
|
|
|
|
# $data->set_data_section('new_section', 'section data'); |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# Set a new source |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# $data->set_source('New::Source'); |
|
42
|
|
|
|
|
|
|
# |
|
43
|
|
|
|
|
|
|
# Add a new section to load |
|
44
|
|
|
|
|
|
|
# |
|
45
|
|
|
|
|
|
|
# $data->add_data_section('test'); |
|
46
|
|
|
|
|
|
|
# |
|
47
|
|
|
|
|
|
|
# |
|
48
|
|
|
|
|
|
|
# LICENSE |
|
49
|
|
|
|
|
|
|
# ======= |
|
50
|
|
|
|
|
|
|
# Generate::Tools::Datasections (the distribution) is licensed under the same terms as Perl. |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# AUTHOR |
|
53
|
|
|
|
|
|
|
# ====== |
|
54
|
|
|
|
|
|
|
# Jan Eskilsson |
|
55
|
|
|
|
|
|
|
# |
|
56
|
|
|
|
|
|
|
# COPYRIGHT |
|
57
|
|
|
|
|
|
|
# ========= |
|
58
|
|
|
|
|
|
|
# Copyright (C) 2024 Jan Eskilsson. |
|
59
|
|
|
|
|
|
|
# |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'data_sec'; |
|
64
|
|
|
|
|
|
|
has 'data_sections'; |
|
65
|
|
|
|
|
|
|
has 'source'; |
|
66
|
|
|
|
|
|
|
has 'error'; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Load all data_sections |
|
69
|
0
|
|
|
0
|
0
|
|
sub load_data_sections($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
try { |
|
72
|
0
|
|
|
|
|
|
my $data_sec = {}; |
|
73
|
0
|
|
|
|
|
|
$self->data_sec($data_sec); |
|
74
|
0
|
|
|
|
|
|
my $class = $self->source(); |
|
75
|
0
|
|
|
|
|
|
my $c = load_class($class); |
|
76
|
0
|
|
|
|
|
|
my @data_sec = split(',', $self->data_sections) ; |
|
77
|
0
|
|
|
|
|
|
my $length = scalar @data_sec; |
|
78
|
0
|
|
|
|
|
|
for(my $i = 0; $i < $length; $i++){ |
|
79
|
0
|
|
|
|
|
|
my $section = $data_sec[$i]; |
|
80
|
0
|
0
|
|
|
|
|
if (!exists($self->data_sec->{$section})) { |
|
81
|
0
|
|
|
|
|
|
my $sec = data_section($class, $section); |
|
82
|
0
|
|
|
|
|
|
$self->set_data_section($section, $sec); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} catch ($e) { |
|
86
|
0
|
|
|
|
|
|
$self->error($e); |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return 1; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
# Get one section |
|
92
|
0
|
|
|
0
|
0
|
|
sub get_data_section($self, $section) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return $self->data_sec->{$section}; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
# Set a section |
|
96
|
0
|
|
|
0
|
0
|
|
sub set_data_section($self, $key, $templ) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$self->data_sec->{$key} = $templ; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
# Set Source |
|
100
|
0
|
|
|
0
|
0
|
|
sub set_source($self, $source_class) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$self->source = $source_class; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
# Add a section to the data sections_array to be loaded |
|
104
|
0
|
|
|
0
|
0
|
|
sub add_data_section($self, $section) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$self->data_sections .','. $section; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
1; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |