Class: Installer

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Installer.



4
5
6
7
8
9
# File 'lib/vvm-rb/installer.rb', line 4

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_etcObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vvm-rb/installer.rb', line 56

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

.fetchObject



11
12
13
14
15
# File 'lib/vvm-rb/installer.rb', line 11

def self.fetch
  FileUtils.mkdir_p(get_repos_dir)
  repos_dir = get_vimorg_dir
  system("hg -q clone #{VIM_URI} #{repos_dir}") unless File.exist?(repos_dir)
end

.pullObject



17
18
19
# File 'lib/vvm-rb/installer.rb', line 17

def self.pull
  Dir.chdir(get_vimorg_dir) { system('hg -q pull') }
end

Instance Method Details

#checkoutObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vvm-rb/installer.rb', line 21

def checkout
  src_dir = get_src_dir
  FileUtils.mkdir_p(src_dir)
  unless File.exist?(get_src_dir(@version))
    archive = "hg archive -t tar -r #{@version} -p #{@version} -"
    expand  = "(cd #{src_dir} && tar xf -)"
    Dir.chdir get_vimorg_dir do
      system("#{archive} | #{expand} #{@silent}")
    end
  end
end

#configureObject



33
34
35
36
37
38
39
40
# File 'lib/vvm-rb/installer.rb', line 33

def configure
  vims_dir = get_vims_dir(@version)
  src_dir  = get_src_dir(@version)
  default  = "--prefix=#{vims_dir}"
  Dir.chdir src_dir do
    system("./configure #{default} #{@conf.join(' ')} #{@silent}")
  end
end

#make_cleanObject



42
43
44
45
46
47
# File 'lib/vvm-rb/installer.rb', line 42

def make_clean
  src_dir = get_src_dir(@version)
  Dir.chdir src_dir do
    system("make clean #{@silent}")
  end
end

#make_installObject



49
50
51
52
53
54
# File 'lib/vvm-rb/installer.rb', line 49

def make_install
  src_dir = get_src_dir(@version)
  Dir.chdir src_dir do
    system("make all install #{@silent}")
  end
end