Class: Checker::Modules::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/checker/modules/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_list = nil) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/checker/modules/base.rb', line 6

def initialize(file_list = nil)
  self.files = file_list
  self.full_results = {:total => 0, :ok => 0, :warning => 0, :fail => 0}
end

Instance Attribute Details

#filesObject

Returns the value of attribute files.



4
5
6
# File 'lib/checker/modules/base.rb', line 4

def files
  @files
end

#full_resultsObject

Returns the value of attribute full_results.



4
5
6
# File 'lib/checker/modules/base.rb', line 4

def full_results
  @full_results
end

Instance Method Details

#checkObject



11
12
13
14
15
16
17
# File 'lib/checker/modules/base.rb', line 11

def check
  check_files_existing or return true
  print_module_header
  check_executable or return true
  check_all_files
  valid?
end

#classnameObject



35
36
37
# File 'lib/checker/modules/base.rb', line 35

def classname
  self.class.to_s.split('::').last
end

#files_to_checkObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/checker/modules/base.rb', line 23

def files_to_check
  @files_to_check ||= begin
    if self.class.extensions.any?
      self.files.select { |f|
        self.class.extensions.map { |ex| f.ends_with?(".#{ex}") }.any?
      }
    else
      self.files
    end
  end
end

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/checker/modules/base.rb', line 19

def valid?
  @results.all_true?
end