Sha256: 26e9b5e543af569521b8daa0cb9c99b9a876c98a7f4c8accaef26b46bdb397a7
Contents?: true
Size: 993 Bytes
Versions: 15
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module SwaggerDocsGenerator # # Parse Controller classes # # Parse controller classes in Rails application. It's create temporary file # and adding automaticaly tags element. class ParserController < Parser def initialize(description) super(binding.of_callers[1].klass) @description = description prepare_file end def adding_tag json = JSON.parse(File.read(temporary_file)) File.open(temporary_file, 'w') do |file| json['tags'].merge!(construct_tags) file.puts(JSON.pretty_generate(json)) end end private def prepare_file delete_file base_file = { paths: {}, tags: {}, definitions: {} } File.open(temporary_file, 'a+') { |file| file.puts(base_file.to_json) } end def delete_file File.delete(temporary_file) if File.exist?(temporary_file) end def construct_tags { name: tag_name, description: @description } end end end
Version data entries
15 entries across 15 versions & 1 rubygems