Class: R2OAS::Schema::V3::TagAnalyzer

Inherits:
BaseAnalyzer show all
Defined in:
lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb

Constant Summary

Constants inherited from Base

Base::SUPPORT_COMPONENTS_OBJECTS

Instance Method Summary collapse

Methods inherited from BaseAnalyzer

#generate_from_existing_schema

Methods included from R2OAS::Sortable

#deep_sort

Methods inherited from Base

#support_components_objects

Constructor Details

#initialize(after_schema_data, options = {}) ⇒ TagAnalyzer

Returns a new instance of TagAnalyzer.



12
13
14
15
16
17
# File 'lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb', line 12

def initialize(after_schema_data, options = {})
  super({}, after_schema_data, options)
  @file_manager = FileManager.new('tags', :relative)
  before_schema_data = @file_manager.load_data
  @diff_manager = TagDiffManager.new(before_schema_data, after_schema_data)
end

Instance Method Details

#analyze_docsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb', line 19

def analyze_docs
  save_file_path = @file_manager.save_file_path(type: :relative)
  case @type
  when :edited
    @diff_manager.process_by_using_diff_data do |after_edited_data|
      @file_manager.save(after_edited_data.to_yaml)
      logger.info "  Write schema file: \t#{save_file_path}"
    end
  when :existing
    result = @diff_manager.after_target_data
    @file_manager.save(result.to_yaml)
    logger.info "  Write schema file: \t#{save_file_path}"
  else
    raise NoImplementError
  end
end