line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=begin comment |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Smartcat App |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
A simple command line application which allows to sync local files and Smartcat project content. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=end comment |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
139858
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
60
|
|
13
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Smartcat::App; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
983
|
use App::Cmd::Setup -app; |
|
2
|
|
|
|
|
69785
|
|
|
2
|
|
|
|
|
15
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
363
|
use Class::Load; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
20
|
2
|
|
|
2
|
|
1241
|
use Data::Dumper; |
|
2
|
|
|
|
|
13875
|
|
|
2
|
|
|
|
|
127
|
|
21
|
2
|
|
|
2
|
|
1013
|
use File::Copy qw/copy/; |
|
2
|
|
|
|
|
4642
|
|
|
2
|
|
|
|
|
121
|
|
22
|
2
|
|
|
2
|
|
15
|
use File::Spec::Functions qw(catfile); |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
88
|
|
23
|
2
|
|
|
2
|
|
2779
|
use IO::Uncompress::Unzip qw($UnzipError); |
|
2
|
|
|
|
|
118930
|
|
|
2
|
|
|
|
|
205
|
|
24
|
2
|
|
|
2
|
|
2114
|
use JSON qw/encode_json/; |
|
2
|
|
|
|
|
18646
|
|
|
2
|
|
|
|
|
10
|
|
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
1518
|
use Smartcat::Client::ProjectApi; |
|
2
|
|
|
|
|
153788
|
|
|
2
|
|
|
|
|
83
|
|
27
|
2
|
|
|
2
|
|
1186
|
use Smartcat::Client::DocumentApi; |
|
2
|
|
|
|
|
10080
|
|
|
2
|
|
|
|
|
67
|
|
28
|
2
|
|
|
2
|
|
1007
|
use Smartcat::Client::DocumentExportApi; |
|
2
|
|
|
|
|
2630
|
|
|
2
|
|
|
|
|
77
|
|
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
988
|
use Smartcat::Client::Object::BilingualFileImportSetingsModel; |
|
2
|
|
|
|
|
1041394
|
|
|
2
|
|
|
|
|
15
|
|
31
|
2
|
|
|
2
|
|
1265
|
use Smartcat::Client::Object::CreateDocumentPropertyModel; |
|
2
|
|
|
|
|
4946
|
|
|
2
|
|
|
|
|
13
|
|
32
|
2
|
|
|
2
|
|
1237
|
use Smartcat::Client::Object::UploadDocumentPropertiesModel; |
|
2
|
|
|
|
|
3736
|
|
|
2
|
|
|
|
|
11
|
|
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
1036
|
use Smartcat::App::ProjectApi; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
67
|
|
35
|
2
|
|
|
2
|
|
740
|
use Smartcat::App::DocumentApi; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
36
|
2
|
|
|
2
|
|
782
|
use Smartcat::App::DocumentExportApi; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
|
712
|
use Smartcat::App::Config; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
12
|
|
39
|
2
|
|
|
2
|
|
2566
|
use Log::Log4perl qw(:easy); |
|
2
|
|
|
|
|
116937
|
|
|
2
|
|
|
|
|
11
|
|
40
|
2
|
|
|
2
|
|
1523
|
use Log::Any qw($log); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
41
|
2
|
|
|
2
|
|
1636
|
use Log::Any::Adapter; |
|
2
|
|
|
|
|
770
|
|
|
2
|
|
|
|
|
9
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our $VERSION = '0.0.10'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub init { |
46
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
49
|
my $base_url = undef; |
49
|
2
|
50
|
33
|
|
|
14
|
$base_url = $self->{config}->base_url if ($self->{config}->base_url && $self->{config}->base_url ne ''); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->{api} = Smartcat::Client::ApiClient->new( |
52
|
|
|
|
|
|
|
username => $self->{config}->username, |
53
|
|
|
|
|
|
|
password => $self->{config}->password, |
54
|
2
|
|
|
|
|
70
|
base_url => $base_url, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
3755
|
my $log_level = "INFO"; |
58
|
2
|
100
|
|
|
|
11
|
if ( defined $self->{rundata}->{debug} ) { |
59
|
1
|
|
|
|
|
3
|
$log_level = "DEBUG"; |
60
|
1
|
|
|
|
|
4
|
print "*** DEBUG mode is turned on ***\n"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
19
|
my $appender = ""; |
64
|
2
|
|
|
|
|
4
|
my $filter = <<"EOT"; |
65
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfoDebug = Log::Log4perl::Filter::LevelRange |
66
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfoDebug.LevelMin = DEBUG |
67
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfoDebug.LevelMax = WARN |
68
|
|
|
|
|
|
|
log4perl.appender.screen.Filter = MatchWarnInfoDebug |
69
|
|
|
|
|
|
|
EOT |
70
|
2
|
|
|
|
|
6
|
my $logger = ""; |
71
|
2
|
50
|
33
|
|
|
9
|
if ( defined $self->{config}->log && $self->{config}->log ne "" ) { |
72
|
2
|
|
|
|
|
68
|
print "*** Printing to '$self->{config}->{log}' log file ***\n"; |
73
|
2
|
|
|
|
|
80
|
$logger = ", file"; |
74
|
2
|
|
|
|
|
10
|
$appender = <<"EOT"; |
75
|
|
|
|
|
|
|
log4perl.appender.file = Log::Log4perl::Appender::File |
76
|
|
|
|
|
|
|
log4perl.appender.file.filename = $self->{config}->{log} |
77
|
|
|
|
|
|
|
log4perl.appender.file.mode = append |
78
|
|
|
|
|
|
|
log4perl.appender.file.layout = PatternLayout |
79
|
|
|
|
|
|
|
log4perl.appender.file.layout.ConversionPattern = [%d] %p> %m%n |
80
|
|
|
|
|
|
|
EOT |
81
|
2
|
|
|
|
|
6
|
$filter = <<"EOT"; |
82
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfo = Log::Log4perl::Filter::LevelRange |
83
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfo.LevelMin = INFO |
84
|
|
|
|
|
|
|
log4perl.filter.MatchWarnInfo.LevelMax = WARN |
85
|
|
|
|
|
|
|
log4perl.appender.screen.Filter = MatchWarnInfo |
86
|
|
|
|
|
|
|
EOT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
39
|
Log::Log4perl->init( \ <<"EOT"); |
91
|
|
|
|
|
|
|
log4perl.logger = $log_level, screen $logger |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
log4perl.appender.screen = Log::Log4perl::Appender::Screen |
94
|
|
|
|
|
|
|
log4perl.appender.screen.stderr = 0 |
95
|
|
|
|
|
|
|
log4perl.appender.screen.layout = PatternLayout |
96
|
|
|
|
|
|
|
log4perl.appender.screen.layout.ConversionPattern = %m%n |
97
|
|
|
|
|
|
|
$filter |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$appender |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
EOT |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
26809
|
Log::Any::Adapter->set('Log::Log4perl'); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub new { |
107
|
4
|
|
|
4
|
1
|
4782
|
my ( $class, $arg ) = @_; |
108
|
|
|
|
|
|
|
|
109
|
4
|
|
|
|
|
28
|
my $self = $class->SUPER::new($arg); |
110
|
4
|
|
|
|
|
11738
|
$self->{config} = Smartcat::App::Config->load; |
111
|
4
|
|
|
|
|
11
|
$self->{rundata} = {}; |
112
|
|
|
|
|
|
|
|
113
|
4
|
|
|
|
|
14
|
return $self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub project_api { |
117
|
4
|
|
|
4
|
0
|
730
|
my $self = shift @_; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$self->{project_api} = |
120
|
|
|
|
|
|
|
Smartcat::App::ProjectApi->new( $self->{api}, $self->{rundata} ) |
121
|
4
|
100
|
|
|
|
38
|
unless defined $self->{project_api}; |
122
|
4
|
|
|
|
|
19
|
return $self->{project_api}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub document_api { |
126
|
2
|
|
|
2
|
0
|
4
|
my $self = shift @_; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$self->{document_api} = |
129
|
|
|
|
|
|
|
Smartcat::App::DocumentApi->new( $self->{api}, $self->{rundata} ) |
130
|
2
|
100
|
|
|
|
18
|
unless defined $self->{document_api}; |
131
|
2
|
|
|
|
|
13
|
return $self->{document_api}; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub document_export_api { |
135
|
2
|
|
|
2
|
0
|
5
|
my $self = shift @_; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$self->{document_export_api} = |
138
|
|
|
|
|
|
|
Smartcat::App::DocumentExportApi->new( $self->{api}, $self->{rundata} ) |
139
|
2
|
100
|
|
|
|
15
|
unless defined $self->{document_export_api}; |
140
|
2
|
|
|
|
|
12
|
return $self->{document_export_api}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
__END__ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=encoding utf-8 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 NAME |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Smartcat::App - Smartcat cli application |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SYNOPSIS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
use Smartcat::App; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 DESCRIPTION |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Smartcat::App is a simple application which use Smartcat Integration API to sync local translation files with Smartcat project content. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Taras Semenenko E<lt>taras.semenenko@gmail.comE<gt> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 LICENSE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
167
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Smartcat::Client |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |