Skip to content

Commit

Permalink
Import of CORNELIUS/VIM-Uploader-0.07 from CPAN.
Browse files Browse the repository at this point in the history
gitpan-cpan-distribution: VIM-Uploader
gitpan-cpan-version:      0.07
gitpan-cpan-path:         CORNELIUS/VIM-Uploader-0.07.tar.gz
gitpan-cpan-author:       CORNELIUS
gitpan-cpan-maturity:     released
  • Loading branch information
Yo-An Lin (林佑安) authored and Gitpan committed Oct 25, 2014
1 parent 463c2f6 commit 1266bd6
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Makefile.PL
README.mkd
lib/VIM/Uploader.pm
t/00-load.t
bin/vim-upload-new
bin/vim-upload
META.yml Module meta-data (added by MakeMaker)
2 changes: 1 addition & 1 deletion META.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: VIM-Uploader
version: 0.06
version: 0.07
abstract: upload your vim script to vim.org
author:
- Cornelius <cornelius.howl@gmail.com>
Expand Down
137 changes: 137 additions & 0 deletions bin/vim-upload
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env perl
# vim:fdm=marker:fdl=0:
use warnings;
use strict;
use VIM::Uploader;
#use File::Temp 'tempfile';
use Cwd qw(abs_path);

my $pwd = qx(pwd);
my $basename = qx(basename $pwd);
chomp($basename,$pwd);
my $upload_template = "$basename.upload";

if( ! -e $upload_template ) {
my $dist = shift @ARGV;
unless( $dist ) {
print "Usage:\n";
print " vim-upload path/to/your_script_dist_file\n";
exit;
}

$dist = abs_path( $dist );

if( ! -e $dist ) {
die "$dist doesnot exist.";
}

print "Going to upload $dist file.";
# {{{
open FH, ">" , $upload_template;
print FH <<END;
script_name:
[script name]
script_file:
$dist
script_type:
color scheme
ftplugin
game
indent
syntax
utility
patch
vim_version:
5.7
6.0
7.0
7.2
script_id:
script_version:
0.1
summary:
[summary]
description:
[description]
install_details:
[install details]
version_note:
END
close FH;
system( qq(vim $upload_template) );
# }}}
}

open FH , "<" , $upload_template;
local $/;
my $content = <FH>;
close FH;

# parse content
my @lines = split /\n/,$content;

my $section;
my %parts;
my @buffer;

sub flush_buffer {
my ($section) = @_;
if( @buffer and $section ) {
$parts{ $section } = join "\n", @buffer;
@buffer = ( );
}
}

for my $l ( @lines ) {
if ( $l =~ m{^(\w+):\s*$} ) {
flush_buffer( $section );
$section = $1;
next;
}
else {
push @buffer,$l;
}
}
flush_buffer( $section );

# oneline arguments
for ( qw(script_name script_file script_id script_type vim_version script_version) ) {
$parts{ $_ } =~ s{\n}{}g;
$parts{ $_ } =~ s{^\s*}{}g;
$parts{ $_ } =~ s{\s*$}{}g;
}

$parts{ script_name } =~ s{\s}{-}g;

my $uploader = VIM::Uploader->new();
$uploader->login();
if( $parts{script_id} ) {
$uploader->upload(
%parts,
version_comment =>
$parts{'version_note_'.$parts{script_version}}
|| $parts{version_note}
);
}
else{
$uploader->upload_new( %parts );
}
print "Done";
6 changes: 3 additions & 3 deletions lib/VIM/Uploader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ VIM::Uploader - upload your vim script to vim.org
=cut

our $VERSION = '0.06';
our $VERSION = '0.07';

=head1 SYNOPSIS
Expand Down Expand Up @@ -49,8 +49,8 @@ it creates a upload form template for you.
$ vim-upload script-2.04.tar.gz
then the file L<script.vim.upload> will be created after the first upload. just edit the file and the next time
you can upload script easily.
then the file L<script.vim.upload> will be created after the first upload. just edit the file , update script_id
and the next time you can upload script easily.
$ vim-upload script.vim
Expand Down

0 comments on commit 1266bd6

Please sign in to comment.