Class: Nvvm::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/nvvm/installer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, conf, silent: false) ⇒ Installer

Returns a new instance of Installer.



5
6
7
8
9
10
# File 'lib/nvvm/installer.rb', line 5

def initialize(version, conf, silent: false)
  nvvmopt  = ENV['NVVMOPT']
  @silent  = silent ? '> /dev/null 2>&1' : ''
  @version = version
  @conf    = conf.flatten.empty? && nvvmopt ? nvvmopt.split(' ') : conf
end

Class Method Details

.cp_etcObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/nvvm/installer.rb', line 52

def self.cp_etc
   = 
  path          = File.join(File.dirname(__FILE__), '..', '..', 'etc', 'login')
           = File.expand_path(path)
  if !File.exist?()
    etc = etc_dir
    FileUtils.mkdir_p(etc)
    FileUtils.cp(, etc)
  elsif !FileUtils.compare_file(, )
    FileUtils.cp(, etc_dir)
  end
end

.fetchObject



12
13
14
# File 'lib/nvvm/installer.rb', line 12

def self.fetch
  system("git clone --quiet #{VIM_URI} #{repo_dir}") unless File.exist?(repo_dir)
end

.pullObject



16
17
18
19
20
21
22
# File 'lib/nvvm/installer.rb', line 16

def self.pull
  fetch unless File.exist?(repo_dir)
  Dir.chdir(repo_dir) do
    system('git pull --rebase --quiet')
    system('git fetch --tags --force --quiet')
  end
end

Instance Method Details

#checkoutObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nvvm/installer.rb', line 24

def checkout
  src = src_dir(@version)
  return if File.exist?(src)

  FileUtils.mkdir_p(src)
  archive = "git archive --format=tar #{@version}"
  expand  = "(cd #{src} && tar xf -)"
  Dir.chdir repo_dir do
    system("#{archive} | #{expand} #{@silent}")
  end
end

#make_cleanObject



36
37
38
39
40
41
42
43
# File 'lib/nvvm/installer.rb', line 36

def make_clean
  src       = src_dir(@version)
  src_build = File.join(src, 'build')
  FileUtils.rm_rf(src_build) if File.exist?(src_build)
  Dir.chdir src do
    system("make clean #{@silent}")
  end
end

#make_installObject



45
46
47
48
49
50
# File 'lib/nvvm/installer.rb', line 45

def make_install
  src = src_dir(@version)
  Dir.chdir src do
    system("make CMAKE_BUILD_TYPE=Release #{@silent}")
  end
end

#messageObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/nvvm/installer.rb', line 65

def message
  return unless message?

  print "\e[32m"
  puts "\n  Neovim is successfully installed. For daily use,\n  please add the following line into your ~/.bash_login etc:\n\n  test -f ~/.nvvm/etc/login && source ~/.nvvm/etc/login\n\n  MESSAGE\n  print \"\\e[0m\"\nend\n"