Class: OKF::Bundle::Validator::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/okf/bundle/validator/result.rb

Overview

The outcome of a ยง9 conformance check (see OKF::Bundle::Validator): hard errors, soft warnings, and file counts. Conformant iff there are no errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



11
12
13
14
15
# File 'lib/okf/bundle/validator/result.rb', line 11

def initialize
  @errors = []
  @warnings = []
  @counts = { concepts: 0, indexes: 0, logs: 0 }
end

Instance Attribute Details

#countsObject (readonly)

Returns the value of attribute counts.



9
10
11
# File 'lib/okf/bundle/validator/result.rb', line 9

def counts
  @counts
end

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/okf/bundle/validator/result.rb', line 9

def errors
  @errors
end

#warningsObject (readonly)

Returns the value of attribute warnings.



9
10
11
# File 'lib/okf/bundle/validator/result.rb', line 9

def warnings
  @warnings
end

Instance Method Details

#add_error(path, message) ⇒ Object



21
22
23
# File 'lib/okf/bundle/validator/result.rb', line 21

def add_error(path, message)
  errors << { path: path, message: message }
end

#add_warning(path, message) ⇒ Object



25
26
27
# File 'lib/okf/bundle/validator/result.rb', line 25

def add_warning(path, message)
  warnings << { path: path, message: message }
end

#count(kind) ⇒ Object



29
30
31
# File 'lib/okf/bundle/validator/result.rb', line 29

def count(kind)
  @counts[kind] += 1 if @counts.key?(kind)
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/okf/bundle/validator/result.rb', line 17

def valid?
  errors.empty?
end