Module: ConsistencyCheck

Defined in:
lib/consistency_check.rb,
lib/consistency_check/version.rb,
lib/generators/consistency_check/install/install_generator.rb

Defined Under Namespace

Modules: Generators

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.run_all(max_shown_violations = 5) ⇒ Object



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

def run_all(max_shown_violations = 5)
  ConsistencyCheck::Definitions.methods(false).map do |method|
    puts "Running #{method}..."
    violations = ConsistencyCheck::Definitions.send method
    first_violations_ids = violations.take(max_shown_violations).map(&:id).join(',')
    optional_ellipsis = violations.to_a.count > max_shown_violations ? '...' : ''
    result = violations.empty? ? 'OK' : "FAIL (#{violations.to_a.count} violations: #{first_violations_ids}#{optional_ellipsis})"
    ConsistencyCheckResult.new(name: method.to_s.camelcase, violations: violations.to_a.count, result: result)
  end
end