Class: Spellcop::FolderChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/spellcop/folder_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(foldername, recursive = true) ⇒ FolderChecker

Returns a new instance of FolderChecker.



5
6
7
8
9
10
11
12
13
# File 'lib/spellcop/folder_checker.rb', line 5

def initialize(foldername, recursive = true)
  @warnings = []
  if recursive
    @folder = "#{foldername}/**/*.rb"
  else
    @folder = "#{foldername}/*.rb"
  end
  @files = []
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/spellcop/folder_checker.rb', line 3

def files
  @files
end

#warningsObject (readonly)

Returns the value of attribute warnings.



3
4
5
# File 'lib/spellcop/folder_checker.rb', line 3

def warnings
  @warnings
end

Instance Method Details

#check!Object



15
16
17
18
19
20
21
22
# File 'lib/spellcop/folder_checker.rb', line 15

def check!
  Dir[@folder].each do |file|
    result = { file: file, warnings: FileChecker.new(file).check! }
    @warnings << result unless result[:warnings].empty?
    @files << file
  end
  @warnings
end