vim-epidemic 0.0.1 → 0.0.2

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.
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source "http://rubygems.org"
5
5
 
6
6
  gem 'paint', '~> 0.8.5'
7
7
  gem 'commander', '~> 4.1.2'
8
+ gem 'which_works'
8
9
 
9
10
  # Add dependencies to develop your gem here.
10
11
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -33,6 +33,7 @@ GEM
33
33
  multi_json (~> 1.0)
34
34
  simplecov-html (~> 0.5.3)
35
35
  simplecov-html (0.5.3)
36
+ which_works (1.0.0)
36
37
 
37
38
  PLATFORMS
38
39
  ruby
@@ -48,3 +49,4 @@ DEPENDENCIES
48
49
  rake-version
49
50
  rspec
50
51
  simplecov
52
+ which_works
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vim-epidemic
1
+ # epidemic.vim
2
2
 
3
3
  Downloads vim plugins and installs them into the pathogen.vim bundle directory.
4
4
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/program.rb CHANGED
@@ -5,3 +5,31 @@ program :name, 'vim-epidemic'
5
5
  program :version, VimEpidemic::VERSION
6
6
  program :description, 'Downloads vim plugins and installs them into the pathogen.vim bundle directory.'
7
7
 
8
+ controller = VimEpidemic::Controller.new
9
+
10
+ command :info do |c|
11
+ c.syntax = 'vim-epidemic'
12
+ c.description = 'Show configuration and list installed plugins (default action)'
13
+ c.action do |args,options|
14
+ controller.info options
15
+ end
16
+ end
17
+
18
+ command :update do |c|
19
+ c.syntax = 'vim-epidemic update'
20
+ c.description = 'Installs configured plugins'
21
+ c.action do |args,options|
22
+ controller.update options
23
+ end
24
+ end
25
+
26
+ command :add do |c|
27
+ c.syntax = 'vim-epidemic add <REPO>'
28
+ c.description = 'Adds a plugin repository to install (run "update" to install)'
29
+ c.action do |args, options|
30
+ controller.add args, options
31
+ end
32
+ end
33
+
34
+ default_command :info
35
+
@@ -0,0 +1,45 @@
1
+ require 'fileutils'
2
+
3
+ module VimEpidemic
4
+
5
+ class Config
6
+ attr_reader :plugins
7
+
8
+ def initialize
9
+ @plugins = []
10
+ @home = File.expand_path '~'
11
+ end
12
+
13
+ def touch
14
+ FileUtils.touch file
15
+ end
16
+
17
+ def has? *args
18
+ @plugins.find{ |p| p.match? *args }
19
+ end
20
+
21
+ def empty?
22
+ @plugins.empty?
23
+ end
24
+
25
+ def install *args, &block
26
+ @plugins << Plugin.new(self, *args, block)
27
+ end
28
+
29
+ def configure &block
30
+ self.instance_eval &block
31
+ end
32
+
33
+ def file
34
+ File.join @home, '.epidemic.vim.rb'
35
+ end
36
+
37
+ def exists?
38
+ File.exists? file
39
+ end
40
+
41
+ def bundle_dir
42
+ File.join @home, '.vim', 'bundle'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,101 @@
1
+
2
+ module VimEpidemic
3
+
4
+ class Controller
5
+
6
+ def initialize
7
+ @config = Config.new
8
+ end
9
+
10
+ def info options = {}
11
+ load_config!
12
+ show_info
13
+ end
14
+
15
+ def update options = {}
16
+ check_requirements!
17
+ load_config!
18
+ puts "\n#{banner}\n"
19
+ if @config.empty?
20
+ puts "\nNothing to update.\n\n"
21
+ exit 0
22
+ end
23
+ successful = true
24
+ @config.plugins.each do |plugin|
25
+ puts
26
+ action = plugin.installed? ? 'Updating' : 'Installing'
27
+ puts Paint["#{action} #{plugin}...", :yellow]
28
+ if plugin.install
29
+ puts Paint["Done!", :green]
30
+ else
31
+ successful = false
32
+ puts Paint["Could not install.", :red]
33
+ end
34
+ end
35
+ puts
36
+ if successful
37
+ puts Paint["All plugins were successfully installed/updated.", :green, :bold]
38
+ else
39
+ puts Paint["There were problems with some of the plugins.", :red, :bold]
40
+ end
41
+ puts
42
+ end
43
+
44
+ def add args, options = {}
45
+ load_config!
46
+ unless @config.has? *args
47
+ @config.touch unless @config.exists?
48
+ File.open(@config.file, 'a') do |f|
49
+ f.write %|\ninstall "#{args.first}"|
50
+ end
51
+ @config.install *args
52
+ end
53
+ show_info
54
+ end
55
+
56
+ private
57
+
58
+ def show_info
59
+ puts "\n#{banner}\n\n"
60
+ if @config.plugins.any?
61
+ @config.plugins.each do |plugin|
62
+ puts " #{Paint[plugin.to_s, plugin.installed? ? :green : :yellow]}"
63
+ end
64
+ else
65
+ puts Paint[%|No plugins registered.|, :yellow]
66
+ puts %|Run "vim-epidemic add <REPO>" to register one.|
67
+ end
68
+ puts
69
+ end
70
+
71
+ def banner
72
+ String.new.tap do |s|
73
+ s << Paint[%|epidemic.vim v#{VERSION}|, :bold]
74
+ s << %|\nconfiguration: |
75
+ if @config.exists?
76
+ s << @config.file
77
+ else
78
+ s << %|none|
79
+ end
80
+ s << "\nbundles: #{@config.bundle_dir}"
81
+ end
82
+ end
83
+
84
+ def check_requirements!
85
+ abort %|epidemic.vim requires "git" to be in your $PATH| unless Which.which('git')
86
+ end
87
+
88
+ def abort msg
89
+ warn Paint[msg, :red]
90
+ exit 1
91
+ end
92
+
93
+ def load_config!
94
+ @config.instance_eval read_config, @config.file if @config.exists?
95
+ end
96
+
97
+ def read_config
98
+ File.open(@config.file, 'r').read
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,62 @@
1
+ require 'uri'
2
+
3
+ module VimEpidemic
4
+
5
+ class Plugin
6
+
7
+ def initialize config, *args, block
8
+ @config = config
9
+ options = args.last.kind_of?(Hash) ? args.pop : {}
10
+ @source = args.shift
11
+ @type = args.shift || options[:type]
12
+ @block = block
13
+ end
14
+
15
+ def match? *args
16
+ complete_source(args.first) == complete_source
17
+ end
18
+
19
+ def install
20
+ if File.exists? dir
21
+ Dir.chdir dir
22
+ `git pull`
23
+ else
24
+ Dir.chdir @config.bundle_dir
25
+ `git clone #{complete_source} #{name}`
26
+ Dir.chdir dir if $? == 0
27
+ end
28
+ call_block if $? == 0
29
+ $? == 0
30
+ end
31
+
32
+ def to_s
33
+ "#{name} (#{complete_source})"
34
+ end
35
+
36
+ def installed?
37
+ File.exists? dir
38
+ end
39
+
40
+ private
41
+
42
+ def call_block
43
+ @block.call if @block
44
+ end
45
+
46
+ def dir
47
+ File.join @config.bundle_dir, name
48
+ end
49
+
50
+ def name
51
+ complete_source.sub(/.*\//, '').sub(/\.git\Z/, '')
52
+ end
53
+
54
+ def complete_source source = @source
55
+ if source.match /\Agit\:\/\//
56
+ source
57
+ else
58
+ "git://github.com/#{source}.git"
59
+ end
60
+ end
61
+ end
62
+ end
data/lib/vim-epidemic.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  require 'paint'
3
+ require 'which_works'
3
4
 
4
5
  module VimEpidemic
5
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
6
7
  end
7
8
 
8
- [].each do |lib|
9
+ [ :config, :controller, :plugin ].each do |lib|
9
10
  require File.join(File.dirname(__FILE__), 'vim-epidemic', lib.to_s)
10
11
  end
@@ -0,0 +1,89 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "vim-epidemic"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["AlphaHydrae"]
12
+ s.date = "2012-09-28"
13
+ s.description = "Downloads vim plugins and installs them into the pathogen.vim bundle directory."
14
+ s.email = "hydrae.alpha@gmail.com"
15
+ s.executables = ["vim-epidemic"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".rspec",
22
+ ".rvmrc",
23
+ ".screenrc",
24
+ ".travis.yml",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "bin/vim-epidemic",
32
+ "lib/program.rb",
33
+ "lib/vim-epidemic.rb",
34
+ "lib/vim-epidemic/config.rb",
35
+ "lib/vim-epidemic/controller.rb",
36
+ "lib/vim-epidemic/plugin.rb",
37
+ "spec/helper.rb",
38
+ "spec/version_spec.rb",
39
+ "vim-epidemic.gemspec"
40
+ ]
41
+ s.homepage = "http://github.com/AlphaHydrae/vim-epidemic"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.24"
45
+ s.summary = "Unofficial pathogen.vim plugin manager."
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<paint>, ["~> 0.8.5"])
52
+ s.add_runtime_dependency(%q<commander>, ["~> 4.1.2"])
53
+ s.add_runtime_dependency(%q<which_works>, [">= 0"])
54
+ s.add_development_dependency(%q<bundler>, [">= 0"])
55
+ s.add_development_dependency(%q<rake>, [">= 0"])
56
+ s.add_development_dependency(%q<rspec>, [">= 0"])
57
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_development_dependency(%q<gemcutter>, [">= 0"])
59
+ s.add_development_dependency(%q<gem-release>, [">= 0"])
60
+ s.add_development_dependency(%q<rake-version>, [">= 0"])
61
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<paint>, ["~> 0.8.5"])
64
+ s.add_dependency(%q<commander>, ["~> 4.1.2"])
65
+ s.add_dependency(%q<which_works>, [">= 0"])
66
+ s.add_dependency(%q<bundler>, [">= 0"])
67
+ s.add_dependency(%q<rake>, [">= 0"])
68
+ s.add_dependency(%q<rspec>, [">= 0"])
69
+ s.add_dependency(%q<jeweler>, [">= 0"])
70
+ s.add_dependency(%q<gemcutter>, [">= 0"])
71
+ s.add_dependency(%q<gem-release>, [">= 0"])
72
+ s.add_dependency(%q<rake-version>, [">= 0"])
73
+ s.add_dependency(%q<simplecov>, [">= 0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<paint>, ["~> 0.8.5"])
77
+ s.add_dependency(%q<commander>, ["~> 4.1.2"])
78
+ s.add_dependency(%q<which_works>, [">= 0"])
79
+ s.add_dependency(%q<bundler>, [">= 0"])
80
+ s.add_dependency(%q<rake>, [">= 0"])
81
+ s.add_dependency(%q<rspec>, [">= 0"])
82
+ s.add_dependency(%q<jeweler>, [">= 0"])
83
+ s.add_dependency(%q<gemcutter>, [">= 0"])
84
+ s.add_dependency(%q<gem-release>, [">= 0"])
85
+ s.add_dependency(%q<rake-version>, [">= 0"])
86
+ s.add_dependency(%q<simplecov>, [">= 0"])
87
+ end
88
+ end
89
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vim-epidemic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 4.1.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: which_works
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: bundler
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -194,8 +210,12 @@ files:
194
210
  - bin/vim-epidemic
195
211
  - lib/program.rb
196
212
  - lib/vim-epidemic.rb
213
+ - lib/vim-epidemic/config.rb
214
+ - lib/vim-epidemic/controller.rb
215
+ - lib/vim-epidemic/plugin.rb
197
216
  - spec/helper.rb
198
217
  - spec/version_spec.rb
218
+ - vim-epidemic.gemspec
199
219
  homepage: http://github.com/AlphaHydrae/vim-epidemic
200
220
  licenses:
201
221
  - MIT