vimbrew 0.0.1.a.2 → 0.0.1.a.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,6 @@ module Vimbrew::Downloaders
2
2
 
3
3
  require 'vimbrew/downloaders/abstract'
4
4
  require 'vimbrew/downloaders/git'
5
+ require 'vimbrew/downloaders/vim_org'
5
6
 
6
7
  end
@@ -0,0 +1,48 @@
1
+ class Vimbrew::Downloaders::VimOrg < Vimbrew::Downloaders::Abstract
2
+
3
+ def initialize(url, options={})
4
+ @id = File.basename(url.path)
5
+ @id, @type = @id.split('.', 2)
6
+ end
7
+
8
+ def fetch_into(shell, dst)
9
+ @shell = shell
10
+ dst.dirname.mkpath
11
+ dst.rmtree rescue nil
12
+
13
+ tmp_dst = dst.dirname + (dst.basename.to_s + '.vimbrew_tmp')
14
+ tmp_dst.rmtree rescue nil
15
+ tmp_dst.mkpath
16
+
17
+ plugin_dir = nil
18
+
19
+ Dir.chdir(tmp_dst) do
20
+ sh("wget -O #{@id}.#{@type} http://www.vim.org/scripts/download_script.php?src_id=#{@id}")
21
+
22
+ download = tmp_dst.children.first
23
+ case @type
24
+ when 'vim'
25
+ (tmp_dst + 'tmp/plugin').mkpath
26
+ download.rename(tmp_dst + 'tmp/plugin' + download.basename.to_s)
27
+ plugin_dir = tmp_dst + 'tmp'
28
+ when 'zip'
29
+ sh("unzip #{download}")
30
+ download.unlink
31
+ plugin_dir = tmp_dst.children.first
32
+ when 'tar.gz'
33
+ sh("tar xzf #{download}")
34
+ download.unlink
35
+ plugin_dir = tmp_dst.children.first
36
+ end
37
+ end
38
+
39
+ plugin_dir.rename(dst) if plugin_dir and plugin_dir.directory?
40
+ ensure
41
+ tmp_dst.rmtree rescue nil
42
+ end
43
+
44
+ def version
45
+ @id.to_s
46
+ end
47
+
48
+ end
@@ -21,6 +21,7 @@ class Vimbrew::Recipe
21
21
  url = URI.parse(value)
22
22
  @fetcher = case url.scheme
23
23
  when 'git' then Vimbrew::Downloaders::Git.new(url, options)
24
+ when 'vim' then Vimbrew::Downloaders::VimOrg.new(url, options)
24
25
  else raise "Cannot fetch url #{url}"
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module Vimbrew
2
- VERSION = '0.0.1.a.2'
2
+ VERSION = '0.0.1.a.3'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimbrew
3
3
  version: !ruby/object:Gem::Version
4
- hash: 121
4
+ hash: 123
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 1
10
10
  - a
11
- - 2
12
- version: 0.0.1.a.2
11
+ - 3
12
+ version: 0.0.1.a.3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Simon Menke
@@ -56,6 +56,7 @@ files:
56
56
  - lib/vimbrew/commands.rb
57
57
  - lib/vimbrew/downloaders/abstract.rb
58
58
  - lib/vimbrew/downloaders/git.rb
59
+ - lib/vimbrew/downloaders/vim_org.rb
59
60
  - lib/vimbrew/downloaders.rb
60
61
  - lib/vimbrew/environment.rb
61
62
  - lib/vimbrew/recipe.rb