vpm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vpm.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vpm (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ ansi (1.4.1)
10
+ rake (0.9.2.2)
11
+ turn (0.8.3)
12
+ ansi
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ rake
19
+ turn
20
+ vpm!
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ Vim Plugin Manager
2
+ ==================
3
+
4
+ Vim Plugin
5
+ ----------
6
+
7
+ ### What?
8
+
9
+ A Vim Plugin is a package that contains vim scripts and a vim plugin specification, a.k.a. "vbspec".
10
+
11
+
12
+ ### Why?
13
+
14
+ To allow proper distribution of vim scripts. For example, versioning of
15
+ vim scripts.
16
+
17
+ ### How?
18
+
19
+ A vbspec, like a [gemspec](http://docs.rubygems.org/read/chapter/20), consists of several attributes.
20
+ For example, a description, example usage, notes, and more.
21
+
22
+ The directory structure of a vim bundle constains a file ending with *.vbspec in the root directory:
23
+
24
+ - command-t.vbspec
25
+ - ...
26
+
27
+ Vim Plugin Manager
28
+ ------------------
29
+
30
+ ### What?
31
+
32
+ Vim Plugin Manager (VPM) keeps track of installed vim scripts,
33
+ installs/updates vim scripts from [vim-plugins.org](http://vim-plugins.org), uninstalls vim scripts and searches vim
34
+ scripts by name.
35
+
36
+ ### Why?
37
+
38
+ Managing vim scripts is difficult without a manager. For example,
39
+ installing or updating a version of a vim script.
40
+
41
+ ### How?
42
+
43
+ With Vim Plugin Manager, you are able to manipulate Vim Plugins like this:
44
+
45
+ $ vpm install command-t
46
+ $ vpm update command-t
47
+ $ vpm list
48
+ $ vpm search command-t
49
+ $ vpm uninstall command-t
50
+
51
+ You are also able to install a certain version of a vim bundle:
52
+
53
+ $ vpm install command-t v1.0
54
+
55
+ Vim-Plugins.org
56
+ --------------
57
+
58
+ Vim-Plugins.org is a community vim bundle host. Vim Plugin authors
59
+ publish their bundled vim scripts to the host and keep track of basic statistics
60
+ of their vim bundles.
61
+
62
+ To publish/yank a Vim Plugin:
63
+
64
+ $ vpm publish
65
+ $ vpm yank
66
+
67
+ Similar Projects
68
+ ----------------
69
+
70
+ * <https://github.com/gmarik/vundle>
71
+ * <http://vim-scripts.org/vim/tools.html>
72
+ * <http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen>
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :test
4
+
5
+ require 'rake/testtask'
6
+ Rake::TestTask.new(:test) do |test|
7
+ test.libs << 'lib' << 'spec'
8
+ test.pattern = 'spec/**/*_spec.rb'
9
+ test.verbose = true
10
+ end
data/bin/vpm ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vpm'
4
+ VPM.run(ARGV)
data/lib/vpm.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'fileutils'
2
+ require 'vpm/version'
3
+ require 'vpm/manifest_parser'
4
+ require 'vpm/plugin'
5
+ require 'vpm/git_plugin'
6
+
7
+ module VPM
8
+ def self.run(args)
9
+ if args.empty?
10
+ install_all_plugins
11
+ end
12
+ end
13
+
14
+ def self.install_all_plugins
15
+ vim_plugins_file = File.join(File.expand_path('.'), 'VimPlugins')
16
+ content = File.read(vim_plugins_file)
17
+ parser = ManifestParser.new
18
+ plugins = parser.parse(content)
19
+ plugins.each(&:install)
20
+ end
21
+
22
+ def self.plugin_dir
23
+ @dir_path ||= begin
24
+ dir_path = ENV['VPM_PLUGIN_DIR'] || File.join(ENV['HOME'], '.vim', 'bundle')
25
+ FileUtils.mkdir_p dir_path unless Dir.exists?(dir_path)
26
+ dir_path
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module VPM
2
+ class GitPlugin < Plugin
3
+ attr_accessor :git_commander
4
+
5
+ def initialize(name, options)
6
+ super
7
+ @git_commander = GitCommander
8
+ end
9
+
10
+ def install
11
+ @git_commander.clone(options[:git], VPM.plugin_dir)
12
+ end
13
+
14
+ module GitCommander
15
+ def self.clone(repo, destination)
16
+ Dir.chdir destination do
17
+ `git clone #{repo}`
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module VPM
2
+ class ManifestParser
3
+ def initialize
4
+ @plugins = {}
5
+ end
6
+
7
+ def parse(content)
8
+ instance_eval(content)
9
+ plugins
10
+ end
11
+
12
+ def plugin(name, options = {})
13
+ @plugins[name] = Plugin.create(name, options)
14
+ end
15
+
16
+ def plugins
17
+ @plugins.values
18
+ end
19
+ end
20
+ end
data/lib/vpm/plugin.rb ADDED
@@ -0,0 +1,16 @@
1
+ module VPM
2
+ class Plugin
3
+ attr_reader :name, :options
4
+
5
+ def initialize(name, options = {})
6
+ @name = name
7
+ @options = options
8
+ end
9
+
10
+ def self.create(name, options)
11
+ if options.has_key?(:git)
12
+ GitPlugin.new(name, options)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module VPM
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe VPM::GitPlugin do
4
+ it "intalls the plugin if it hasn't" do
5
+ mock_git_command = MiniTest::Mock.new
6
+ mock_git_command.expect(:clone, true, ["https://xxx.git", "#{ENV['HOME']}/.vim/bundle"])
7
+ plugin = VPM::GitPlugin.new("command-t", :git => "https://xxx.git")
8
+ plugin.git_commander = mock_git_command
9
+ plugin.install
10
+ mock_git_command.verify
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe VPM::ManifestParser do
4
+ it "parses one plugin" do
5
+ parser = VPM::ManifestParser.new
6
+ parser.parse "plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'"
7
+
8
+ parser.plugins.size.must_equal 1
9
+ end
10
+
11
+ it "parses multiple plugins" do
12
+ parser = VPM::ManifestParser.new
13
+ parser.parse <<-END
14
+ plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'
15
+ plugin 'turn', :git => 'https://github.com/adifferent_repo.git'
16
+ plugin 'surround', :git => 'http://anothersite.com/repo.git'
17
+ END
18
+
19
+ parser.plugins.size.must_equal 3
20
+ end
21
+
22
+ it "ignores duplicate entries" do
23
+ parser = VPM::ManifestParser.new
24
+ parser.parse <<-END
25
+ plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'
26
+ plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'
27
+ END
28
+
29
+ parser.plugins.size.must_equal 1
30
+ end
31
+
32
+ it "parses to the right class of Plugin" do
33
+ parser = VPM::ManifestParser.new
34
+ parser.parse <<-END
35
+ plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'
36
+ plugin 'command-t', :git => 'https://github.com/agitrepo.git', :tag => '1.0.2'
37
+ END
38
+
39
+ parser.plugins.first.must_be_kind_of VPM::GitPlugin
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'minitest/autorun'
4
+ begin; require 'turn'; rescue LoadError; end
5
+
6
+
7
+ require 'vpm'
data/spec/vpm_test.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ describe VPM do
4
+ it "parses install command with args" do
5
+ parser = MiniTest::Mock.new
6
+
7
+ VPM.run(['intstall', 'xxx.git'])
8
+ # ['<command'>, args]
9
+ # InstallCommand.run(args)
10
+ # RemoveCommadn.run(args)
11
+ VPM.parse
12
+ end
13
+ end
data/vpm.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "vpm/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vpm"
7
+ s.version = VPM::VERSION
8
+ s.authors = ["Jingwen Owen Ou"]
9
+ s.email = ["jingweno@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{An awesome utility for managing VIM plugins}
12
+
13
+ s.rubyforge_project = "vpm"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # specify any dependencies here; for example:
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "turn"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vpm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jingwen Owen Ou
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70192619467680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70192619467680
25
+ - !ruby/object:Gem::Dependency
26
+ name: turn
27
+ requirement: &70192619467260 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70192619467260
36
+ description:
37
+ email:
38
+ - jingweno@gmail.com
39
+ executables:
40
+ - vpm
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - Gemfile.lock
47
+ - README.md
48
+ - Rakefile
49
+ - bin/vpm
50
+ - lib/vpm.rb
51
+ - lib/vpm/git_plugin.rb
52
+ - lib/vpm/manifest_parser.rb
53
+ - lib/vpm/plugin.rb
54
+ - lib/vpm/version.rb
55
+ - spec/git_plugin_spec.rb
56
+ - spec/manifest_parser_spec.rb
57
+ - spec/spec_helper.rb
58
+ - spec/vpm_test.rb
59
+ - vpm.gemspec
60
+ homepage: ''
61
+ licenses: []
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ segments:
73
+ - 0
74
+ hash: 1524590733277353739
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 1524590733277353739
84
+ requirements: []
85
+ rubyforge_project: vpm
86
+ rubygems_version: 1.8.10
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: An awesome utility for managing VIM plugins
90
+ test_files:
91
+ - spec/git_plugin_spec.rb
92
+ - spec/manifest_parser_spec.rb
93
+ - spec/spec_helper.rb
94
+ - spec/vpm_test.rb