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
Original file line number Diff line number Diff line change
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

3 comments on commit 6ae5611

@bronson
Copy link

@bronson bronson commented on 6ae5611 Dec 8, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tmm1
Copy link
Contributor Author

@tmm1 tmm1 commented on 6ae5611 Dec 8, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tmm1
Copy link
Contributor Author

@tmm1 tmm1 commented on 6ae5611 Dec 8, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up committing fe8e7a9, thanks!

Please sign in to comment.