Class: Fitting::Doc::CombinationOptional
- Inherits:
-
CombinationStep
- Object
- Step
- CombinationStep
- Fitting::Doc::CombinationOptional
- Defined in:
- lib/fitting/doc/combination_optional.rb
Instance Attribute Summary
Attributes inherited from CombinationStep
Attributes inherited from Step
#index_after, #index_before, #index_medium, #next_steps, #res_after, #res_before, #res_medium, #step_cover_size, #step_key
Instance Method Summary collapse
Methods inherited from CombinationStep
#debug_report, #initialize, #initialize_combinations
Methods inherited from Step
#index_offset, #mark_enum, #mark_range, #mark_required, #new_index_offset, #next, #nocover!, #range, #to_hash, #valid?
Constructor Details
This class inherits a constructor from Fitting::Doc::CombinationStep
Instance Method Details
#cover!(log) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fitting/doc/combination_optional.rb', line 7 def cover!(log) error = JSON::Validator.fully_validate(@json_schema, log.body) if error == [] @step_cover_size += 1 @logs.push(log.body) nil end end |
#report(res, index) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fitting/doc/combination_optional.rb', line 16 def report(res, index) @index_before = index @res_before = [] + res @index_medium = index @res_medium = [] + res combinations = @step_key.split('.') elements = YAML.dump(@source_json_schema).split("\n")[1..-1] res_index = 0 elements.each_with_index do |element, i| if element.include?(combinations[-1]) res_index = i break end end res[res_index + index] = @step_cover_size res[res_index + index + 1] = @step_cover_size if @source_json_schema["properties"][combinations[-1]] && @source_json_schema["properties"][combinations[-1]].class == Hash && @source_json_schema["properties"][combinations[-1]]["type"] == "array" res[res_index + index + 2] = @step_cover_size res[res_index + index + 3] = @step_cover_size res[res_index + index + 4] = @step_cover_size schema = @source_json_schema["properties"][combinations[-1]]['items'] mark_required(res_index + index + 4, res, schema) elsif @source_json_schema["properties"][combinations[-1]] && @source_json_schema["properties"][combinations[-1]].class == Hash && @source_json_schema["properties"][combinations[-1]]["type"] == "object" schema = @source_json_schema["properties"][combinations[-1]] res[res_index + index + 2] = @step_cover_size mark_required(res_index + index + 2, res, schema) end @index_after = res_index + index + 4 @res_after = [] + res [res, index] end |