vrundler 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8954ad00769ec2555b8a9d5db526fd2a32ccb4f
4
+ data.tar.gz: 0146d8ef94910acaee4a4f7c8bab63bb90d70083
5
+ SHA512:
6
+ metadata.gz: dde94e0a7ce644c9c44e1ff148dfdf507c7cb9ef8e75f5a9e13000e8c88ec8794237774f6b799469c86386509aafe0241352086f9501d256e6c8dde34ca86b19
7
+ data.tar.gz: 9866b34f3a6c599640880fa90ae2a3e9b28583ea732545ea0ad1f4b04e054cd2e58b9c1b6ef0ec05692c6c187fc7c0227d2139335a5b27f9c022f85a9bc69b32
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .ruby-gemset
2
+ .ruby-version
3
+ Gemfile.lock
4
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 - 2014 Jean-Paul Sylvain Boodhoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ #VRundler
2
+
3
+ This project is a a simple utility that I wrote to manage my vim plugin ecosystem.
4
+
5
+ #Usage
6
+
7
+ TODO
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/vrundler ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'vrundler'
5
+
6
+ class CLI < Thor
7
+ class_option :vrundles_file, type: :string, default: "VRundles"
8
+
9
+ desc 'install', 'Installs the vim bundles you have specified in your VRundles file'
10
+ def install
11
+ ensure_vrundles_file_provided
12
+
13
+ load vrundles_file
14
+
15
+ Dir.chdir Bundles.bundles_dir do
16
+ Bundles.unpack_all_bundles
17
+ end
18
+ end
19
+
20
+ no_commands do
21
+ def vrundles_file?
22
+ File.exist?(vrundles_file)
23
+ end
24
+
25
+ def vrundles_file
26
+ options[:vrundles_file]
27
+ end
28
+
29
+ def ensure_vrundles_file_provided
30
+ unless vrundles_file?
31
+ puts "You need to run this when you are in a folder that contains a VRundlesFile. Or specify a path to a valid VRundler configuration file using --vrundles_file=FILE"
32
+ exit
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ CLI.start(ARGV)
@@ -0,0 +1,28 @@
1
+ module VRundler
2
+ module BasicBundle
3
+ attr_reader :completion_block
4
+
5
+ def dont_delete(value=nil)
6
+ @dont_delete ||= false
7
+ @dont_delete = value || @dont_delete
8
+ end
9
+
10
+ def delete_existing_folder(path)
11
+ folder = File.join(path, name.to_s)
12
+ FileUtils.rm_rf folder unless dont_delete
13
+ end
14
+
15
+ def after_download(&block)
16
+ @completion_block = block
17
+ end
18
+
19
+ def run_extra
20
+ completion_block.call if completion_block
21
+ end
22
+
23
+ def unpack
24
+ bundle_specific_unpack
25
+ run_extra
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ module VRundler
2
+ class Bundle
3
+ include BasicBundle
4
+
5
+ attr_reader :owner
6
+ attr_reader :name
7
+
8
+ def initialize(name, owner)
9
+ @name = name
10
+ @owner = owner
11
+ end
12
+
13
+ def unpack
14
+ log "Unpacking #{url} into #{name}"
15
+ `git clone #{url} #{name}`
16
+ run_extra
17
+ end
18
+
19
+ def url
20
+ "#{owner.name}#{name}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module VRundler
2
+ class BundleGroup
3
+ attr_reader :name
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ end
8
+
9
+ def bundle(*names)
10
+ names.each do |name|
11
+ instance = Bundle.new(name, self)
12
+ yield instance, Bundles if block_given?
13
+ Bundles << instance
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ module VRundler
2
+ class Bundles
3
+ class << self
4
+ def bundles
5
+ @bundles ||= []
6
+ end
7
+
8
+ def add(bundle)
9
+ bundles << bundle
10
+ end
11
+ alias :<< :add
12
+
13
+ def bundles_dir(name=nil)
14
+ @name = (name || @name)
15
+ end
16
+
17
+ def bundle_folder(name)
18
+ return File.join(bundles_dir, name)
19
+ end
20
+
21
+ def output_folder(bundle)
22
+ return bundle_folder(bundle.name)
23
+ end
24
+
25
+ def each(&block)
26
+ bundles.each(&block)
27
+ end
28
+
29
+ def unpack_all_bundles
30
+ each do |bundle|
31
+ bundle.delete_existing_folder(File.expand_path(Bundles.bundles_dir))
32
+ bundle.unpack
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ module VRundler
2
+ class ScriptTypeGroup
3
+ attr_reader :script_type
4
+
5
+ def initialize(script_type)
6
+ @script_type = script_type
7
+ end
8
+
9
+ def script(name, id)
10
+ Bundles << VimScriptBundle.new(name, script_type, id)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module VRundler
2
+ class SymlinkBundle
3
+ include BasicBundle
4
+
5
+ attr_reader :name
6
+ attr_reader :source_folder
7
+
8
+ def initialize(name, source_folder)
9
+ @name = name.to_s
10
+ @source_folder = source_folder
11
+ end
12
+
13
+ def bundle_specific_unpack
14
+ system("ln -s #{source_folder} #{name}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module VRundler
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,31 @@
1
+ module VRundler
2
+ class VimScriptBundle
3
+ include BasicBundle
4
+
5
+ attr_reader :name,
6
+ :script_type,
7
+ :id
8
+
9
+ def initialize(name, type, id)
10
+ @name = name
11
+ @script_type = type
12
+ @id = id
13
+ end
14
+
15
+ def bundle_specific_unpack
16
+ log " Downloading script: [#{name}]"
17
+
18
+ local_file = File.join(name, script_type, "#{name}.vim")
19
+
20
+ FileUtils.mkdir_p(File.dirname(local_file))
21
+
22
+ File.open(local_file, "w") do |file|
23
+ file << open(url).read
24
+ end
25
+ end
26
+
27
+ def url
28
+ "http://www.vim.org/scripts/download_script.php?scr_id=#{self.id}"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ module VRundler
2
+ class VimScriptGroup
3
+ def group(script_type, &block)
4
+ instance = ScriptTypeGroup.new(script_type.to_s)
5
+ instance.instance_eval(&block) if block_given?
6
+ instance
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,56 @@
1
+ module VRundler
2
+ class VimZipBundle
3
+ include BasicBundle
4
+
5
+ attr_reader :name,
6
+ :id
7
+
8
+ def initialize(name, id)
9
+ @name = name
10
+ @id = id
11
+ end
12
+
13
+ def windows?
14
+ RUBY_PLATFORM =~ /(mingw|cyg)/
15
+ end
16
+
17
+ def linux?
18
+ RUBY_PLATFORM =~ /linux/
19
+ end
20
+
21
+ def create_unzip_command
22
+ command = "curl #{url}"
23
+
24
+ if windows? || linux?
25
+ command += " > #{zip_file}"
26
+ else
27
+ command += " | tar -xv"
28
+ end
29
+ end
30
+
31
+ def zip_file
32
+ "#{name}.zip"
33
+ end
34
+
35
+ def bundle_specific_unpack
36
+ log " Downloading zip: [#{name}]"
37
+
38
+ folder_name = Bundles.bundle_folder(name)
39
+
40
+ FileUtils.mkdir_p(folder_name)
41
+
42
+ Dir.chdir(folder_name) do
43
+ command = create_unzip_command
44
+
45
+ `#{command}`
46
+ `unzip #{zip_file}` if windows?
47
+ `gunzip #{zip_file}` if linux?
48
+ `rm #{zip_file}` if windows? || linux?
49
+ end
50
+ end
51
+
52
+ def url
53
+ "http://www.vim.org/scripts/download_script.php?src_id=#{id}"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,7 @@
1
+ module VRundler
2
+ class VimZipGroup
3
+ def zip(symbol_or_name, id)
4
+ Bundles << VimZipBundle.new(symbol_or_name.to_s, id)
5
+ end
6
+ end
7
+ end
data/lib/vrundler.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'fileutils'
2
+ require 'open-uri'
3
+
4
+ require 'vrundler/basic_bundle'
5
+ require 'vrundler/bundle'
6
+ require 'vrundler/bundles'
7
+ require 'vrundler/bundle_group'
8
+ require 'vrundler/vim_script_bundle'
9
+ require 'vrundler/script_type_group'
10
+ require 'vrundler/symlink_bundle'
11
+ require 'vrundler/vim_script_group'
12
+ require 'vrundler/vim_zip_bundle'
13
+ require 'vrundler/vim_zip_group'
14
+
15
+ module VRundler
16
+ def log(message)
17
+ puts message
18
+ end
19
+
20
+ def bundles_dir(path)
21
+ Bundles.bundles_dir path
22
+ end
23
+
24
+ def github(name, &block)
25
+ group("http://github.com/#{name}/", &block)
26
+ end
27
+
28
+ def vimscripts(&block)
29
+ vim_script_group = VimScriptGroup.new
30
+ vim_script_group.instance_eval(&block) if block
31
+ end
32
+
33
+ def vimzips(&block)
34
+ zip_group = VimZipGroup.new
35
+ zip_group.instance_eval(&block) if block
36
+ end
37
+
38
+ def symlink(destination_folder_key, source_path)
39
+ bundle = SymlinkBundle.new(destination_folder_key, source_path)
40
+ Bundles << bundle
41
+ yield bundle, Bundles if block_given?
42
+ bundle
43
+ end
44
+
45
+ :private
46
+ def group(name, &block)
47
+ group = BundleGroup.new(name)
48
+ group.instance_eval(&block)
49
+ end
50
+ end
51
+
52
+ include VRundler
data/vrundler.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib",__FILE__)
3
+ require "vrundler/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vrundler"
7
+ s.version = VRundler::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.license = 'MIT'
10
+ s.authors = ["Develop With Passion®"]
11
+ s.email = ["open_source@developwithpassion.com"]
12
+ s.homepage = "http://www.developwithpassion.com"
13
+ s.summary = %q{Simple vim plugin manager}
14
+ s.description = %q{Lightweight ruby tool to manage my vim plugin ecosystem}
15
+ s.rubyforge_project = "vrundler"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ s.add_runtime_dependency "thor", "0.19.1"
24
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vrundler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Develop With Passion®
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ description: Lightweight ruby tool to manage my vim plugin ecosystem
28
+ email:
29
+ - open_source@developwithpassion.com
30
+ executables:
31
+ - vrundler
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - bin/vrundler
41
+ - lib/vrundler.rb
42
+ - lib/vrundler/basic_bundle.rb
43
+ - lib/vrundler/bundle.rb
44
+ - lib/vrundler/bundle_group.rb
45
+ - lib/vrundler/bundles.rb
46
+ - lib/vrundler/script_type_group.rb
47
+ - lib/vrundler/symlink_bundle.rb
48
+ - lib/vrundler/version.rb
49
+ - lib/vrundler/vim_script_bundle.rb
50
+ - lib/vrundler/vim_script_group.rb
51
+ - lib/vrundler/vim_zip_bundle.rb
52
+ - lib/vrundler/vim_zip_group.rb
53
+ - vrundler.gemspec
54
+ homepage: http://www.developwithpassion.com
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: vrundler
74
+ rubygems_version: 2.2.2
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Simple vim plugin manager
78
+ test_files: []