class SwaggerDocsGenerator::Parser

# Parse classes

@abstract Classes for parsing Rails classes

@!attribute [r] controller

It's a name of controller parsed

@!attribute [r] tag_name

It's a tag attaching to controller

Attributes

controller[R]
tag_name[R]

Public Class Methods

new(klass) click to toggle source
# File lib/swagger_docs_generator/parser/parser.rb, line 15
def initialize(klass)
  @controller = klass::CONTROLLER
  @tag_name = defined?(klass::TAG) ? klass::TAG : controller_name
end

Public Instance Methods

temporary_file() click to toggle source
# File lib/swagger_docs_generator/parser/parser.rb, line 20
def temporary_file
  File.join(SwaggerDocsGenerator.temporary_folder, tmp_json)
end

Private Instance Methods

controller_name() click to toggle source
# File lib/swagger_docs_generator/parser/parser.rb, line 26
def controller_name
  @controller.controller_name
end
create_file() click to toggle source
# File lib/swagger_docs_generator/parser/parser.rb, line 34
def create_file
  base_file = { paths: {}, tags: {}, definitions: {} }
  File.open(temporary_file, 'a+') { |file| file.puts(base_file.to_json) }
end
tmp_json() click to toggle source
# File lib/swagger_docs_generator/parser/parser.rb, line 30
def tmp_json
  "#{@tag_name}.json"
end