Class: VundleCli::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/vundle_cli/finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, plugin = '') ⇒ Finder

Returns a new instance of Finder.



6
7
8
9
10
# File 'lib/vundle_cli/finder.rb', line 6

def initialize(options, plugin = '')
  @options = options
  @vimrc = file_validate(options.vimrc)
  @plugin = plugin
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/vundle_cli/finder.rb', line 4

def options
  @options
end

#pluginObject (readonly)

Returns the value of attribute plugin.



4
5
6
# File 'lib/vundle_cli/finder.rb', line 4

def plugin
  @plugin
end

#vimrcObject (readonly)

Returns the value of attribute vimrc.



4
5
6
# File 'lib/vundle_cli/finder.rb', line 4

def vimrc
  @vimrc
end

Instance Method Details

#find?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vundle_cli/finder.rb', line 28

def find?
  say "Searching..."
  found = false
  open(@vimrc, 'r').each { |l|
    matches = l.chomp.match(/^(Bundle|Plugin) (\S*)/)
    if matches
      plugin = matches[2].gsub(/[',]/, '')
      if plugin.downcase.include?(@plugin.downcase)
        say_ok "Found "
        say plugin
        found = true
      end
    end
  }
  found
end

#get_listObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/vundle_cli/finder.rb', line 12

def get_list
  plugins = Array.new
  open(@vimrc, 'r').each { |l|
    matches = l.chomp.match(/^(Bundle|Plugin) (\S*)/)
    if matches
      plugins << matches[2].gsub(/[',]/, '')
    end
  }
  plugins
end

#listObject



23
24
25
26
# File 'lib/vundle_cli/finder.rb', line 23

def list
  enable_paging
  say get_list.join("\n")
end