line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OTRS::OPM::Maker::Command::sopmtest; |
2
|
|
|
|
|
|
|
$OTRS::OPM::Maker::Command::sopmtest::VERSION = '0.19'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Check if sopm is valid |
4
|
|
|
|
|
|
|
|
5
|
16
|
|
|
16
|
|
219725
|
use strict; |
|
16
|
|
|
|
|
50
|
|
|
16
|
|
|
|
|
520
|
|
6
|
16
|
|
|
16
|
|
88
|
use warnings; |
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
440
|
|
7
|
|
|
|
|
|
|
|
8
|
16
|
|
|
16
|
|
2735
|
use Path::Class (); |
|
16
|
|
|
|
|
210437
|
|
|
16
|
|
|
|
|
333
|
|
9
|
16
|
|
|
16
|
|
4473
|
use XML::LibXML; |
|
16
|
|
|
|
|
291431
|
|
|
16
|
|
|
|
|
117
|
|
10
|
|
|
|
|
|
|
|
11
|
16
|
|
|
16
|
|
4950
|
use OTRS::OPM::Maker -command; |
|
16
|
|
|
|
|
53
|
|
|
16
|
|
|
|
|
163
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub abstract { |
14
|
1
|
|
|
1
|
1
|
3590
|
return "check .sopm if it is valid"; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub usage_desc { |
18
|
1
|
|
|
1
|
1
|
939
|
return "opmbuild sopmtest "; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub validate_args { |
22
|
8
|
|
|
8
|
1
|
9184
|
my ($self, $opt, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
8
|
100
|
100
|
|
|
160
|
$self->usage_error( 'need path to .sopm' ) if |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
25
|
|
|
|
|
|
|
!$args or |
26
|
|
|
|
|
|
|
'ARRAY' ne ref $args or |
27
|
|
|
|
|
|
|
!defined $args->[0] or |
28
|
|
|
|
|
|
|
$args->[0] !~ /\.sopm\z/ or |
29
|
|
|
|
|
|
|
!-f $args->[0]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub execute { |
33
|
7
|
|
|
7
|
1
|
7588
|
my ($self, $opt, $args) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
20
|
my $file = $args->[0]; |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
15
|
my $check_result; |
38
|
|
|
|
|
|
|
my $tree; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
eval { |
41
|
7
|
|
|
|
|
62
|
my $parser = XML::LibXML->new; |
42
|
7
|
|
|
|
|
163
|
$tree = $parser->parse_file( $file ); |
43
|
4
|
|
|
|
|
1511
|
1; |
44
|
7
|
100
|
|
|
|
14
|
} or do { print "Cannot parse .sopm: $@\n"; return }; |
|
3
|
|
|
|
|
1432
|
|
|
3
|
|
|
|
|
136
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
eval { |
47
|
4
|
|
|
|
|
7
|
my $xsd = do{ local $/; }; |
|
4
|
|
|
|
|
33
|
|
|
4
|
|
|
|
|
194
|
|
48
|
4
|
|
|
|
|
41
|
my $schema = XML::LibXML::Schema->new( string => $xsd ); |
49
|
4
|
|
|
|
|
10506
|
$schema->validate( $tree ); |
50
|
3
|
|
|
|
|
340
|
1; |
51
|
4
|
100
|
|
|
|
19
|
} or do { |
52
|
1
|
|
|
|
|
151
|
print ".sopm is not valid: $@\n"; |
53
|
1
|
|
|
|
|
121
|
return; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
105
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
OTRS::OPM::Maker::Command::sopmtest - Check if sopm is valid |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 0.19 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Renee Baecker |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Renee Baecker. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software, licensed under: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__DATA__ |