PATCH: installer source directory detection (was Re: The installer
again -- further tests.)
Doug Kearns
dougkearns at gmail.com
Mon Jul 4 02:31:55 EDT 2005
On Tue, Jan 04, 2005 at 11:29:06AM +0000, Hugh Sasse Staff Elec Eng wrote:
>
> OK, here is the diff with the extra diagnostic print statements
> removed. this is against the CVS as grabbed with wget from
> http://rubyforge.org/cgi-bin/viewcvs.cgi/vim-ruby/bin/vim-ruby-install.rb?cvsroot=vim-ruby
>
> today.
>
> You don't need to worry about the change from env ruby on the first
> line of course...
OK, I'll stick my nose in where it doesn't belong and commit this. ;-)
Thanks Hugh!
Is there any reason we're trying the current directory as a possible
source directory first. Isn't it always going to be one up from the
installation script? Excluding the gems case because I know nothing of
RubyGems...
Committed as:
Index: bin/vim-ruby-install.rb
===================================================================
RCS file: /var/cvs/vim-ruby/vim-ruby/bin/vim-ruby-install.rb,v
retrieving revision 1.1
diff -u -r1.1 vim-ruby-install.rb
--- bin/vim-ruby-install.rb 19 Sep 2004 15:37:35 -0000 1.1
+++ bin/vim-ruby-install.rb 4 Jul 2005 06:23:44 -0000
@@ -52,8 +52,11 @@
# 1. Try the current directory.
if SOURCE_FILES.all? { |path| FileTest.file?(path) }
return '.'
+ # 2. Try the directory above this installation script.
+ elsif SOURCE_FILES.map { |f| File.join(File.dirname($0), '..', f) }.all? { |path| FileTest.file?(path) }
+ return File.join(File.dirname($0), '..')
end
- # 2. Try the gem 'vim-ruby'.
+ # 3. Try the gem 'vim-ruby'.
begin
require 'rubygems'
raise "Need RubyGems 0.8+" if Gem::RubyGemsPackageVersion < '0.8'
@@ -231,6 +234,9 @@
# will be copied. Both are strings.
def initialize(source, target)
@source_dir = source
+ unless FileTest.directory?(@source_dir)
+ raise "Automatically determined source directory ('#{@source_dir}') doesn't exist"
+ end
unless FileTest.directory?(target)
raise "Chosen target directory ('#{target}') doesn't exist"
end
@@ -366,6 +372,7 @@
op.parse!(ARGV)
source_dir = Env.determine_source_directory
+if source_dir.nil? then raise "Can't find source directory"; end
target_dir = $options[:target_dir] || TargetDirectory.finder.find_target_directory
VimRubyInstaller.new(source_dir, target_dir).install
More information about the vim-ruby-devel
mailing list