Permalink
Browse files

pure ruby installer for vimball archives

  • Loading branch information...
1 parent 66d6601 commit 6ae56116aa9f1cd65af43bd550405295ff2f5967 @tmm1 tmm1 committed Sep 6, 2010
Showing with 27 additions and 3 deletions.
  1. +27 −3 Rakefile
View
@@ -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

3 comments on commit 6ae5611

There is a problem with this line:

        file = current[/^(.+?)\s+\[\[\[(\d+)$/, 1]

A lot of vimballs don't have that garbage at the end. The following code is more similar to vimball itself and works for all vimballs on vim-scripts.org:

    file_name = current
    file_name.sub! /\t\[\[\[1$/, ''
    file_name.gsub! '\\', '/'

That last line is because 16 vimballs separate paths with .

By the way, great idea! It's really improved the vim-scripts.org scraper. vim-scraper/vim-scraper@f395205#L0R900

Contributor

tmm1 replied Dec 8, 2010

Great. Any chance you can submit a patch/pull-request, or just open a ticket so I don't forget about this.

Contributor

tmm1 replied Dec 8, 2010

I ended up committing fe8e7a9, thanks!

Please sign in to comment.