Sha256: d157ee74a87b4252d51d967e604cab00d727cc54a9c1b04f2a728789a499ce3a

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require_relative '../base_analyzer'
require 'r2-oas/schema/v3/manager/file/components_file_manager'
require 'r2-oas/schema/v3/manager/diff/components_diff_manager'

# Scope Rails
module R2OAS
  module Schema
    module V3
      module Components
        class ObjectAnalyzer < BaseAnalyzer
          def initialize(before_schema_data, after_schema_data, options = {})
            super(before_schema_data, after_schema_data, options.except(:middle_category))
            @major_category = 'components'
            @middle_category = options[:middle_category]
          end

          def analyze_docs
            diff_manager = ComponentsDiffManager.new(@before_schema_data, @after_schema_data, middle_category: @middle_category)
            diff_manager.process_by_using_diff_data do |schema_name, is_removed, is_added, is_leftovers, after_edited_data|
              file_manager = ComponentsFileManager.build("#/#{@major_category}/#{@middle_category}/#{schema_name}", :ref)
              save_file_path = file_manager.save_file_path(type: :relative)

              if is_removed && !is_added && !is_leftovers
                file_manager.delete
                logger.info "  Delete schema file: \t#{save_file_path}"
              else
                file_manager.save(after_edited_data.to_yaml)
                logger.info "  Write schema file: \t#{save_file_path}"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
r2-oas-0.5.0 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.4.1 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.4.0 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.3.4 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.3.3 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.3.2 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.3.1 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.3.0 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.2.0 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb
r2-oas-0.1.3 lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb