vimbrew 0.0.1.a.1
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/LICENSE +19 -0
- data/README.md +1 -0
- data/bin/vimbrew +12 -0
- data/lib/vimbrew/cli.rb +55 -0
- data/lib/vimbrew/commands/abstract.rb +12 -0
- data/lib/vimbrew/commands/home.rb +12 -0
- data/lib/vimbrew/commands/install.rb +15 -0
- data/lib/vimbrew/commands/list.rb +33 -0
- data/lib/vimbrew/commands/setup.rb +10 -0
- data/lib/vimbrew/commands/sync.rb +12 -0
- data/lib/vimbrew/commands/uninstall.rb +15 -0
- data/lib/vimbrew/commands/update.rb +27 -0
- data/lib/vimbrew/commands.rb +12 -0
- data/lib/vimbrew/downloaders/abstract.rb +21 -0
- data/lib/vimbrew/downloaders/git.rb +26 -0
- data/lib/vimbrew/downloaders.rb +6 -0
- data/lib/vimbrew/environment.rb +82 -0
- data/lib/vimbrew/recipe.rb +97 -0
- data/lib/vimbrew/version.rb +3 -0
- data/lib/vimbrew.rb +16 -0
- metadata +104 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Simon Menke
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Vimbrew
|
data/bin/vimbrew
ADDED
data/lib/vimbrew/cli.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
class Vimbrew::CLI < Thor
|
2
|
+
|
3
|
+
desc 'list', 'list all available recipes'
|
4
|
+
def list
|
5
|
+
Vimbrew::Commands::List.run(shell)
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'search QUERY', 'search for available recipes'
|
9
|
+
def search(query)
|
10
|
+
Vimbrew::Commands::List.run(shell, :query => query)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'installed', 'list installed recipes'
|
14
|
+
def installed
|
15
|
+
Vimbrew::Commands::List.run(shell, :installed => true)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'outdated', 'list outdated recipes'
|
19
|
+
def outdated
|
20
|
+
Vimbrew::Commands::List.run(shell, :outdated => true)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'home RECIPE', 'go to the homepage of this recipe'
|
24
|
+
def home(recipe)
|
25
|
+
Vimbrew::Commands::Home.run(shell, recipe)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'install RECIPE', 'install a new recipe'
|
29
|
+
def install(recipe)
|
30
|
+
Vimbrew::Commands::Install.run(shell, recipe)
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'uninstall RECIPE', 'uninstall a recipe'
|
34
|
+
def uninstall(recipe)
|
35
|
+
Vimbrew::Commands::Uninstall.run(shell, recipe)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'update', 'updated all outdated recipes'
|
39
|
+
method_option :force, :type => :boolean, :default => false,
|
40
|
+
:desc => 'Force update all recipes'
|
41
|
+
def update
|
42
|
+
Vimbrew::Commands::Update.run(shell, options.force)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'sync', 'pull new recipes from the server'
|
46
|
+
def sync
|
47
|
+
Vimbrew::Commands::Sync.run(shell)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'setup', 'setup vimbrew'
|
51
|
+
def setup
|
52
|
+
Vimbrew::Commands::Setup.run(shell)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Vimbrew::Commands::Install < Vimbrew::Commands::Abstract
|
2
|
+
|
3
|
+
def initialize(recipe)
|
4
|
+
@recipe = load_recipe(recipe)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
@recipe.install(shell)
|
9
|
+
|
10
|
+
dump_list_of_installed_recipes
|
11
|
+
|
12
|
+
%x"vim -c 'call pathogen#helptags()' -c 'quit' 2>&1"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Vimbrew::Commands::List < Vimbrew::Commands::Abstract
|
2
|
+
|
3
|
+
def initialize(options={})
|
4
|
+
if options[:installed]
|
5
|
+
@recipes = installed_recipes.keys
|
6
|
+
|
7
|
+
elsif options[:outdated]
|
8
|
+
@recipes = outdated_recipes
|
9
|
+
|
10
|
+
else
|
11
|
+
@recipes = recipe_root.children
|
12
|
+
|
13
|
+
@recipes = @recipes.select do |recipe|
|
14
|
+
recipe.extname == '.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
@recipes = @recipes.collect do |recipe|
|
18
|
+
recipe.basename('.rb')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if query = options[:query]
|
23
|
+
@recipes = @recipes.select do |recipe|
|
24
|
+
recipe.to_s.include?(query)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
puts @recipes
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Vimbrew::Commands::Sync < Vimbrew::Commands::Abstract
|
2
|
+
|
3
|
+
def run
|
4
|
+
recipe_root.mkpath
|
5
|
+
inside(recipe_root) do
|
6
|
+
sh 'git init' unless recipe_root('.git').directory?
|
7
|
+
sh 'git pull --ff -f git://github.com/fd/vimbrew-recipes.git master'
|
8
|
+
end
|
9
|
+
shell.say_status 'Info', 'pulled new recipes from source.', :green
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Vimbrew::Commands::Uninstall < Vimbrew::Commands::Abstract
|
2
|
+
|
3
|
+
def initialize(recipe)
|
4
|
+
@recipe = load_recipe(recipe)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
@recipe.uninstall(shell)
|
9
|
+
|
10
|
+
dump_list_of_installed_recipes
|
11
|
+
|
12
|
+
%x"vim -c 'call pathogen#helptags()' -c 'quit' 2>&1"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Vimbrew::Commands::Update < Vimbrew::Commands::Abstract
|
2
|
+
|
3
|
+
def initialize(force=false)
|
4
|
+
@force = force
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
recipes = (@force ? installed_recipes.keys : outdated_recipes.dup)
|
9
|
+
|
10
|
+
recipes.collect! do |name|
|
11
|
+
load_recipe(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
recipes.each do |recipe|
|
15
|
+
recipe.uninstall(shell)
|
16
|
+
end
|
17
|
+
|
18
|
+
recipes.each do |recipe|
|
19
|
+
recipe.install(shell)
|
20
|
+
end
|
21
|
+
|
22
|
+
dump_list_of_installed_recipes
|
23
|
+
|
24
|
+
%x"vim -c 'call pathogen#helptags()' -c 'quit' 2>&1"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Vimbrew::Commands
|
2
|
+
|
3
|
+
require 'vimbrew/commands/abstract'
|
4
|
+
require 'vimbrew/commands/setup'
|
5
|
+
require 'vimbrew/commands/list'
|
6
|
+
require 'vimbrew/commands/home'
|
7
|
+
require 'vimbrew/commands/install'
|
8
|
+
require 'vimbrew/commands/uninstall'
|
9
|
+
require 'vimbrew/commands/update'
|
10
|
+
require 'vimbrew/commands/sync'
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Vimbrew::Downloaders::Abstract
|
2
|
+
|
3
|
+
include Vimbrew::Environment
|
4
|
+
|
5
|
+
def initialize(url, options={})
|
6
|
+
@url = url
|
7
|
+
@options = { :ref => 'master' }.merge(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def fetch_into(shell, dst)
|
11
|
+
@shell = shell
|
12
|
+
dst.dirname.mkpath
|
13
|
+
|
14
|
+
dst.rmtree
|
15
|
+
|
16
|
+
sh("git clone #{@url} #{dst}")
|
17
|
+
sh("git checkout #{@options[:ref]}")
|
18
|
+
(dst + '.git').rmtree
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Vimbrew::Downloaders::Git < Vimbrew::Downloaders::Abstract
|
2
|
+
|
3
|
+
def initialize(url, options={})
|
4
|
+
@url = url
|
5
|
+
@options = { :ref => 'master' }.merge(options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def fetch_into(shell, dst)
|
9
|
+
@shell = shell
|
10
|
+
dst.dirname.mkpath
|
11
|
+
|
12
|
+
dst.rmtree rescue nil
|
13
|
+
|
14
|
+
sh("git clone #{@url} #{dst}")
|
15
|
+
Dir.chdir(dst) do
|
16
|
+
sh("git branch -f _vimbrew #{@options[:ref]}")
|
17
|
+
sh("git checkout _vimbrew")
|
18
|
+
end
|
19
|
+
(dst + '.git').rmtree
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
@options[:ref]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Vimbrew::Environment
|
2
|
+
|
3
|
+
attr_reader :shell
|
4
|
+
|
5
|
+
def inside(dir)
|
6
|
+
dir = vim_root(dir) unless Pathname == dir and dir.absolute?
|
7
|
+
Dir.chdir(dir) do
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def sh(cmd)
|
13
|
+
output = %x[#{cmd} 2>&1]
|
14
|
+
if $?.exitstatus == 0
|
15
|
+
output
|
16
|
+
else
|
17
|
+
shell.say_status 'Error', cmd, :red
|
18
|
+
puts output
|
19
|
+
exit(1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def vim_root(sub=nil)
|
24
|
+
@vim_root ||= Pathname.new('~/.vim').expand_path
|
25
|
+
(sub ? @vim_root + sub : @vim_root)
|
26
|
+
end
|
27
|
+
|
28
|
+
def link_root(sub=nil)
|
29
|
+
@link_root ||= vim_root('bundle')
|
30
|
+
(sub ? @link_root + sub : @link_root)
|
31
|
+
end
|
32
|
+
|
33
|
+
def install_root(sub=nil)
|
34
|
+
@install_root ||= vim_root('vimbrew/bundles')
|
35
|
+
(sub ? @install_root + sub : @install_root)
|
36
|
+
end
|
37
|
+
|
38
|
+
def recipe_root(sub=nil)
|
39
|
+
@recipe_root ||= vim_root('vimbrew/recipes')
|
40
|
+
(sub ? @recipe_root + sub : @recipe_root)
|
41
|
+
end
|
42
|
+
|
43
|
+
def installed_recipes(force=false)
|
44
|
+
if self == Vimbrew::Environment
|
45
|
+
@installed_recipes = nil if force
|
46
|
+
@installed_recipes ||= begin
|
47
|
+
YAML.load_file(vim_root('vimbrew/installed'))
|
48
|
+
end
|
49
|
+
else
|
50
|
+
Vimbrew::Environment.installed_recipes(force)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def dump_list_of_installed_recipes
|
55
|
+
File.open(vim_root('vimbrew/installed'), 'w+', 644) do |file|
|
56
|
+
file.write YAML.dump(installed_recipes)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def outdated_recipes(force=false)
|
61
|
+
if self == Vimbrew::Environment
|
62
|
+
@outdated_recipes = nil if force
|
63
|
+
@outdated_recipes ||= begin
|
64
|
+
r = installed_recipes
|
65
|
+
r.keys.select do |name|
|
66
|
+
recipe = load_recipe(name)
|
67
|
+
recipe.version != r[name]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
else
|
71
|
+
Vimbrew::Environment.outdated_recipes(force)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def load_recipe(name)
|
76
|
+
require(recipe_root(name))
|
77
|
+
Vimbrew::Recipe.recipes[name]
|
78
|
+
end
|
79
|
+
|
80
|
+
extend self
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
class Vimbrew::Recipe
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
include Vimbrew::Environment
|
5
|
+
|
6
|
+
def recipes
|
7
|
+
if self == Vimbrew::Recipe
|
8
|
+
@recipes ||= {}
|
9
|
+
else
|
10
|
+
Vimbrew::Recipe.recipes
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def inherited(subclass)
|
15
|
+
if self == Vimbrew::Recipe
|
16
|
+
recipes[subclass.recipe_name] = subclass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def url(value, options={})
|
21
|
+
url = URI.parse(value)
|
22
|
+
@fetcher = case url.scheme
|
23
|
+
when 'git' then Vimbrew::Downloaders::Git.new(url, options)
|
24
|
+
else raise "Cannot fetch url #{url}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def home(value=nil)
|
29
|
+
@homepage = value if value
|
30
|
+
@homepage
|
31
|
+
end
|
32
|
+
|
33
|
+
def recipe_name
|
34
|
+
@recipe_name ||= self.to_s.gsub(/[A-Z]/, '_\0').downcase.gsub(/\A_|_\Z/, '')
|
35
|
+
end
|
36
|
+
|
37
|
+
def install(shell)
|
38
|
+
@shell = shell
|
39
|
+
|
40
|
+
install_path = install_root(recipe_name)
|
41
|
+
link_path = link_root("#{recipe_name}.vb")
|
42
|
+
|
43
|
+
link_path.unlink rescue nil
|
44
|
+
|
45
|
+
recipe = nil
|
46
|
+
|
47
|
+
@fetcher.fetch_into(shell, install_path)
|
48
|
+
inside(install_path) do
|
49
|
+
recipe = self.new(shell)
|
50
|
+
recipe.install
|
51
|
+
end
|
52
|
+
|
53
|
+
link_path.make_symlink install_path
|
54
|
+
|
55
|
+
installed_recipes[self.recipe_name] = self.version
|
56
|
+
|
57
|
+
shell.say_status('Installed', recipe_name, :green)
|
58
|
+
end
|
59
|
+
|
60
|
+
def uninstall(shell)
|
61
|
+
install_path = install_root(recipe_name)
|
62
|
+
link_path = link_root("#{recipe_name}.vb")
|
63
|
+
|
64
|
+
inside(install_path) do
|
65
|
+
recipe = self.new(shell)
|
66
|
+
recipe.uninstall
|
67
|
+
end
|
68
|
+
|
69
|
+
install_path.rmtree
|
70
|
+
link_path.unlink
|
71
|
+
|
72
|
+
installed_recipes.delete(self.recipe_name)
|
73
|
+
|
74
|
+
shell.say_status('Uninstalled', recipe_name, :green)
|
75
|
+
end
|
76
|
+
|
77
|
+
def version
|
78
|
+
@fetcher.version
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
include Vimbrew::Environment
|
84
|
+
extend ClassMethods
|
85
|
+
|
86
|
+
def initialize(shell)
|
87
|
+
@shell = shell
|
88
|
+
end
|
89
|
+
|
90
|
+
def install
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def uninstall
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
data/lib/vimbrew.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vimbrew
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'pathname'
|
5
|
+
require 'yaml'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
require 'vimbrew/version'
|
9
|
+
require 'vimbrew/cli'
|
10
|
+
require 'vimbrew/environment'
|
11
|
+
require 'vimbrew/recipe'
|
12
|
+
|
13
|
+
require 'vimbrew/commands'
|
14
|
+
require 'vimbrew/downloaders'
|
15
|
+
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vimbrew
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 127
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
- a
|
11
|
+
- 1
|
12
|
+
version: 0.0.1.a.1
|
13
|
+
platform: ruby
|
14
|
+
authors:
|
15
|
+
- Simon Menke
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-07-19 00:00:00 +02:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
name: thor
|
34
|
+
requirement: *id001
|
35
|
+
prerelease: false
|
36
|
+
type: :runtime
|
37
|
+
description: ...---...
|
38
|
+
email:
|
39
|
+
- simon.menke@gmail.com
|
40
|
+
executables:
|
41
|
+
- vimbrew
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- lib/vimbrew/cli.rb
|
48
|
+
- lib/vimbrew/commands/abstract.rb
|
49
|
+
- lib/vimbrew/commands/home.rb
|
50
|
+
- lib/vimbrew/commands/install.rb
|
51
|
+
- lib/vimbrew/commands/list.rb
|
52
|
+
- lib/vimbrew/commands/setup.rb
|
53
|
+
- lib/vimbrew/commands/sync.rb
|
54
|
+
- lib/vimbrew/commands/uninstall.rb
|
55
|
+
- lib/vimbrew/commands/update.rb
|
56
|
+
- lib/vimbrew/commands.rb
|
57
|
+
- lib/vimbrew/downloaders/abstract.rb
|
58
|
+
- lib/vimbrew/downloaders/git.rb
|
59
|
+
- lib/vimbrew/downloaders.rb
|
60
|
+
- lib/vimbrew/environment.rb
|
61
|
+
- lib/vimbrew/recipe.rb
|
62
|
+
- lib/vimbrew/version.rb
|
63
|
+
- lib/vimbrew.rb
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- bin/vimbrew
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://github.com/fd/vimbrew
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 23
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 3
|
94
|
+
- 6
|
95
|
+
version: 1.3.6
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project: vimbrew
|
99
|
+
rubygems_version: 1.3.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: --
|
103
|
+
test_files: []
|
104
|
+
|