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, bundle = '') ⇒ Finder

Returns a new instance of Finder.



10
11
12
13
14
# File 'lib/vundle_cli/finder.rb', line 10

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

Instance Attribute Details

#bundleObject (readonly)

Returns the value of attribute bundle.



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

def bundle
  @bundle
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#vimrcObject (readonly)

Returns the value of attribute vimrc.



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

def vimrc
  @vimrc
end

Instance Method Details

#findObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/vundle_cli/finder.rb', line 25

def find
  puts "Searching..."
  open(@vimrc, 'r').each { |l| 
    matches = l.chomp.match(/^Bundle (\S*)/)
    if matches
      bundle = matches[1].gsub("'", '')
      puts "Found #{bundle}" if bundle.downcase.include?(@bundle.downcase)
    end
  }
end

#listObject



16
17
18
19
20
21
22
23
# File 'lib/vundle_cli/finder.rb', line 16

def list
  open(@vimrc, 'r').each { |l| 
    matches = l.chomp.match(/^Bundle (\S*)/)
    if matches
      puts matches[1].gsub("'", '')
    end
  }
end