class R2OAS::Schema::V3::BaseAnalyzer
Attributes
existing_schema_file_path[RW]
type[RW]
Public Class Methods
new(before_schema_data, after_schema_data, options = {})
click to toggle source
Calls superclass method
R2OAS::Base::new
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 12 def initialize(before_schema_data, after_schema_data, options = {}) super(options) @type = options[:type].presence @before_schema_data = before_schema_data @after_schema_data = after_schema_data.presence || create_after_schema_data end
Public Instance Methods
analyze_docs()
click to toggle source
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 19 def analyze_docs raise NoImplementError, 'Please implement in inherited class.' end
generate_from_existing_schema()
click to toggle source
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 23 def generate_from_existing_schema raise NoImplementError, 'Please implement in inherited class.' end
Private Instance Methods
create_after_schema_data()
click to toggle source
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 32 def create_after_schema_data case @type when :edited {} when :existing if existing_schema_file_path.present? create_after_schema_data_when_specify_path else create_after_schema_data_when_not_specify_path end end end
create_after_schema_data_when_not_specify_path()
click to toggle source
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 45 def create_after_schema_data_when_not_specify_path if FileTest.exists?(doc_save_file_path) YAML.load_file(doc_save_file_path) else raise NoFileExistsError, "Do not exists file: #{doc_save_file_path}" end end
create_after_schema_data_when_specify_path()
click to toggle source
# File lib/r2-oas/schema/v3/analyzer/base_analyzer.rb, line 53 def create_after_schema_data_when_specify_path extname = File.extname(existing_schema_file_path) case extname when /json/ File.open(existing_schema_file_path) do |file| JSON.parse(file.read) end when /yaml/ YAML.load_file(existing_schema_file_path) when /yml/ YAML.load_file(existing_schema_file_path) else raise NoImplementError, "Do not support extension: #{extname}" end end