Module: VundleCli::Helper
- Defined in:
- lib/vundle_cli/helper.rb
Class Method Summary collapse
- .agree?(message, color = nil) ⇒ Boolean
- .file_validate(fpath, check_dir = false) ⇒ Object
- .plugin_base_name(plugin) ⇒ Object
-
.plugin_trim_name(plugin_name) ⇒ Object
Get the trimmed name of the plugin, e.g.
- .puts_separator ⇒ Object
Class Method Details
.agree?(message, color = nil) ⇒ Boolean
41 42 43 44 45 46 47 48 |
# File 'lib/vundle_cli/helper.rb', line 41 def agree?(, color = nil) begin = $terminal.color(, color) unless color.nil? agree() 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.(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_separator ⇒ Object
37 38 39 |
# File 'lib/vundle_cli/helper.rb', line 37 def puts_separator say "-----------------------------" end |