| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package NG; |
|
2
|
1
|
|
|
1
|
|
24276
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
1562
|
use Try::Tiny; |
|
|
1
|
|
|
|
|
1848
|
|
|
|
1
|
|
|
|
|
69
|
|
|
5
|
1
|
|
|
1
|
|
1756
|
use autodie; |
|
|
1
|
|
|
|
|
20496
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
17542
|
use YAML::XS (); |
|
|
1
|
|
|
|
|
9128
|
|
|
|
1
|
|
|
|
|
25
|
|
|
7
|
1
|
|
|
1
|
|
1553
|
use JSON::XS (); |
|
|
1
|
|
|
|
|
10990
|
|
|
|
1
|
|
|
|
|
29
|
|
|
8
|
1
|
|
|
1
|
|
442
|
use XML::Simple; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Spreadsheet::ParseExcel; |
|
10
|
|
|
|
|
|
|
use NG::Autobox; |
|
11
|
|
|
|
|
|
|
use NG::Array; |
|
12
|
|
|
|
|
|
|
use NG::DB; |
|
13
|
|
|
|
|
|
|
use NG::Excel; |
|
14
|
|
|
|
|
|
|
use NG::Excel::Cell; |
|
15
|
|
|
|
|
|
|
use NG::Excel::Sheet; |
|
16
|
|
|
|
|
|
|
use NG::HTTP::Client; |
|
17
|
|
|
|
|
|
|
use NG::EMail; |
|
18
|
|
|
|
|
|
|
use NG::File; |
|
19
|
|
|
|
|
|
|
use NG::Dir; |
|
20
|
|
|
|
|
|
|
use NG::Log; |
|
21
|
|
|
|
|
|
|
use NG::System; |
|
22
|
|
|
|
|
|
|
use NG::Time; |
|
23
|
|
|
|
|
|
|
use NG::Class; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use base 'Exporter'; |
|
26
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
27
|
|
|
|
|
|
|
local_run |
|
28
|
|
|
|
|
|
|
remote_run |
|
29
|
|
|
|
|
|
|
fork_run |
|
30
|
|
|
|
|
|
|
taskset |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
web_get |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
mail_send |
|
35
|
|
|
|
|
|
|
mail_get |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
from_json |
|
38
|
|
|
|
|
|
|
from_yaml |
|
39
|
|
|
|
|
|
|
mkdir_p |
|
40
|
|
|
|
|
|
|
rm_r |
|
41
|
|
|
|
|
|
|
cp_r |
|
42
|
|
|
|
|
|
|
read_file |
|
43
|
|
|
|
|
|
|
read_dir |
|
44
|
|
|
|
|
|
|
file_stat |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
process_log |
|
47
|
|
|
|
|
|
|
geo_ip |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
db |
|
50
|
|
|
|
|
|
|
now |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
parse_excel |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
def_class |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
our $VERSION = '0.001_05'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub file_stat { NG::File->fstat(@_) } |
|
59
|
|
|
|
|
|
|
sub file_md5 { NG::File->md5(@_) } |
|
60
|
|
|
|
|
|
|
sub cp_r { NG::File->copy(@_) } |
|
61
|
|
|
|
|
|
|
sub process_log { NG::Log::process_log(@_) } |
|
62
|
|
|
|
|
|
|
sub geo_ip { NG::Log::geo_ip(@_) } |
|
63
|
|
|
|
|
|
|
sub def_class { NG::Class::def(@_) } |
|
64
|
|
|
|
|
|
|
sub db { NG::DB->new(@_) } |
|
65
|
|
|
|
|
|
|
sub now { NG::Time->now } |
|
66
|
|
|
|
|
|
|
sub local_run { NG::System::local_run(@_) } |
|
67
|
|
|
|
|
|
|
sub remote_run { NG::System::remote_run(@_) } |
|
68
|
|
|
|
|
|
|
sub fork_run { NG::System::fork_run(@_) } |
|
69
|
|
|
|
|
|
|
sub taskset { NG::System::taskset(@_) } |
|
70
|
|
|
|
|
|
|
sub web_get { NG::HTTP::Client::web_get(@_) } |
|
71
|
|
|
|
|
|
|
sub mail_send { NG::EMail::send(@_) } |
|
72
|
|
|
|
|
|
|
sub mail_get { NG::EMail::get(@_) } |
|
73
|
|
|
|
|
|
|
sub mkdir_p { NG::Dir->make(@_) } |
|
74
|
|
|
|
|
|
|
sub rm_r { NG::Dir->remove(@_) } |
|
75
|
|
|
|
|
|
|
sub read_dir { NG::Dir->read(@_) } |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub read_file { |
|
78
|
|
|
|
|
|
|
my ( $file, $cb ) = @_; |
|
79
|
|
|
|
|
|
|
unless ( defined $cb ) { |
|
80
|
|
|
|
|
|
|
open my $fh, '<', $file; |
|
81
|
|
|
|
|
|
|
return do { local $/; <$fh> } |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
my $content = NG::File->read($file); |
|
84
|
|
|
|
|
|
|
$cb->($content); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub from_yaml { |
|
88
|
|
|
|
|
|
|
my $ref = YAML::XS::LoadFile(@_); |
|
89
|
|
|
|
|
|
|
return ref($ref) eq 'HASH' |
|
90
|
|
|
|
|
|
|
? NG::Hashtable->new($ref) |
|
91
|
|
|
|
|
|
|
: NG::Array->new($ref); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub from_json { |
|
95
|
|
|
|
|
|
|
my $data = &read_file(@_); |
|
96
|
|
|
|
|
|
|
my $ref = JSON::XS::decode_json($data); |
|
97
|
|
|
|
|
|
|
return ref($ref) eq 'HASH' |
|
98
|
|
|
|
|
|
|
? NG::Hashtable->new($ref) |
|
99
|
|
|
|
|
|
|
: NG::Array->new($ref); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub from_xml { |
|
103
|
|
|
|
|
|
|
my $data = &read_file(@_); |
|
104
|
|
|
|
|
|
|
my $ref = XMLin($data); |
|
105
|
|
|
|
|
|
|
return ref($ref) eq 'HASH' |
|
106
|
|
|
|
|
|
|
? NG::Hashtable->new($ref) |
|
107
|
|
|
|
|
|
|
: NG::Array->new($ref); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub parse_excel { |
|
111
|
|
|
|
|
|
|
my ( $filepath, $cb ) = @_; |
|
112
|
|
|
|
|
|
|
my $parser = Spreadsheet::ParseExcel->new(); |
|
113
|
|
|
|
|
|
|
my $workbook = $parser->parse($filepath); |
|
114
|
|
|
|
|
|
|
if ( !defined $workbook ) { |
|
115
|
|
|
|
|
|
|
die $parser->error() . "\n"; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
my $ng_sheet_arr = NG::Array->new; |
|
118
|
|
|
|
|
|
|
for my $sheet ( $workbook->worksheets() ) { |
|
119
|
|
|
|
|
|
|
my ( $row_min, $row_max ) = $sheet->row_range(); |
|
120
|
|
|
|
|
|
|
my ( $col_min, $col_max ) = $sheet->col_range(); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $ng_sheet = NG::Excel::Sheet->new( |
|
123
|
|
|
|
|
|
|
name => $sheet->get_name(), |
|
124
|
|
|
|
|
|
|
row_count => $row_max + 1, |
|
125
|
|
|
|
|
|
|
col_count => $col_max + 1, |
|
126
|
|
|
|
|
|
|
); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
for my $row ( $row_min .. $row_max ) { |
|
129
|
|
|
|
|
|
|
for my $col ( $col_min .. $col_max ) { |
|
130
|
|
|
|
|
|
|
my $cell = $sheet->get_cell( $row, $col ); |
|
131
|
|
|
|
|
|
|
next unless $cell; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $ng_cell = NG::Excel::Cell->new( value => $cell->value(), ); |
|
134
|
|
|
|
|
|
|
$ng_sheet->{cells}->[$row][$col] = $ng_cell; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
$ng_sheet_arr->push($ng_sheet); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $ng_excel = NG::Excel->new($ng_sheet_arr); |
|
141
|
|
|
|
|
|
|
if ( defined $cb ) { |
|
142
|
|
|
|
|
|
|
$cb->($ng_excel); |
|
143
|
|
|
|
|
|
|
$ng_excel->save($filepath); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
else { |
|
146
|
|
|
|
|
|
|
return $ng_excel; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub import { |
|
151
|
|
|
|
|
|
|
my $class = shift; |
|
152
|
|
|
|
|
|
|
strict->import; |
|
153
|
|
|
|
|
|
|
warnings->import; |
|
154
|
|
|
|
|
|
|
utf8->import; |
|
155
|
|
|
|
|
|
|
feature->import(':5.10'); |
|
156
|
|
|
|
|
|
|
Try::Tiny->import; |
|
157
|
|
|
|
|
|
|
NG::Autobox::import($class); |
|
158
|
|
|
|
|
|
|
$class->export_to_level( 1, $class, @EXPORT ); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |