Skip to content

Commit

Permalink
pure ruby installer for vimball archives
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Sep 6, 2010
1 parent 66d6601 commit 6ae5611
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Rakefile
Expand Up @@ -45,9 +45,33 @@ def vim_plugin_task(name, repo=nil)
sh "mv #{dirname} #{dir}"

when /vba(\.gz)?$/
system "vim -c 'so %' -c 'q' tmp/#{filename}"
rm "tmp/#{File.basename(filename, '.gz')}" if filename =~ /gz$/
mkdir_p dir # TODO: hax, this needs to exist for :install task later
if filename =~ /gz$/
sh "gunzip -f tmp/#{filename}"
filename = File.basename(filename, '.gz')
end

# TODO: move this into the install task
mkdir_p dir
lines = File.readlines("tmp/#{filename}")
current = lines.shift until current =~ /finish$/ # find finish line

while current = lines.shift
# first line is the filename, followed by some unknown data
file = current[/^(.+?)\s+\[\[\[(\d+)$/, 1]

# then the size of the payload in lines
current = lines.shift
num_lines = current[/^(\d+)$/, 1].to_i

# the data itself
data = lines.slice!(0, num_lines)

# install the data
Dir.chdir dir do
mkdir_p File.dirname(file)
File.open(file, 'w'){ |f| f.write(data) }
end
end
end
end

Expand Down

0 comments on commit 6ae5611

Please sign in to comment.