r908 - in /trunk/packages/vim-addon-manager: debian/changelog debian/control src/vim/addon-manager.rb src/vim/common.rb src/vim/constants.rb

zack at users.alioth.debian.org zack at users.alioth.debian.org
Sat Feb 10 17:19:03 UTC 2007


Author: zack
Date: Sat Feb 10 18:19:02 2007
New Revision: 908

URL: http://svn.debian.org/wsvn/pkg-vim/?sc=1&rev=908
Log:
- added feedback messages
- avoid performing unneeded actions
- run helpztags when stuff is installed/removed under doc/

Modified:
    trunk/packages/vim-addon-manager/debian/changelog
    trunk/packages/vim-addon-manager/debian/control
    trunk/packages/vim-addon-manager/src/vim/addon-manager.rb
    trunk/packages/vim-addon-manager/src/vim/common.rb
    trunk/packages/vim-addon-manager/src/vim/constants.rb

Modified: trunk/packages/vim-addon-manager/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-addon-manager/debian/changelog?rev=908&op=diff
==============================================================================
--- trunk/packages/vim-addon-manager/debian/changelog (original)
+++ trunk/packages/vim-addon-manager/debian/changelog Sat Feb 10 18:19:02 2007
@@ -1,9 +1,14 @@
 vim-addon-manager (0.2) UNRELEASED; urgency=low
 
-  * debian/TODO.Debian
-    - create TODO file with a couple of items
+  * vim-addons:
+    - when files are installed or removed under doc/ run helpztags afterwards
+      to regenerate help tags
+    - avoid performing an action when there is no need to perform it
+    - added feedback messages for the user
+  * debian/control
+    - added dependency on vim-common, which ships /usr/bin/helpztags
 
- -- Stefano Zacchiroli <zack at debian.org>  Wed,  7 Feb 2007 12:57:02 +0100
+ -- Stefano Zacchiroli <zack at debian.org>  Sat, 10 Feb 2007 18:17:08 +0100
 
 vim-addon-manager (0.1) experimental; urgency=low
 

Modified: trunk/packages/vim-addon-manager/debian/control
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-addon-manager/debian/control?rev=908&op=diff
==============================================================================
--- trunk/packages/vim-addon-manager/debian/control (original)
+++ trunk/packages/vim-addon-manager/debian/control Sat Feb 10 18:19:02 2007
@@ -7,7 +7,7 @@
 
 Package: vim-addon-manager
 Architecture: all
-Depends: ruby, ${misc:Depends}
+Depends: ruby, vim-common, ${misc:Depends}
 Recommends: vim-tiny | vim | gvim
 Description: manager of addons for the Vim editor
  vim-addon-manager is a tool for managing addons for the Vim

Modified: trunk/packages/vim-addon-manager/src/vim/addon-manager.rb
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-addon-manager/src/vim/addon-manager.rb?rev=908&op=diff
==============================================================================
--- trunk/packages/vim-addon-manager/src/vim/addon-manager.rb (original)
+++ trunk/packages/vim-addon-manager/src/vim/addon-manager.rb Sat Feb 10 18:19:02 2007
@@ -12,6 +12,7 @@
 require 'fileutils'
 
 require 'vim/common'
+require 'vim/constants'
 
 module Vim
 
@@ -26,37 +27,54 @@
     attr_accessor :target_dir
 
     def install(addons)
-      addons.each do |a|
-	base_dir = (a.basedir or @source_dir)
-	symlink = lambda do |f|
-	  dest = File.join(@target_dir, f)
+      installed_files = []
+      addons.each do |addon|
+	base_dir = (addon.basedir or @source_dir)
+	symlink = lambda do |file|
+	  dest = File.join(@target_dir, file)
 	  dest_dir = File.dirname dest
 	  FileUtils.mkdir_p dest_dir unless File.directory? dest_dir
-	  FileUtils.ln_sf(File.join(base_dir, f), dest)
+	  FileUtils.ln_sf(File.join(base_dir, file), dest)
 	end
-	status = a.status(@target_dir)
+	status = addon.status(@target_dir)
 	case status.status
 	when :broken
+	  Vim.info "installing broken addon '#{addon}'"
 	  status.missing_files.each(&symlink)
+          installed_files.concat(status.missing_files.to_a)
 	when :not_installed
