Class: Vvm::Installer
- Inherits:
-
Object
- Object
- Vvm::Installer
- Defined in:
- lib/vvm/installer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #checkout ⇒ Object
- #configure ⇒ Object
-
#initialize(version, conf, silent = false) ⇒ Installer
constructor
A new instance of Installer.
- #make_clean ⇒ Object
- #make_install ⇒ Object
- #message ⇒ Object
Constructor Details
#initialize(version, conf, silent = false) ⇒ Installer
Returns a new instance of Installer.
5 6 7 8 9 10 |
# File 'lib/vvm/installer.rb', line 5 def initialize(version, conf, silent = false) vvmopt = ENV['VVMOPT'] @silent = silent ? '> /dev/null 2>&1' : '' @version = version @conf = conf.flatten.empty? && vvmopt ? vvmopt.split(' ') : conf end |
Class Method Details
.cp_etc ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vvm/installer.rb', line 60 def self.cp_etc current_login = login_file path = File.join(File.dirname(__FILE__), '..', '..', 'etc', 'login') login = File.(path) if !File.exist?(current_login) etc = etc_dir FileUtils.mkdir_p(etc) FileUtils.cp(login, etc) elsif !FileUtils.compare_file(login, current_login) FileUtils.cp(login, etc_dir) end end |
.fetch ⇒ Object
12 13 14 15 16 |
# File 'lib/vvm/installer.rb', line 12 def self.fetch FileUtils.mkdir_p(repos_dir) repo = vimorg_dir system("hg -q clone #{VIM_URI} #{repo}") unless File.exist?(repo) end |
.pull ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/vvm/installer.rb', line 18 def self.pull fetch unless File.exist?(vimorg_dir) Dir.chdir(vimorg_dir) do system('hg -q pull') system('hg -q update') end end |
Instance Method Details
#checkout ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vvm/installer.rb', line 26 def checkout src = src_dir FileUtils.mkdir_p(src) return if File.exist?(src_dir(@version)) archive = "hg archive -t tar -r #{@version} -p #{@version} -" = "(cd #{src} && tar xf -)" Dir.chdir vimorg_dir do system("#{archive} | #{} #{@silent}") end end |
#configure ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/vvm/installer.rb', line 37 def configure vims = vims_dir(@version) src = src_dir(@version) default = "--prefix=#{vims}" Dir.chdir src do system("./configure #{default} #{@conf.join(' ')} #{@silent}") end end |
#make_clean ⇒ Object
46 47 48 49 50 51 |
# File 'lib/vvm/installer.rb', line 46 def make_clean src = src_dir(@version) Dir.chdir src do system("make clean #{@silent}") end end |
#make_install ⇒ Object
53 54 55 56 57 58 |
# File 'lib/vvm/installer.rb', line 53 def make_install src = src_dir(@version) Dir.chdir src do system("make all install #{@silent}") end end |
#message ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vvm/installer.rb', line 73 def return if !$?.success? || !@silent.empty? print "\e[32m" puts <<-EOS Vim is successfully installed. For daily use, please add the following line into your ~/.bash_login etc: test -f ~/.vvm-rb/etc/login && source ~/.vvm-rb/etc/login EOS print "\e[0m" end |