Module: VundleCli::Helper

Defined in:
lib/vundle_cli/helper.rb

Class Method Summary collapse

Class Method Details

.agree?(message, color = nil) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
# File 'lib/vundle_cli/helper.rb', line 41

def agree?(message, color = nil)
  begin
    message = $terminal.color(message, color) unless color.nil?
    agree(message)
  rescue Interrupt
    abort("\nAbort.")
  end
end

.file_validate(fpath, check_dir = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vundle_cli/helper.rb', line 5

def file_validate(fpath, check_dir = false)
  fpath = File.expand_path(fpath)

  unless File.exist?(fpath)
    raise ArgumentError.new("#{fpath} does not exist")
  end

  fpath = File.readlink(fpath) if File.symlink?(fpath)

  if check_dir
    unless File.directory?(fpath)
      raise ArgumentError.new("#{fpath} is not a directory")
    end
  else
    unless File.file?(fpath)
      raise ArgumentError.new("#{fpath} is not a valid file")
    end
  end

  fpath
end

.plugin_base_name(plugin) ⇒ Object



27
28
29
# File 'lib/vundle_cli/helper.rb', line 27

def plugin_base_name(plugin)
  File.basename(plugin)
end

.plugin_trim_name(plugin_name) ⇒ Object

Get the trimmed name of the plugin, e.g. remove prefix, suffix “vim-”, “-vim”, “.vim”.



33
34
35
# File 'lib/vundle_cli/helper.rb', line 33

def plugin_trim_name(plugin_name)
  plugin_name.gsub(/(vim-|-vim|\.vim)/, '')
end

.puts_separatorObject



37
38
39
# File 'lib/vundle_cli/helper.rb', line 37

def puts_separator
  say "-----------------------------"
end