Permalink
Browse files

add Env.determine_home_dir to vim-ruby-install.rb

  • Loading branch information...
dkearns committed Aug 27, 2005
1 parent cd0d6e0 commit 888664ad4ff1df581269d2ec57d2ef9c107f50d3
Showing with 26 additions and 17 deletions.
  1. +3 −0 ChangeLog
  2. +23 −17 bin/vim-ruby-install.rb
View
@@ -1,5 +1,8 @@
2005-08-27 Doug Kearns <djkea2@gus.gscit.monash.edu.au>
+ * bin/vim-ruby-install.rb: add Env.determine_home_dir using
+ %HOMEDRIVE%%HOMEPATH% as HOME on windows if HOME is not explicitly set
+
* syntax/ruby.vim: fix regression in rubyOptDoBlock
* syntax/ruby.vim: fix typo in rubyBlockParameter pattern
View
@@ -75,25 +75,31 @@ def Env.determine_source_directory
# TODO: print warning if vim command not in PATH or appropriate key not in registry?
def Env.determine_vim_dir
installation_dir = ENV['VIM'] ||
- case Env.determine_target_os
- when :UNIX
- IO.popen('vim --version 2>/dev/null') do |version|
- dir = version.read[/fall-back for \$VIM: "(.*)"/, 1]
+ case Env.determine_target_os
+ when :UNIX
+ IO.popen('vim --version 2>/dev/null') do |version|
+ dir = version.read[/fall-back for \$VIM: "(.*)"/, 1]
+ end
+ when :WINDOWS
+ require 'win32/registry'
+ path = ''
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Vim\Gvim') do |reg|
+ path = reg['path', Win32::Registry::REG_SZ]
+ end
+ dir = path.sub(/\\vim\d\d\\gvim.exe/i, '') unless path.empty? or path.nil?
end
- when :WINDOWS
- require 'win32/registry'
- path = ''
- Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Vim\Gvim') do |reg|
- path = reg['path', Win32::Registry::REG_SZ]
- end
- # TODO: Does Registry#[] ever return nil? Exceptions?
- unless path.empty? or path.nil?
- dir = path.sub(/\\vim\d\d\\gvim.exe/i, '')
- end
- end
return installation_dir
end
+ def Env.determine_home_dir
+ home_dir = ENV['HOME'] ||
+ case Env.determine_target_os
+ when :WINDOWS
+ ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] and ENV['HOMEPATH']
+ end
+ return home_dir
+ end
+
def Env.ask_user(message)
print message
gets.strip
@@ -229,15 +235,15 @@ def _potential_directories
# Return the Vim system preferences directory
def _vim_system_dir
- vim_dir = ENV['VIM'] || Env.determine_vim_dir
+ vim_dir = Env.determine_vim_dir
system_dir = vim_dir + "/vimfiles" if vim_dir
return system_dir
end
# Return the Vim user preferences directory
def _vim_user_dir
platform_dir = { :UNIX => "/.vim", :WINDOWS => "/vimfiles" }
- home_dir = ENV['HOME']
+ home_dir = Env.determine_home_dir
user_dir = home_dir + platform_dir[Env.determine_target_os] if home_dir
return user_dir
end

0 comments on commit 888664a

Please sign in to comment.