Class: Chid::Commands::Installs::Vim

Inherits:
Chid::Command show all
Defined in:
lib/chid/commands/installs/vim.rb

Constant Summary

Constants inherited from Chid::Command

Chid::Command::COMMANDS

Instance Attribute Summary

Attributes inherited from Chid::Command

#options

Instance Method Summary collapse

Methods inherited from Chid::Command

command, help, #initialize, map_options_with_values, run

Constructor Details

This class inherits a constructor from Chid::Command

Instance Method Details

#do_gvim?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/chid/commands/installs/vim.rb', line 52

def do_gvim?
  answers = ['Yes','No']
  should_install_gvim = prompt.select('Install gvim too?', answers)
  should_install_gvim == 'Yes'
end

#do_vim?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/chid/commands/installs/vim.rb', line 46

def do_vim?
  answers = ['Yes','No']
  should_install_vim = prompt.select('Install vim ?', answers)
  should_install_vim == 'Yes'
end

#promptObject



42
43
44
# File 'lib/chid/commands/installs/vim.rb', line 42

def prompt
  @prompt ||= TTY::Prompt.new
end

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chid/commands/installs/vim.rb', line 21

def run
  puts "\nInstalling vim..."

  is_vim = do_vim?
  is_gvim = do_gvim?

  ::ChidConfig.on_linux do
    system('sudo apt-get install vim') if is_vim
    system('sudo apt-get install vim-gnome') if is_gvim
  end

  ::ChidConfig.on_osx do
    system('brew install vim && brew install macvim')
  end

  puts "\nVim installed successfully" if is_vim
  puts "\nGvim installed successfully" if is_gvim

  puts "\nNothing installed =(" unless is_vim || is_gvim
end