class SwaggerDocsGenerator::ParserController
# Parse Controller classes
Parse controller classes in Rails application. It's create temporary file and adding automaticaly tags element.
Public Class Methods
new(description)
click to toggle source
Calls superclass method
# File lib/swagger_docs_generator/parser/controller.rb, line 9 def initialize(description) super(binding.of_callers[1].klass) @description = description prepare_file end
Public Instance Methods
adding_tag()
click to toggle source
# File lib/swagger_docs_generator/parser/controller.rb, line 15 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 Instance Methods
delete_file()
click to toggle source
# File lib/swagger_docs_generator/parser/controller.rb, line 31 def delete_file File.delete(temporary_file) if File.exist?(temporary_file) end
prepare_file()
click to toggle source
# File lib/swagger_docs_generator/parser/controller.rb, line 25 def prepare_file delete_file base_file = { paths: {}, tags: {}, definitions: {} } File.open(temporary_file, 'a+') { |file| file.puts(base_file.to_json) } end