line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VIM::Packager::MetaReader; |
2
|
2
|
|
|
2
|
|
26631
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1696
|
use YAML; |
|
2
|
|
|
|
|
24114
|
|
|
2
|
|
|
|
|
350
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub trim_comment { |
8
|
42
|
|
|
42
|
0
|
51
|
my $c = shift; |
9
|
42
|
|
|
|
|
53
|
$c =~ s/#.*$//; # skip comment |
10
|
42
|
|
|
|
|
87
|
return $c; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub trim { |
14
|
44
|
|
|
44
|
0
|
46
|
my $c = shift; |
15
|
44
|
|
|
|
|
111
|
$c =~ s/^\s*//; |
16
|
44
|
|
|
|
|
172
|
$c =~ s/\s*$//; |
17
|
44
|
|
|
|
|
79
|
return $c; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 Synopsis |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Generic VIM Meta file format |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=name new_plugin |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=abstract vim plugin blah blah blah |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=author Cornelius (cornelius.howl@gmail.com) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=version_from plugin/new_plugin.vim # extract version infomation from this file |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=type syntax |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=script_id [script id on vim.org] # for uploading script to vim.org |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=dependency |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
autocomplpop.vim > 0.3 |
41
|
|
|
|
|
|
|
rainbow.vim >= 1.2 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
libperl.vim |
44
|
|
|
|
|
|
|
| autoload/libperl.vim | http://....../..././.../libperl.vim |
45
|
|
|
|
|
|
|
| autoload/std.vim | http://....../..././.../std.vim |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
cpan.vim > 0 |
48
|
|
|
|
|
|
|
git://github.com/c9s/cpan.vim.git # install from git repository |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=libpath . |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=script |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
bin/parser |
55
|
|
|
|
|
|
|
bin/template_generator |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=repository git://....../ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 Description |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 Constant |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 META_FILES |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
available metafile names: F, F, F |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
2
|
|
21
|
use constant META_FILES => [ 'VIMMETA','META','VIMMETA.yml']; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
3450
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 Functions |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 new |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
1
|
1
|
1881
|
sub new { bless {} , shift } |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 meta |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
15
|
|
100
|
15
|
1
|
22
|
sub meta { my $self = shift; return $self->{meta} ||= {}; } |
|
15
|
|
|
|
|
73
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 read_metafile |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
read_metafile function tries to find available vim meta file |
90
|
|
|
|
|
|
|
and parse meta file into hashref. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return meta information in hashref. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub read_metafile { |
97
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
98
|
|
|
|
|
|
|
# read meta_reader file |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
0
|
my $file = $self->find_meta_file(); |
101
|
0
|
0
|
|
|
|
0
|
die 'Can not found META file' unless -e $file; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
open my $fh , "<" , $file ; |
104
|
0
|
|
|
|
|
0
|
$self->read( $fh ); |
105
|
0
|
|
|
|
|
0
|
close $fh; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
return $self->meta; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 find_meta_file |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
find_meta_file function tries to find available vim meta file |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
return the filename of vim meta file (string) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub find_meta_file { |
119
|
0
|
|
|
0
|
1
|
0
|
my $files = META_FILES; |
120
|
0
|
|
|
|
|
0
|
for ( @$files ) { |
121
|
0
|
0
|
|
|
|
0
|
return $_ if -e $_; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub read { |
128
|
1
|
|
|
1
|
0
|
405
|
my $self = shift; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
2
|
my $fh = shift; |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
25
|
my @lines = <$fh>; |
133
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
3
|
my $cur_section; |
135
|
1
|
|
|
|
|
3
|
my %sections = (); |
136
|
1
|
|
|
|
|
3
|
for ( @lines ) { |
137
|
42
|
|
|
|
|
44
|
chomp; |
138
|
42
|
|
|
|
|
65
|
$_ = trim trim_comment($_); |
139
|
42
|
100
|
|
|
|
72
|
next if blank($_); |
140
|
|
|
|
|
|
|
|
141
|
21
|
100
|
|
|
|
72
|
if( /^=(\w+)(?:\s+(.*?))?$/ ) { |
142
|
10
|
|
|
|
|
18
|
$cur_section = $1; |
143
|
10
|
100
|
|
|
|
31
|
$sections{$cur_section} = $2 if $2; |
144
|
10
|
|
|
|
|
13
|
next; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
11
|
|
|
|
|
11
|
push @{ $sections{ $cur_section } } , $_; |
|
11
|
|
|
|
|
29
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
6
|
for my $sec ( keys %sections ) { |
152
|
10
|
|
|
|
|
12
|
my $lines = $sections{ $sec }; |
153
|
10
|
|
|
|
|
16
|
my $dispatch = '__' . $sec; |
154
|
10
|
50
|
|
|
|
39
|
if( $self->can( $dispatch ) ) { |
155
|
10
|
|
|
|
|
29
|
$self->$dispatch( $lines ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
|
|
|
|
|
|
# print "Meta tag $sec is not supported. but we will still save to Makefile\n"; |
159
|
0
|
|
|
|
|
0
|
$self->{meta}->{ $sec } = $lines; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
=pod |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# XXX: check for mandatory meta info |
166
|
|
|
|
|
|
|
my $fall; |
167
|
|
|
|
|
|
|
my $meta = $class->meta; |
168
|
|
|
|
|
|
|
for ( qw(name author version type vim_version) ) { |
169
|
|
|
|
|
|
|
if( ! defined $meta->{ $_ } ) { |
170
|
|
|
|
|
|
|
print STDOUT "META: column '$_' is required. "; |
171
|
|
|
|
|
|
|
$fall = 1; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
die if $fall; |
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $package_re = '[0-9a-zA-Z._-]+'; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub blank { |
183
|
42
|
|
|
42
|
0
|
44
|
my $c = shift; |
184
|
42
|
|
|
|
|
152
|
return $c =~ /^\s*$/; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _get_value { |
189
|
0
|
|
|
0
|
|
0
|
my $cur = shift; |
190
|
0
|
|
|
|
|
0
|
my ($v) = ( $cur =~ /^=\w+\s+(.*)$/ ) ; |
191
|
0
|
|
|
|
|
0
|
return $v; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub __name { |
195
|
1
|
|
|
1
|
|
2
|
my ($self,$value) = @_; |
196
|
1
|
|
|
|
|
2
|
$self->meta->{name} =$value; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub __email { |
200
|
0
|
|
|
0
|
|
0
|
my ($self,$value) = @_; |
201
|
0
|
|
|
|
|
0
|
$self->meta->{email} =$value; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub __author { |
205
|
1
|
|
|
1
|
|
2
|
my ($self,$value) = @_; |
206
|
1
|
|
|
|
|
2
|
$self->meta->{author} =$value; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub __version { |
210
|
1
|
|
|
1
|
|
2
|
my ($self,$value) = @_; |
211
|
1
|
|
|
|
|
3
|
$self->meta->{version} = $value; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub __abstract { |
215
|
0
|
|
|
0
|
|
0
|
my ($self,$value) = @_; |
216
|
0
|
|
|
|
|
0
|
$self->meta->{abstract} =$value; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub __type { |
220
|
1
|
|
|
1
|
|
2
|
my ($self,$value) = @_; |
221
|
1
|
|
|
|
|
3
|
$self->meta->{type} =$value; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub __libpath { |
225
|
0
|
|
|
0
|
|
0
|
my ($self,$value) = @_; |
226
|
0
|
|
|
|
|
0
|
$self->meta->{libpath} =$value; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub __version_from { |
230
|
1
|
|
|
1
|
|
2
|
my ($self,$version_file) = @_; |
231
|
|
|
|
|
|
|
|
232
|
1
|
|
|
|
|
4
|
$self->meta->{version_from} = $version_file; |
233
|
|
|
|
|
|
|
|
234
|
1
|
|
|
|
|
46
|
open FH, "<" , $version_file; |
235
|
1
|
|
|
|
|
26
|
my @lines = ; |
236
|
1
|
|
|
|
|
13
|
close FH; |
237
|
|
|
|
|
|
|
|
238
|
1
|
|
|
|
|
3
|
for ( @lines ) { |
239
|
2
|
100
|
66
|
|
|
13
|
if( /^"=VERSION ([0-9.]+)$/ or /^"\s*Version:\s*([0-9.]+)$/i ) { |
240
|
1
|
|
|
|
|
3
|
$self->meta->{version} = $1; |
241
|
1
|
|
|
|
|
4
|
return; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
} |
244
|
0
|
|
|
|
|
0
|
print "Warning: Can not found version, you should declare your version in your vim script.\n"; |
245
|
0
|
|
|
|
|
0
|
print "For example \n"; |
246
|
0
|
|
|
|
|
0
|
print " \" Version: 0.3 \n"; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 __install_dirs |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
if you don't like F |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub __install_dirs { |
256
|
1
|
|
|
1
|
|
3
|
my ($self,$lines) = @_; |
257
|
1
|
|
|
|
|
3
|
$self->meta->{install_dirs} = []; |
258
|
1
|
|
|
|
|
2
|
for ( @$lines ) { |
259
|
2
|
|
|
|
|
5
|
$_ = trim $_; |
260
|
2
|
50
|
|
|
|
5
|
push @{ $self->meta->{install_dirs} },$_ if $_; |
|
2
|
|
|
|
|
4
|
|
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub __dependency { |
265
|
1
|
|
|
1
|
|
2
|
my ( $self, $lines ) = @_; |
266
|
1
|
|
|
|
|
18
|
$self->meta->{dependency} = []; |
267
|
|
|
|
|
|
|
|
268
|
1
|
|
|
|
|
3
|
my %pkgs = (); |
269
|
1
|
|
|
|
|
54
|
my $cur_name; |
270
|
1
|
|
|
|
|
2
|
for ( @$lines ) { |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# for lines like: |
273
|
|
|
|
|
|
|
# plugin.vim > 1.0 |
274
|
7
|
100
|
|
|
|
136
|
if( m{^ ($package_re) \s+ ([=<>]{1,2}) \s+ ([0-9.]+) }x ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
275
|
3
|
|
|
|
|
9
|
my ( $name, $op, $version ) = ( $1, $2, $3 ); |
276
|
3
|
|
|
|
|
5
|
$cur_name = $name; |
277
|
3
|
|
|
|
|
13
|
$pkgs{ $name } = { |
278
|
|
|
|
|
|
|
name => $name, |
279
|
|
|
|
|
|
|
op => $op, |
280
|
|
|
|
|
|
|
version => $version, |
281
|
|
|
|
|
|
|
}; |
282
|
3
|
|
|
|
|
7
|
next; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# for lines like: |
286
|
|
|
|
|
|
|
# plugin.vim |
287
|
|
|
|
|
|
|
# | plugin/plugin.vim | http://...../.../plugin.vim |
288
|
|
|
|
|
|
|
elsif( m{^($package_re)$} ) { |
289
|
1
|
|
|
|
|
2
|
$cur_name = $1; |
290
|
1
|
|
|
|
|
4
|
$pkgs{ $cur_name } = []; |
291
|
1
|
|
|
|
|
3
|
next; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
elsif( m{^\|\s*(.*?)\s*\|\s*(\S+)} ) { |
294
|
2
|
|
|
|
|
5
|
my ( $target, $from ) = ( $1, $2 ); |
295
|
2
|
|
|
|
|
8
|
push @{ $pkgs{ $cur_name } } , { from => $from , target => $target }; |
|
2
|
|
|
|
|
9
|
|
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# from git repository |
299
|
|
|
|
|
|
|
elsif( m{^git://} ) { |
300
|
1
|
|
|
|
|
2
|
my $git_repo = $_; |
301
|
1
|
|
|
|
|
4
|
$pkgs{ $cur_name }->{git_repo} = $git_repo; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
1
|
|
|
|
|
6
|
$self->meta->{dependency} = [ |
306
|
4
|
|
|
|
|
11
|
map( { { name => $_, required_files => $pkgs{$_} } } grep { ref( $pkgs{$_} ) eq 'ARRAY' } keys %pkgs ), |
|
3
|
|
|
|
|
7
|
|
307
|
1
|
|
|
|
|
4
|
map( { $pkgs{$_} } grep { ref( $pkgs{$_} ) ne 'ARRAY' } keys %pkgs ), |
|
4
|
|
|
|
|
7
|
|
308
|
|
|
|
|
|
|
]; |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub __script { |
313
|
1
|
|
|
1
|
|
3
|
my ( $self, $lines ) = @_; |
314
|
1
|
|
|
|
|
4
|
$self->meta->{script} = $lines; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub __repository { |
318
|
1
|
|
|
1
|
|
2
|
my ( $self, $value ) = @_; |
319
|
1
|
|
|
|
|
3
|
$self->meta->{repository} = $value; |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
sub __vim_version { |
323
|
1
|
|
|
1
|
|
8
|
my ( $self , $v ) = @_; |
324
|
1
|
|
|
|
|
5
|
my ( $op , $version ) = $v =~ m/^([<=>]{1,2})\s+([0-9.-a-z]+)/; |
325
|
1
|
|
|
|
|
5
|
$self->meta->{vim_version} = { |
326
|
|
|
|
|
|
|
op => $op, |
327
|
|
|
|
|
|
|
version => $version, |
328
|
|
|
|
|
|
|
}; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
# some alias |
332
|
|
|
|
|
|
|
# .... |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
1; |