-	  a.files.each(&symlink)
+	  Vim.info "installing removed addon '#{addon}'"
+	  addon.files.each(&symlink)
+          installed_files.concat(addon.files.to_a)
+        else
+          Vim.info "ignoring '#{addon}' which is neither removed nor broken"
 	end
       end
+      rebuild_tags(installed_files)
     end
 
     def remove(addons)
       # TODO remove empty directories (recursively toward the top of ~/.vim/,
       # a la rmdir -p)
-      rmlink = lambda {|f| File.delete(File.join(@target_dir, f)) }
-      addons.each do |a|
-	status = a.status(@target_dir)
+      removed_files = []
+      rmlink = lambda {|file| File.delete(File.join(@target_dir, file)) }
+      addons.each do |addon|
+	status = addon.status(@target_dir)
 	case status.status
 	when :installed
-	  a.files.each(&rmlink)
+	  Vim.info "removing installed addon '#{addon}'"
+	  addon.files.each(&rmlink)
+          removed_files.concat(addon.files.to_a)
 	when :broken
-	  (a.files - status.missing_files).each(&rmlink)
+	  Vim.info "removing broken addon '#{addon}'"
+          files = (addon.files - status.missing_files)
+	  files.each(&rmlink)
+          removed_files.concat(files.to_a)
+        else
+          Vim.info "ignoring '#{addon}' which is neither installed nor broken"
 	end
       end
+      rebuild_tags(removed_files)
     end
 
     def disable(addons)
@@ -64,10 +82,13 @@
         addons.each do |addon|  # disable each not yet disabled addon
           if not addon.disabled_by_line
             Vim.warn \
-              "#{addon} can't be disabled (since it has no disabledby field)"
+              "#{addon} can't be disabled (since it has no 'disabledby' field)"
             next
           end
-          unless lines.any? {|line| addon.is_disabled_by? line}
+          if lines.any? {|line| addon.is_disabled_by? line}
+	    Vim.info "ignoring addon '#{addon}' which is already disabled"
+	  else
+	    Vim.info "disabling enabled addon '#{addon}'"
             lines << addon.disabled_by_line + "\n"
           end
         end
@@ -82,7 +103,12 @@
               "#{addon} can't be amended (since it has no disabledby field)"
             next
           end
-          lines.reject! {|line| addon.is_disabled_by? line}
+	  if lines.any? {|line| addon.is_disabled_by? line}
+	    Vim.info "amending disabled addon '#{addon}'"
+	    lines.reject! {|line| addon.is_disabled_by? line}
+	  else
+	    Vim.info "ignoring addon '#{addon}' which is enabled"
+	  end
         end
       end
     end
@@ -110,6 +136,15 @@
       end
     end
 
+    def rebuild_tags(files)
+      needs_rebuilding = files.any? {|file| file =~ /^doc\//}
+      if needs_rebuilding
+        Vim.info 'Rebuilding tags since documentation has been modified ...'
+        Vim.system "#{HELPZTAGS} #{@target_dir}"
+        Vim.info 'done.'
+      end
+    end
+
   end
 
 end

Modified: trunk/packages/vim-addon-manager/src/vim/common.rb
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-addon-manager/src/vim/common.rb?rev=908&op=diff
==============================================================================
--- trunk/packages/vim-addon-manager/src/vim/common.rb (original)
+++ trunk/packages/vim-addon-manager/src/vim/common.rb Sat Feb 10 18:19:02 2007
@@ -33,6 +33,15 @@
     def warn(s)
       puts "Warning: #{s}"
     end
+
+    def info(s)
+      puts "Info: #{s}"
+    end
+
+    def system(cmd)
+      info "executing '#{cmd}'" if verbose?
+      Kernel::system cmd
+    end
   end
 
 

Modified: trunk/packages/vim-addon-manager/src/vim/constants.rb
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-addon-manager/src/vim/constants.rb?rev=908&op=diff
==============================================================================
--- trunk/packages/vim-addon-manager/src/vim/constants.rb (original)
+++ trunk/packages/vim-addon-manager/src/vim/constants.rb Sat Feb 10 18:19:02 2007
@@ -12,5 +12,6 @@
 module Vim
 
   OVERRIDE_FILE = 'plugin/000-vim-addons.vim'
+  HELPZTAGS = '/usr/bin/helpztags'
 
 end




More information about the pkg-vim-maintainers mailing list