[SCM] vim-addon-manager packaging branch, master, updated. v0.4.4-52-geef7258
Antonio Terceiro
terceiro at debian.org
Tue Jan 31 23:33:28 UTC 2012
The following commit has been merged in the master branch:
commit 7e01731632e0d431249085a08fc877b02083d236
Author: Antonio Terceiro <terceiro at debian.org>
Date: Sun Jan 22 12:28:38 2012 -0200
Making the Addon class select an implementation
If the yaml description contains a 'files' attribute, we use the legacy
Addon class, otherwise we assume that it describes a new style addon,
with one directory that must be added to the vim runtimepath.
diff --git a/lib/vim/addon_manager/addon.rb b/lib/vim/addon_manager/addon.rb
index 83417ef..7444725 100644
--- a/lib/vim/addon_manager/addon.rb
+++ b/lib/vim/addon_manager/addon.rb
@@ -6,14 +6,17 @@ module Vim
class Addon
+ # Initializes a new Addon instance.
+ #
+ # If a subclass defines its own +initialize+ method, then it *must* call
+ # super at some point to make sure essential data is properly
+ # initialized.
+ #
def initialize(yaml, basedir)
@basedir = (yaml['basedir'] or basedir)
@description = yaml['description']
@name = yaml['addon']
- @files = Set.new yaml['files']
- raise ArgumentError.new('empty addon') if @files.size == 0
-
@disabled_by_line = yaml['disabledby']
if @disabled_by_line then
@disabled_by_RE = /^\s*#{Regexp.escape @disabled_by_line}\s*$/
@@ -23,6 +26,14 @@ module Vim
end
+ # Returns a Set of the files contained in this addon.
+ #
+ # This method must be overriden by subclasses.
+ #
+ def files
+ Set.new
+ end
+
# return the status of the self add-on wrt a target installation
# directory, and the system wide installation directory.
#
@@ -76,13 +87,16 @@ module Vim
attr_reader :basedir
attr_reader :description
- attr_reader :files
attr_reader :name
attr_reader :disabled_by_line
alias_method :addon, :name
def self.build(yaml, basedir)
- Vim::AddonManager::Addon::Legacy.new(yaml, basedir)
+ if yaml['files']
+ Vim::AddonManager::Addon::Legacy.new(yaml, basedir)
+ else
+ Vim::AddonManager::Addon::Directory.new(yaml, basedir)
+ end
end
private
@@ -108,3 +122,4 @@ module Vim
end
require 'vim/addon_manager/addon/legacy'
+require 'vim/addon_manager/addon/directory'
diff --git a/lib/vim/addon_manager/addon/directory.rb b/lib/vim/addon_manager/addon/directory.rb
new file mode 100644
index 0000000..1569fa7
--- /dev/null
+++ b/lib/vim/addon_manager/addon/directory.rb
@@ -0,0 +1,15 @@
+module Vim
+
+ class AddonManager
+
+ class Addon
+
+ class Directory < Addon
+
+ end
+ end
+
+ end
+
+end
+
diff --git a/lib/vim/addon_manager/addon/legacy.rb b/lib/vim/addon_manager/addon/legacy.rb
index b76c674..160ef42 100644
--- a/lib/vim/addon_manager/addon/legacy.rb
+++ b/lib/vim/addon_manager/addon/legacy.rb
@@ -6,6 +6,14 @@ module Vim
class Legacy < Addon
+ def initialize(yaml, basedir)
+ @files = Set.new yaml['files']
+ raise ArgumentError.new('empty addon') if @files.size == 0
+ super
+ end
+
+ attr_reader :files
+
def status(target_dir)
expected_dest = @files.collect {|f| File.join(target_dir, f)}
installed = expected_dest.select do |f|
diff --git a/spec/data/addons/ftplugin/foo.vim b/spec/data/bundle/newstyle/ftplugin/newstyle.vim
similarity index 100%
copy from spec/data/addons/ftplugin/foo.vim
copy to spec/data/bundle/newstyle/ftplugin/newstyle.vim
diff --git a/spec/data/addons/ftplugin/foo.vim b/spec/data/bundle/newstyle/syntax/newstyle.vim
similarity index 100%
copy from spec/data/addons/ftplugin/foo.vim
copy to spec/data/bundle/newstyle/syntax/newstyle.vim
diff --git a/spec/data/registry/newstyle.yaml b/spec/data/registry/newstyle.yaml
new file mode 100644
index 0000000..1bf87e7
--- /dev/null
+++ b/spec/data/registry/newstyle.yaml
@@ -0,0 +1,3 @@
+addon: newstyle
+description: "new style addon with a directory instead of files"
+basedir: /usr/share/vim-scripts/bundles
diff --git a/spec/vim/addon_manager/addon_spec.rb b/spec/vim/addon_manager/addon_spec.rb
new file mode 100644
index 0000000..0b5677a
--- /dev/null
+++ b/spec/vim/addon_manager/addon_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe Vim::AddonManager::Addon do
+
+ it 'should build legacy addon objects if files atribute is specified' do
+ addon('foo').should be_a(Vim::AddonManager::Addon::Legacy)
+ end
+
+ it 'should build new style addon objects if files attribute is not specified' do
+ addon('newstyle').should be_a(Vim::AddonManager::Addon::Directory)
+ end
+
+end
--
vim-addon-manager packaging
More information about the pkg-vim-maintainers
mailing list