class R2OAS::Schema::V3::ComponentsCleaner

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method R2OAS::Base::new
# File lib/r2-oas/schema/v3/cleaner/components_cleaner.rb, line 10
def initialize(options = {})
  super
  @components_file_paths = Dir.glob("#{schema_save_dir_path}/components/**/**.yml")
  @security_schemes_paths = Dir.glob("#{schema_save_dir_path}/components/securitySchemes/**/**.yml")
end

Public Instance Methods

clean_docs() click to toggle source
# File lib/r2-oas/schema/v3/cleaner/components_cleaner.rb, line 16
def clean_docs
  logger.info '[Clean OAS file (components)] start'
  super do |file_path|
    logger.info "  Delete schema file: \t#{file_path}"
  end
  logger.info '[Clean OAS file (components)] end'
end

Private Instance Methods

all_file_paths() click to toggle source
# File lib/r2-oas/schema/v3/cleaner/components_cleaner.rb, line 36
def all_file_paths
  (@components_file_paths - @security_schemes_paths).uniq
end
clean_target_files() click to toggle source
# File lib/r2-oas/schema/v3/cleaner/components_cleaner.rb, line 26
def clean_target_files
  used_file_paths = many_paths_file_paths.each_with_object([]) do |unit_paths_path, result|
    file_manager = PathItemFileManager.new(unit_paths_path, :full)
    components_file_paths_at_path = file_manager.descendants_ref_paths
    result.push(*components_file_paths_at_path)
  end.uniq

  all_file_paths - used_file_paths
end