infect 0.0.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05d75015caec374001e4358c43d235a82d35b363
4
+ data.tar.gz: 9e5ea3749966f1bc0650aaffb5e0861c454bb89b
5
+ SHA512:
6
+ metadata.gz: e96756c93fa19f14ee5f4b772f13d4abebb3417b8bf46cbfd577048a47fa500769e968d33188feb08f1001c6de728ece48a6f5d507b1b5d028a7ab9d196e36e9
7
+ data.tar.gz: d02ef3b339747ae14051c06c0a1bec0ec862125c1d3a62fb1f870b89d284e35a2d67975775d96bef742fd2bf39d942d87540401c8cede694df73ce076124d938
@@ -1,18 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- infect (0.0.4)
4
+ infect (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ byebug (2.7.0)
10
+ columnize (~> 0.3)
11
+ debugger-linecache (~> 1.2)
9
12
  coderay (1.0.9)
13
+ columnize (0.9.0)
14
+ debugger-linecache (1.2.0)
10
15
  diff-lcs (1.1.3)
11
16
  method_source (0.8.1)
12
17
  pry (0.9.12.2)
13
18
  coderay (~> 1.0.5)
14
19
  method_source (~> 0.8)
15
20
  slop (~> 3.4)
21
+ pry-byebug (1.3.2)
22
+ byebug (~> 2.7)
23
+ pry (~> 0.9.12)
24
+ rake (10.1.0)
16
25
  rspec (2.12.0)
17
26
  rspec-core (~> 2.12.0)
18
27
  rspec-expectations (~> 2.12.0)
@@ -28,5 +37,9 @@ PLATFORMS
28
37
 
29
38
  DEPENDENCIES
30
39
  infect!
31
- pry
40
+ pry-byebug
41
+ rake
32
42
  rspec
43
+
44
+ BUNDLED WITH
45
+ 1.13.5
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # ☣ Infect
2
2
 
3
- Bundle manager for [Pathogen](https://github.com/tpope/vim-pathogen).
3
+ Package manager for [Vim 8](https://github.com/vim/vim/blob/master/runtime/doc/version8.txt#L97-L103).
4
4
 
5
- Manage your entire vim config with a single `.vimrc` file. Much the same way that [sprockets](https://github.com/sstephenson/sprockets) lets you include web assets, infect will handle install vim plugins for you.
5
+ The only package manager that makes no impact on start up time.
6
+
7
+ Manage your entire vim config with a single `.vimrc` file, while keeping the vimrc file functional on systems with out any custom plugins installed, or with older versions of Vim.
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Infect has no dependencies other than a recentish version of ruby. And can be installed as a standalone script, perhaps in your `~/bin` directory.
10
12
 
11
- $ curl https://raw.github.com/csexton/infect/master/standalone/infect > ~/bin/infect && chmod +x ~/bin/infect
13
+ $ curl https://raw.githubusercontent.com/csexton/infect/master/standalone/infect > ~/bin/infect && chmod +x ~/bin/infect
12
14
 
13
15
  Or if you prefer to manage it at a gem:
14
16
 
@@ -16,37 +18,63 @@ Or if you prefer to manage it at a gem:
16
18
 
17
19
  ## Objective
18
20
 
19
- The point of Infect it to make it easy to manage your vim config. You should be able to check in your `.vimrc` into source control and use that one file to easily install any plugins you need.
21
+ The point of Infect it to make it easy to manage your vim config. You should be able to check in your `.vimrc` into source control and use that **one** file to easily install any plugins or packages you need.
20
22
 
21
23
  ## Rationale
22
24
 
23
25
  Why invent another way of managing vim plugins?
24
26
 
25
- * I want to be able to use my `.vimrc` when without installing plugins.
27
+ * I want to **be able** to use my `.vimrc` when without installing plugins.
26
28
  * I like having simple command line apps to manage my setup.
27
- * I wanted to use pathogen to do the loading.
29
+ * I wanted to the **built-in** plugin loading system.
28
30
  * I was tired of managing git submodules, nor did I find it very scalable.
31
+ * I do not want my plugin manager to **affect the start up time** of my editor.
29
32
 
33
+ Many of the other plugins mangers are really slick, but every one I have seen has violated of of those reasons.
30
34
 
31
- Vundle is really slick, much nicer now than when I used it a few years ago. But I had two main problems with it:
32
-
33
- * The `vimrc` is not usable unless vundle is installed. You will get errors on the config lines if you try to run vim with out the vundle plugin no installed. This is probably not normally a problem for most people, but I like to be able to scp my `.vimrc` to servers to get a basic configuration up there, but don't want to worry about installing the plugins.
34
- * Vundle was slower than pathogen to load. Not sure if this is still the case, but at one point it added a noticable delay in loading vim.
35
- * I don't really want to use my editor for installing stuff. Bram said "Each program has its own task and should be good at it" and think installing bundles is better suited for a command line script.
36
-
37
- Like I said, [Vundle](https://github.com/gmarik/vundle) is really nice, quite polished and active. Just not for me, you may want to check it out.
38
-
35
+ I don't really want to use my editor for installing stuff. Bram said "Each program has its own task and should be good at it" and think installing bundles is better suited for a command line script.
39
36
 
40
37
  ## Usage
41
38
 
42
- Infect reads your `.vimrc` file and looks for magic comments. It uses those to install pathogen style vim bundles. A minimal `.vimrc` to use with infect would look like this:
39
+ Infect reads your `.vimrc` file and looks for magic comments. It uses those to install pathogen style vim bundles. A minimal `.vimrc` to use with infect might look like this:
40
+
41
+ "=plugin tpope/vim-sensible
42
+ "=plugin csexton/trailertrash.vim
43
43
 
44
- "=bundle tpope/vim-pathogen
45
- "=bundle tpope/vim-sensible
46
- source ~/.vim/bundle/vim-pathogen/autoload/pathogen.vim
47
- execute pathogen#runtime_append_all_bundles()
48
44
  syntax on
49
45
  filetype plugin indent on
50
46
 
51
- Just put those lines at the top of your vimrc and infect will install pathogen and the bundles for you.
47
+ Just put those lines at the top of your vimrc and infect will install plugins and packages for you.
48
+
49
+ ## Building plugins
50
+
51
+ Some plugins have binaries that need to be compiled, and infect can automatically run those commands for you. For example Shougo's [vimproc](https://github.com/Shougo/vimproc.vim) needs you to call `make` after installing it:
52
+
53
+ "=plugin Shougo/vimproc.vim build: make
54
+
55
+ ## Plugins vs Packages
56
+
57
+ Packages are collections of plugins. Introduced in Vim 8, they provide a way to combine a number of plugins together and have Vim load them for you. One of the nice upsides to this is you don't need any external plugin manager to be able to load plugin bundles, just have to put them in the right folder.
58
+
59
+ Infect will do this for you. If you declare a 'plugin`, infect will put that in the `default` package's `start` directory. That will cause it to automatically be loaded when vim is started.
60
+
61
+ ## Loading automatically or optionally
62
+
63
+ According to Vim docs:
64
+
65
+ > Note that the files under "pack/foo/opt" are not loaded automatically, only the
66
+ ones under "pack/foo/start". See |pack-add| below for how the "opt" directory
67
+ is used.
68
+
69
+ This means you have to call `:packadd` to load any optional plugins. This can be hanyd if you don't want to proactivly load up some plugins.
70
+
71
+ Tell vim to only load trailertrash when requested:
72
+
73
+ "=plugin csexton/trailertrash.vim load: opt
74
+
75
+ Then to request it to be loaded:
76
+
77
+ :packadd trailertrash.vim
78
+
79
+
52
80
 
data/Rakefile CHANGED
@@ -12,3 +12,46 @@ end
12
12
 
13
13
  desc "Build standalone script"
14
14
  task :standalone => "./standalone/infect"
15
+
16
+ namespace :build do
17
+ task :standalone_parallel => [:clean] do
18
+ Rake::Task[:standalone].invoke
19
+ pmap = Gem::Specification.find_by_name('pmap')
20
+ pmap_lib = Dir["#{File.join(pmap.lib_dirs_glob, 'pmap.rb')}"].first
21
+ content = File.read(pmap_lib)
22
+
23
+ preamble = <<PREAMBLE
24
+
25
+ #####
26
+ # This file is generated code. DO NOT send patches for it.
27
+ #
28
+ # Original source files with comments are at:
29
+ # https://github.com/csexton/infect
30
+ #####
31
+
32
+ PREAMBLE
33
+ license = File.read("#{File.join(pmap.lib_dirs_glob, '..', 'LICENSE')}")
34
+ infect = File.read('standalone/infect')
35
+ .gsub(%r{#!/usr/bin/.* ruby$}, '')
36
+ .gsub(%r{#!/usr/bin/ruby$}, '')
37
+ .gsub(%r{require 'pmap'}, '')
38
+ output = [ "#!/usr/bin/env ruby",
39
+ preamble,
40
+ "=begin",
41
+ "Content related to pmap belongs to the #{pmap.name} gem",
42
+ "See source at https://github.com/bruceadams/pmap",
43
+ "License",
44
+ license,
45
+ "=end",
46
+ content,
47
+ "# End of PMap gem",
48
+ infect,
49
+ ].join("\n")
50
+
51
+ File.write(File.expand_path('standalone/infect'), output)
52
+ end
53
+ end
54
+
55
+ task :clean do
56
+ FileUtils.rm_f 'standalone/infect'
57
+ end
@@ -17,5 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
  gem.add_development_dependency('rspec')
20
- gem.add_development_dependency('pry')
20
+ gem.add_development_dependency('pry-byebug')
21
+ gem.add_development_dependency('rake')
21
22
  end
@@ -3,7 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'infect/version'
4
4
  require 'infect/colorize'
5
5
  require 'infect/command'
6
- require 'infect/command/bundle'
6
+ require 'infect/command/plugin'
7
+ require 'infect/command/package'
7
8
  require 'infect/command/prereqs'
8
9
  require 'infect/cleanup'
9
10
  require 'infect/runner'
@@ -1,22 +1,16 @@
1
1
  module Infect
2
2
  class Cleanup
3
3
  include Infect::Colorize
4
- attr_reader :commands, :force
4
+ attr_reader :names, :force
5
5
 
6
- def initialize(commands, args = {})
7
- @commands = commands
6
+ def initialize(list, args)
7
+ @names = list.map{|p| File.basename(p)}
8
8
  @force = args[:force] || false
9
9
  end
10
10
 
11
11
  def call
12
- uninstall_unless_included names
13
- end
14
-
15
- private
16
-
17
- def uninstall_unless_included(list)
18
- Dir["#{BUNDLE_DIR}/*"].each do |path|
19
- unless list.include? File.basename(path)
12
+ Dir["#{PACK_DIR}*/*/*"].each do |path|
13
+ unless names.include? File.basename(path)
20
14
  if confirm(path)
21
15
  notice "Deleting #{path}"
22
16
  require 'fileutils'
@@ -43,15 +37,5 @@ module Infect
43
37
  end
44
38
  end
45
39
 
46
- def names
47
- list = []
48
- commands.each do |command|
49
- if command.respond_to? :name
50
- list << command.name
51
- end
52
- end
53
- list
54
- end
55
-
56
40
  end
57
41
  end
@@ -7,8 +7,10 @@ module Infect
7
7
 
8
8
  def self.build(command, arg ,opts)
9
9
  case command.to_sym
10
- when :bundle
11
- Bundle.new(arg, opts)
10
+ when :plugin
11
+ Plugin.new(arg, opts)
12
+ when :bundle, :package
13
+ Package.new(arg, opts)
12
14
  else
13
15
  $stderr.puts "WARNING: #{command} is not a valid command, ignorning"
14
16
  end
@@ -19,7 +21,6 @@ module Infect
19
21
  def mkdir(path)
20
22
  expanded_path = File.expand_path(path)
21
23
  unless File.directory?(expanded_path)
22
- notice "Making dir #{path}"
23
24
  FileUtils.mkdir_p(expanded_path)
24
25
  end
25
26
  end
@@ -0,0 +1,10 @@
1
+ module Infect
2
+ class Command
3
+ class Package < Plugin
4
+ def initialize(arg, opts)
5
+ super
6
+ @location = File.expand_path("#{PACK_DIR}/#{name}")
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,65 @@
1
+ require 'open3'
2
+
3
+ module Infect
4
+ class Command
5
+ class Plugin < Command
6
+ attr_reader :build, :location, :name, :options, :url
7
+
8
+ def initialize(arg, opts)
9
+ load = opts.fetch(:load) { "start" }
10
+ package = opts.fetch(:package) { "default" }
11
+
12
+ @name = File.basename(arg)
13
+ @url = "git@github.com:#{arg}.git"
14
+ @location = File.expand_path("#{PACK_DIR}/#{package}/#{load}/#{name}")
15
+ @build = opts[:build]
16
+ end
17
+
18
+ def install
19
+ notice "Installing #{name} to #{@location}..."
20
+ parent_dir = File.expand_path("..", location)
21
+ mkdir parent_dir
22
+ chdir parent_dir
23
+ git "clone --depth 1 '#{url}'"
24
+ end
25
+
26
+ def update
27
+ notice "Updating #{name}..."
28
+ chdir location
29
+ git "fetch"
30
+ git "checkout master"
31
+ end
32
+
33
+ def call
34
+ if File.exists? location
35
+ update
36
+ else
37
+ install
38
+ end
39
+
40
+ if build
41
+ notice " Found build command, running: '#{build}'"
42
+ chdir location
43
+ quiet_system "#{build.gsub(/^\"|\"?$/, '')}"
44
+ end
45
+
46
+ location
47
+ end
48
+
49
+ private
50
+
51
+ def git(args)
52
+ quiet_system "git #{args}"
53
+ end
54
+
55
+ def quiet_system(cmd)
56
+ output = %x{#{cmd} 2>&1}
57
+ unless $?.success?
58
+ error "Command failed: #{cmd}\n"
59
+ error output.gsub(/^/, " ")
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+ end
@@ -8,7 +8,7 @@ module Infect
8
8
  end
9
9
  end
10
10
  def call
11
- mkdir "~/.vim/bundle"
11
+ mkdir PACK_DIR
12
12
  # create the cache directories for sensible.vim:
13
13
  # TODO: Support Windows
14
14
  if RUBY_PLATFORM =~ /darwin/
@@ -2,32 +2,37 @@ module Infect
2
2
  # Globals be global
3
3
  VIMHOME = ENV['VIM'] || "#{ENV['HOME']}/.vim"
4
4
  VIMRC = ENV['MYVIMRC'] || "#{ENV['HOME']}/.vimrc"
5
- BUNDLE_DIR = "#{VIMHOME}/bundle"
5
+ PACK_DIR = "#{VIMHOME}/pack/"
6
6
 
7
7
  class Runner
8
8
  def self.call(*args)
9
- force = args.include? "-f"
10
-
11
- commands = [Command::Prereqs.new()]
9
+ self.new.call(args)
10
+ end
12
11
 
13
- File.open( VIMRC ).each_line do |line|
14
- if line =~ /^"=/
15
- command, arg, opts = parse_command(line.gsub('"=', ''))
16
- commands << Command.build(command, arg, opts)
17
- end
18
- end
12
+ def call(*args)
13
+ force = args.include? "-f"
19
14
 
20
- commands.compact.each do |command|
21
- command.call
22
- end
15
+ Command::Prereqs.new().call
23
16
 
24
- Cleanup.new(commands, :force => force).call
17
+ commands = get_packages_from_vimrc
18
+ commands.compact.each(&:call)
25
19
 
20
+ locations = commands.map(&:location)
21
+ Cleanup.new(locations, :force => force).call
26
22
  end
27
23
 
28
24
  private
29
25
 
30
- def self.parse_command(line)
26
+ def get_packages_from_vimrc
27
+ File.readlines(VIMRC).map do |line|
28
+ if line =~ /^"=/
29
+ command, arg, opts = parse_command(line.gsub('"=', ''))
30
+ Command.build(command, arg, opts)
31
+ end
32
+ end.compact
33
+ end
34
+
35
+ def parse_command(line)
31
36
  # TODO: pass in named params after for things like build commands and
32
37
  # branches
33
38
  #
@@ -37,7 +42,7 @@ module Infect
37
42
  # Now we can take args and split by ',' the split those by ':' and
38
43
  # map that to a hash that we can pass into the command builder
39
44
 
40
- # This splits adn perserves "quoted words"
45
+ # This splits and perserves "quoted words"
41
46
  #command, *args = line.split /\s(?=(?:[^"]|"[^"]*")*$)/
42
47
 
43
48
  #command, *args = line.split
@@ -46,7 +51,7 @@ module Infect
46
51
  [command, arg, parse_opts(opts_string)]
47
52
  end
48
53
 
49
- def self.parse_opts(string)
54
+ def parse_opts(string)
50
55
  hash = {}
51
56
  # Woah now.
52
57
  #
@@ -1,3 +1,3 @@
1
1
  module Infect
2
- VERSION = "0.0.5"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -6,6 +6,6 @@ describe Infect::Command do
6
6
  end
7
7
 
8
8
  it "build a bundle command" do
9
- Infect::Command.build("bundle", "tpope/vim-pathogen", {}).name.should == "vim-pathogen"
9
+ Infect::Command.build("bundle", "tpope/vim-fugitive", {}).name.should == "vim-fugitive"
10
10
  end
11
11
  end
@@ -6,7 +6,7 @@ require 'tmpdir'
6
6
  describe Infect::Runner do
7
7
  before do
8
8
  stub_const "Infect::VIMRC", file
9
- stub_const "Infect::BUNDLE_DIR", dir
9
+ stub_const "Infect::PACK_DIR", dir
10
10
  end
11
11
 
12
12
  let(:file) { Tempfile.new("rspec") }
@@ -7,7 +7,7 @@
7
7
  #
8
8
 
9
9
  module Infect
10
- VERSION = "0.0.4"
10
+ VERSION = "1.0.0"
11
11
  end
12
12
 
13
13
  require 'open-uri'
@@ -37,8 +37,10 @@ module Infect
37
37
 
38
38
  def self.build(command, arg ,opts)
39
39
  case command.to_sym
40
- when :bundle
41
- Bundle.new(arg, opts)
40
+ when :plugin
41
+ Plugin.new(arg, opts)
42
+ when :bundle, :package
43
+ Package.new(arg, opts)
42
44
  else
43
45
  $stderr.puts "WARNING: #{command} is not a valid command, ignorning"
44
46
  end
@@ -49,7 +51,6 @@ module Infect
49
51
  def mkdir(path)
50
52
  expanded_path = File.expand_path(path)
51
53
  unless File.directory?(expanded_path)
52
- notice "Making dir #{path}"
53
54
  FileUtils.mkdir_p(expanded_path)
54
55
  end
55
56
  end
@@ -68,46 +69,78 @@ module Infect
68
69
  end
69
70
  end
70
71
 
72
+ require 'open3'
73
+
71
74
  module Infect
72
75
  class Command
73
- class Bundle < Command
74
- attr_reader :bundle, :name, :location
76
+ class Plugin < Command
77
+ attr_reader :build, :location, :name, :options, :url
78
+
75
79
  def initialize(arg, opts)
76
- @bundle = arg
77
- @options = opts
78
- @name = File.basename(bundle)
79
- @location = File.expand_path("#{BUNDLE_DIR}/#{name}")
80
- end
80
+ load = opts.fetch(:load) { "start" }
81
+ package = opts.fetch(:package) { "default" }
81
82
 
82
- def url
83
- "git@github.com:#{bundle}.git"
83
+ @name = File.basename(arg)
84
+ @url = "git@github.com:#{arg}.git"
85
+ @location = File.expand_path("#{PACK_DIR}/#{package}/#{load}/#{name}")
86
+ @build = opts[:build]
84
87
  end
85
88
 
86
89
  def install
87
- notice "Installing #{name}... "
88
- mkdir BUNDLE_DIR
89
- chdir BUNDLE_DIR
90
- git "clone '#{url}'"
90
+ notice "Installing #{name} to #{@location}..."
91
+ parent_dir = File.expand_path("..", location)
92
+ mkdir parent_dir
93
+ chdir parent_dir
94
+ git "clone --depth 1 '#{url}'"
91
95
  end
92
96
 
93
97
  def update
94
- notice "Updating #{name}... "
95
- chdir @location
96
- git "pull"
98
+ notice "Updating #{name}..."
99
+ chdir location
100
+ git "fetch"
101
+ git "checkout master"
97
102
  end
98
103
 
99
104
  def call
100
- if File.exists? @location
105
+ if File.exists? location
101
106
  update
102
107
  else
103
108
  install
104
109
  end
110
+
111
+ if build
112
+ notice " Found build command, running: '#{build}'"
113
+ chdir location
114
+ quiet_system "#{build.gsub(/^\"|\"?$/, '')}"
115
+ end
116
+
117
+ location
105
118
  end
106
119
 
107
120
  private
108
121
 
109
122
  def git(args)
110
- `git #{args}`
123
+ quiet_system "git #{args}"
124
+ end
125
+
126
+ def quiet_system(cmd)
127
+ output = %x{#{cmd} 2>&1}
128
+ unless $?.success?
129
+ error "Command failed: #{cmd}\n"
130
+ error output.gsub(/^/, " ")
131
+ end
132
+
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ module Infect
139
+ class Command
140
+ class Package < Plugin
141
+ def initialize(arg, opts)
142
+ super
143
+ @location = File.expand_path("#{PACK_DIR}/#{name}")
111
144
  end
112
145
  end
113
146
  end
@@ -123,7 +156,7 @@ module Infect
123
156
  end
124
157
  end
125
158
  def call
126
- mkdir "~/.vim/bundle"
159
+ mkdir PACK_DIR
127
160
  if RUBY_PLATFORM =~ /darwin/
128
161
  mkdirs %w(~/Library/Vim/swap ~/Library/Vim/backup ~/Library/Vim/undo)
129
162
  else
@@ -137,22 +170,16 @@ end
137
170
  module Infect
138
171
  class Cleanup
139
172
  include Infect::Colorize
140
- attr_reader :commands, :force
173
+ attr_reader :names, :force
141
174
 
142
- def initialize(commands, args = {})
143
- @commands = commands
175
+ def initialize(list, args)
176
+ @names = list.map{|p| File.basename(p)}
144
177
  @force = args[:force] || false
145
178
  end
146
179
 
147
180
  def call
148
- uninstall_unless_included names
149
- end
150
-
151
- private
152
-
153
- def uninstall_unless_included(list)
154
- Dir["#{BUNDLE_DIR}/*"].each do |path|
155
- unless list.include? File.basename(path)
181
+ Dir["#{PACK_DIR}*/*/*"].each do |path|
182
+ unless names.include? File.basename(path)
156
183
  if confirm(path)
157
184
  notice "Deleting #{path}"
158
185
  require 'fileutils'
@@ -179,48 +206,43 @@ module Infect
179
206
  end
180
207
  end
181
208
 
182
- def names
183
- list = []
184
- commands.each do |command|
185
- if command.respond_to? :name
186
- list << command.name
187
- end
188
- end
189
- list
190
- end
191
-
192
209
  end
193
210
  end
194
211
 
195
212
  module Infect
196
213
  VIMHOME = ENV['VIM'] || "#{ENV['HOME']}/.vim"
197
214
  VIMRC = ENV['MYVIMRC'] || "#{ENV['HOME']}/.vimrc"
198
- BUNDLE_DIR = "#{VIMHOME}/bundle"
215
+ PACK_DIR = "#{VIMHOME}/pack/"
199
216
 
200
217
  class Runner
201
218
  def self.call(*args)
202
- force = args.include? "-f"
203
-
204
- commands = [Command::Prereqs.new()]
219
+ self.new.call(args)
220
+ end
205
221
 
206
- File.open( VIMRC ).each_line do |line|
207
- if line =~ /^"=/
208
- command, arg, opts = parse_command(line.gsub('"=', ''))
209
- commands << Command.build(command, arg, opts)
210
- end
211
- end
222
+ def call(*args)
223
+ force = args.include? "-f"
212
224
 
213
- commands.compact.each do |command|
214
- command.call
215
- end
225
+ Command::Prereqs.new().call
216
226
 
217
- Cleanup.new(commands, :force => force).call
227
+ commands = get_packages_from_vimrc
228
+ commands.compact.each(&:call)
218
229
 
230
+ locations = commands.map(&:location)
231
+ Cleanup.new(locations, :force => force).call
219
232
  end
220
233
 
221
234
  private
222
235
 
223
- def self.parse_command(line)
236
+ def get_packages_from_vimrc
237
+ File.readlines(VIMRC).map do |line|
238
+ if line =~ /^"=/
239
+ command, arg, opts = parse_command(line.gsub('"=', ''))
240
+ Command.build(command, arg, opts)
241
+ end
242
+ end.compact
243
+ end
244
+
245
+ def parse_command(line)
224
246
 
225
247
 
226
248
 
@@ -228,7 +250,7 @@ module Infect
228
250
  [command, arg, parse_opts(opts_string)]
229
251
  end
230
252
 
231
- def self.parse_opts(string)
253
+ def parse_opts(string)
232
254
  hash = {}
233
255
  parts = string.split(/[\s:](?=(?:[^"]|"[^"]*")*$)/).reject! { |c| c.empty? }
234
256
  if parts
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christopher Sexton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: pry
28
+ name: pry-byebug
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: Asset Pipeline for Pathogen.vim
@@ -51,7 +60,7 @@ executables:
51
60
  extensions: []
52
61
  extra_rdoc_files: []
53
62
  files:
54
- - .gitignore
63
+ - ".gitignore"
55
64
  - CONTRIBUTING.md
56
65
  - Gemfile
57
66
  - Gemfile.lock
@@ -64,7 +73,8 @@ files:
64
73
  - lib/infect/cleanup.rb
65
74
  - lib/infect/colorize.rb
66
75
  - lib/infect/command.rb
67
- - lib/infect/command/bundle.rb
76
+ - lib/infect/command/package.rb
77
+ - lib/infect/command/plugin.rb
68
78
  - lib/infect/command/prereqs.rb
69
79
  - lib/infect/runner.rb
70
80
  - lib/infect/standalone.rb
@@ -75,27 +85,26 @@ files:
75
85
  - standalone/infect
76
86
  homepage: https://github.com/csexton/infect
77
87
  licenses: []
88
+ metadata: {}
78
89
  post_install_message:
79
90
  rdoc_options: []
80
91
  require_paths:
81
92
  - lib
82
93
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
94
  requirements:
85
- - - ! '>='
95
+ - - ">="
86
96
  - !ruby/object:Gem::Version
87
97
  version: '0'
88
98
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
99
  requirements:
91
- - - ! '>='
100
+ - - ">="
92
101
  - !ruby/object:Gem::Version
93
102
  version: '0'
94
103
  requirements: []
95
104
  rubyforge_project:
96
- rubygems_version: 1.8.25
105
+ rubygems_version: 2.5.1
97
106
  signing_key:
98
- specification_version: 3
107
+ specification_version: 4
99
108
  summary: Asset Pipeline for Vim and Pathogen, install vim bundles included in your
100
109
  vimrc
101
110
  test_files:
@@ -1,44 +0,0 @@
1
- module Infect
2
- class Command
3
- class Bundle < Command
4
- attr_reader :bundle, :name, :location
5
- def initialize(arg, opts)
6
- @bundle = arg
7
- @options = opts
8
- @name = File.basename(bundle)
9
- @location = File.expand_path("#{BUNDLE_DIR}/#{name}")
10
- end
11
-
12
- def url
13
- "git@github.com:#{bundle}.git"
14
- end
15
-
16
- def install
17
- notice "Installing #{name}... "
18
- mkdir BUNDLE_DIR
19
- chdir BUNDLE_DIR
20
- git "clone '#{url}'"
21
- end
22
-
23
- def update
24
- notice "Updating #{name}... "
25
- chdir @location
26
- git "pull"
27
- end
28
-
29
- def call
30
- if File.exists? @location
31
- update
32
- else
33
- install
34
- end
35
- end
36
-
37
- private
38
-
39
- def git(args)
40
- `git #{args}`
41
- end
42
- end
43
- end
44
- end