Class: Liminal::Openapi::Verification::StructuralDifference

Inherits:
Object
  • Object
show all
Defined in:
lib/liminal/openapi/verification/structural_difference.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, checked, generated) ⇒ StructuralDifference

Returns a new instance of StructuralDifference.



45
46
47
48
49
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 45

def initialize(path, checked, generated)
  @path = path.freeze
  @checked = checked
  @generated = generated
end

Instance Attribute Details

#checkedObject (readonly)

Returns the value of attribute checked.



10
11
12
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 10

def checked
  @checked
end

#generatedObject (readonly)

Returns the value of attribute generated.



10
11
12
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 10

def generated
  @generated
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 10

def path
  @path
end

Class Method Details

.between(checked, generated, path = []) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 12

def self.between(checked, generated, path = [])
  return if checked.eql?(generated)
  return between_hashes(checked, generated, path) if checked.is_a?(Hash) && generated.is_a?(Hash)
  return between_arrays(checked, generated, path) if checked.is_a?(Array) && generated.is_a?(Array)

  new(path, checked, generated)
end

Instance Method Details

#checked_labelObject



57
58
59
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 57

def checked_label
  display(checked)
end

#generated_labelObject



61
62
63
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 61

def generated_label
  display(generated)
end

#pointerObject



51
52
53
54
55
# File 'lib/liminal/openapi/verification/structural_difference.rb', line 51

def pointer
  return "#" if path.empty?

  "#/#{path.map { |part| escape_pointer(part) }.join('/')}"
end