Class: Swagger::Diff::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger/diff/diff.rb

Instance Method Summary collapse

Constructor Details

#initialize(old, new) ⇒ Diff

Returns a new instance of Diff.



4
5
6
7
# File 'lib/swagger/diff/diff.rb', line 4

def initialize(old, new)
  @new_specification = Swagger::Diff::Specification.new(new)
  @old_specification = Swagger::Diff::Specification.new(old)
end

Instance Method Details

#changesObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/swagger/diff/diff.rb', line 9

def changes
  @changes ||= {
    new_endpoints: new_endpoints.to_a.sort,
    removed_endpoints: missing_endpoints.to_a.sort,
    new_request_params: new_or_changed_request_params,
    removed_request_params: incompatible_request_params,
    new_response_attributes: new_or_changed_response_attributes,
    removed_response_attributes: incompatible_response_attributes
  }
end

#changes_messageObject



20
21
22
# File 'lib/swagger/diff/diff.rb', line 20

def changes_message
  changed_endpoints_message + changed_params_message + changed_attrs_message
end

#compatible?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/swagger/diff/diff.rb', line 24

def compatible?
  endpoints_compatible? && requests_compatible? && responses_compatible?
end

#incompatibilitiesObject



28
29
30
31
32
33
34
# File 'lib/swagger/diff/diff.rb', line 28

def incompatibilities
  @incompatibilities ||= {
    endpoints: missing_endpoints.to_a.sort,
    request_params: incompatible_request_params,
    response_attributes: incompatible_response_attributes
  }
end

#incompatibilities_messageObject



36
37
38
39
40
41
42
# File 'lib/swagger/diff/diff.rb', line 36

def incompatibilities_message
  msg = ''
  msg += endpoints_message('missing', incompatibilities[:endpoints])
  msg += params_message('incompatible', incompatibilities[:request_params])
  msg += attributes_message('incompatible', incompatibilities[:response_attributes])
  msg
end