line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EPublisher; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Publish documents in new format |
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
202464
|
use strict; |
|
9
|
|
|
|
|
44
|
|
|
9
|
|
|
|
|
266
|
|
6
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
252
|
|
7
|
9
|
|
|
9
|
|
45
|
use Carp; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
548
|
|
8
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
3617
|
use EPublisher::Config; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
292
|
|
10
|
9
|
|
|
9
|
|
3729
|
use EPublisher::Source; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
265
|
|
11
|
9
|
|
|
9
|
|
3067
|
use EPublisher::Target; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
6854
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 1.27; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new{ |
16
|
9
|
|
|
9
|
1
|
5605
|
my ($class,%args) = @_; |
17
|
9
|
|
|
|
|
29
|
my $self = bless {}, $class; |
18
|
|
|
|
|
|
|
|
19
|
9
|
100
|
|
|
|
41
|
$self->config( $args{config} ) if exists $args{config}; |
20
|
9
|
|
|
|
|
42
|
$self->_debug( $args{debug} ); |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
30
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub config{ |
26
|
18
|
|
|
18
|
1
|
492
|
my ($self,$data) = @_; |
27
|
|
|
|
|
|
|
|
28
|
18
|
|
|
|
|
35
|
my $ref = ref $data; |
29
|
18
|
100
|
100
|
|
|
104
|
if( defined $data and !$ref ){ |
|
|
100
|
100
|
|
|
|
|
30
|
4
|
|
|
|
|
11
|
$self->{_configfile} = $data; |
31
|
4
|
|
|
|
|
13
|
$self->_config(1); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( $ref and $ref eq 'HASH' ) { |
34
|
1
|
|
|
|
|
3
|
$self->_config( 1, $data ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
18
|
|
|
|
|
70
|
return $self->{_configfile}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub projects { |
41
|
3
|
|
|
3
|
1
|
9
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
8
|
my $config = $self->_config; |
44
|
|
|
|
|
|
|
|
45
|
3
|
100
|
|
|
|
16
|
return if !ref $config; |
46
|
2
|
100
|
|
|
|
9
|
return if ref $config ne 'HASH'; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
2
|
return keys %{$config}; |
|
1
|
|
|
|
|
8
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub run{ |
52
|
11
|
|
|
11
|
1
|
1037
|
my ($self,$projects) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
PROJECT: |
55
|
11
|
|
|
|
|
25
|
for my $project ( @$projects ) { |
56
|
11
|
|
|
|
|
24
|
my $config = $self->_config->{$project}; |
57
|
|
|
|
|
|
|
|
58
|
11
|
100
|
|
|
|
32
|
next PROJECT if !$config; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# load the source |
61
|
10
|
100
|
|
|
|
28
|
next PROJECT if !exists $config->{source}; |
62
|
|
|
|
|
|
|
|
63
|
9
|
|
|
|
|
18
|
my $sources = $config->{source}; |
64
|
9
|
100
|
|
|
|
24
|
next PROJECT if !ref $sources; |
65
|
|
|
|
|
|
|
|
66
|
8
|
100
|
|
|
|
26
|
$sources = [ $sources ] if ref $sources ne 'ARRAY'; |
67
|
|
|
|
|
|
|
|
68
|
8
|
100
|
|
|
|
23
|
next PROJECT if !exists $config->{target}; |
69
|
7
|
100
|
|
|
|
22
|
next PROJECT if !$config->{target}->{type}; |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
7
|
my @pods; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
SOURCE: |
74
|
6
|
|
|
|
|
13
|
for my $source ( @{$sources} ) { |
|
6
|
|
|
|
|
12
|
|
75
|
6
|
100
|
|
|
|
29
|
die 'No type in source.' if !length $source->{type}; |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
22
|
$self->debug('100: ' . $source->{type} ); |
78
|
|
|
|
|
|
|
|
79
|
5
|
|
|
|
|
37
|
my $source_obj = EPublisher::Source->new( $source ); |
80
|
5
|
|
|
|
|
37
|
$source_obj->publisher( $self ); |
81
|
|
|
|
|
|
|
|
82
|
5
|
|
|
|
|
20
|
my @pod_source = $source_obj->load_source; |
83
|
|
|
|
|
|
|
|
84
|
5
|
100
|
|
|
|
55
|
next SOURCE if !@pod_source; |
85
|
|
|
|
|
|
|
|
86
|
3
|
|
|
|
|
9
|
@pod_source = grep { $_->{pod} }@pod_source; |
|
3
|
|
|
|
|
12
|
|
87
|
|
|
|
|
|
|
|
88
|
3
|
|
|
|
|
9
|
$self->debug('101: ' . substr join( "", map{ $_->{pod} }@pod_source ), 0, 50 ); |
|
3
|
|
|
|
|
30
|
|
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
44
|
push @pods, @pod_source; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
5
|
100
|
|
|
|
20
|
next PROJECT if !@pods; |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
14
|
$config->{target}->{source} = \@pods; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# deploy the project |
98
|
3
|
|
|
|
|
25
|
$self->debug('200: ' . $config->{target}->{type} ); |
99
|
3
|
|
|
|
|
30
|
my $target = EPublisher::Target->new( $config->{target} ); |
100
|
3
|
|
|
|
|
16
|
$target->publisher( $self ); |
101
|
3
|
|
|
|
|
16
|
$target->deploy; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
10
|
|
|
|
|
116
|
return 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _debug{ |
108
|
11
|
|
|
11
|
|
44
|
my ($self,$ref) = @_; |
109
|
|
|
|
|
|
|
|
110
|
11
|
100
|
100
|
|
|
109
|
if( @_ == 2 and ref($ref) eq 'CODE' ){ |
111
|
2
|
|
|
|
|
6
|
$self->{__debug} = $ref; |
112
|
2
|
|
|
|
|
5
|
$self->{DEBUG} = 1; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
11
|
|
|
|
|
41
|
return $self->{__debug}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub debug { |
119
|
13
|
|
|
13
|
1
|
33
|
my ($self,$message) = @_; |
120
|
|
|
|
|
|
|
|
121
|
13
|
100
|
|
|
|
41
|
return if !$self->{DEBUG}; |
122
|
7
|
|
|
|
|
27
|
$self->{__debug}->($message); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _config{ |
126
|
26
|
|
|
26
|
|
1687
|
my ($self,$bool,$data) = @_; |
127
|
|
|
|
|
|
|
|
128
|
26
|
100
|
100
|
|
|
177
|
if ( $bool and $data ) { |
|
|
100
|
100
|
|
|
|
|
129
|
3
|
|
|
|
|
9
|
$self->{__config} = $data; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif( !$self->{__config} or $bool ){ |
132
|
6
|
100
|
|
|
|
22
|
unless( $self->config ){ |
133
|
1
|
|
|
|
|
144
|
croak "no config file given!"; |
134
|
|
|
|
|
|
|
} |
135
|
5
|
|
|
|
|
26
|
$self->{__config} = EPublisher::Config->get_config( $self->config ); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
25
|
|
|
|
|
82
|
return $self->{__config}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |