line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Data-Importer |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2014 by Kaare Rasmussen. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Data::Importer::Iterator; |
10
|
|
|
|
|
|
|
$Data::Importer::Iterator::VERSION = '0.006'; |
11
|
1
|
|
|
1
|
|
757
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
32
|
|
12
|
1
|
|
|
1
|
|
5
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
13
|
1
|
|
|
1
|
|
55
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 Description |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Base class for handling the import of a file |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Currently, there are iterators for L<CSV|Data::Importer::Iterator::Csv>, L<ODS|Data::Importer::Iterator::Ods>, and L<XLS|Data::Importer::Iterator::Xls>, |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 lineno |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The line counter |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'lineno' => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'Num', |
32
|
|
|
|
|
|
|
traits => ['Counter'], |
33
|
|
|
|
|
|
|
default => 0, |
34
|
|
|
|
|
|
|
handles => { |
35
|
|
|
|
|
|
|
inc_lineno => 'inc', |
36
|
|
|
|
|
|
|
reset_lineno => 'reset', |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 file_name |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The name of the import file |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has file_name => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => 'Str', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 mandatory |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Required input columns |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has 'mandatory' => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
isa => 'ArrayRef', |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 optional |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Required input columns |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has 'optional' => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
isa => 'ArrayRef', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 encoding |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The encoding of the spreadsheet |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has encoding => ( |
80
|
|
|
|
|
|
|
is => 'ro', |
81
|
|
|
|
|
|
|
isa => 'Str', |
82
|
|
|
|
|
|
|
predicate => 'has_encoding', |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 next |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Return the next row of data from the file |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub next { |
94
|
0
|
|
|
0
|
1
|
|
return 'should be sub classed'; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# This file is part of Data-Importer |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
# This software is copyright (c) 2014 by Kaare Rasmussen. |
103
|
|
|
|
|
|
|
# |
104
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
105
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
106
|
|
|
|
|
|
|
# |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |