Permalink
Browse files

we should only read version from file

  • Loading branch information...
1 parent 174311e commit 94e011297b4d7f689a4e84af4c4db5737e2190bf @c9s c9s committed Oct 26, 2009
Showing with 39 additions and 16 deletions.
  1. +7 −10 doc/META
  2. +21 −3 lib/VIM/Packager/MetaReader.pm
  3. +11 −3 t/00-meta.t
View
@@ -1,6 +1,4 @@
-
-
# sample meta file
=name new_plugin
@@ -11,17 +9,13 @@
# author name
-=version 0.1
-
- # version of your plugin
+=type syntax|plugin|autoload|ftplugin|doc|compiler|indent
-=version plugin/new_plugin.vim
-
- # extract version infomation from this file
+ # type
-=type syntax|plugin|autoload|ftplugin|doc|compiler|indent
+=version_from vimlib/plugin/new_plugin.vim
- # type
+ # extract version infomation from this file
=vim_version >= 7.0
@@ -53,6 +47,9 @@
# then get the file from url and put it into "$vimruntime/autoload"
# directory
# for plugins which can't detect version.
+ #
+ # | $(VIM_BASEDIR)/autoload/libperl.vim | http://github.com/c9s/libperl.vim/raw/master/autoload/libperl.vim
+ # XXX: we should support this.
libperl.vim > 0.2 | http://path/to/package/package.tar.gz
@@ -57,14 +57,19 @@ sub read {
if ( /^=(\w+)/ ) {
my $dispatch = '__' . $1;
- $class->$dispatch( $_ , \@lines , $idx );
+ if( $class->can( $dispatch ) ) {
+ $class->$dispatch( $_ , \@lines , $idx );
+ }
+ else {
+ print "meta tag $1 is not supported.\n";
+ }
}
}
# check for mandatory meta info
my $fall;
my $meta = $class->meta;
- for ( qw(name author version_from type vim_version) ) {
+ for ( qw(name author version type vim_version) ) {
if( ! defined $meta->{ $_ } ) {
print STDOUT "META: column '$_' is required. ";
$fall = 1;
@@ -94,7 +99,20 @@ sub __author {
sub __version_from {
my ($self,$cur,$lines,$idx) = @_;
- $self->meta->{version} = _get_value( $cur );
+ my $version_file = _get_value( $cur );
+ open FH, "<" , $version_file;
+ my @lines = <FH>;
+ close FH;
+
+ for ( @lines ) {
+ if( /^"=VERSION/ ) {
+ my $line = $_;
+ chomp $line;
+ $line =~ s/^"//;
+ $self->meta->{version} = _get_value( $line );
+ last;
+ }
+ }
}
sub __type {
View
@@ -7,6 +7,14 @@ BEGIN {
};
+open FH , ">" , "test.vim";
+print FH <<END;
+
+"=VERSION 0.3
+
+END
+close FH;
+
my $sample =<<END;
# comment
@@ -16,8 +24,7 @@ my $sample =<<END;
# comment
=author Cornelius (cornelius.howl\@gmail.com)
-=version 0.1
-=version plugin/new_plugin.vim # extract version infomation from this file
+=version_from test.vim # extract version infomation from this file
=vim_version < 7.2
=type syntax
=dependency
@@ -82,7 +89,8 @@ is( $meta_object->{repository} , 'git://....../' );
is( $meta_object->{author} , 'Cornelius (cornelius.howl@gmail.com)' );
is( $meta_object->{type} , 'syntax' );
is( $meta_object->{name} , 'new_plugin' );
-is( $meta_object->{version} , 'plugin/new_plugin.vim' );
+is( $meta_object->{version} , 0.3 );
is_deeply( $meta_object->{script}, [ 'bin/parser', 'bin/template_generator' ]);
+unlink 'test.vim';

0 comments on commit 94e0112

Please sign in to comment.