class SwaggerDocsGenerator::ParserReadme

# Parse Readme information

Parse block code for display basic information for this API Doc

Public Class Methods

new(readme_file) click to toggle source
# File lib/swagger_docs_generator/parser/readme.rb, line 8
def initialize(readme_file)
  @tag_name = 'README'
  @readme = readme_file
  create_file
end

Public Instance Methods

adding_readme() click to toggle source
# File lib/swagger_docs_generator/parser/readme.rb, line 14
def adding_readme
  json = JSON.parse(File.read(temporary_file))
  File.open(temporary_file, 'w') do |file|
    json['paths'].merge!(complete_path)
    json['tags'].merge!(complete_tag)
    file.puts(JSON.pretty_generate(json))
  end
end

Private Instance Methods

complete_path() click to toggle source
# File lib/swagger_docs_generator/parser/readme.rb, line 25
def complete_path
  {
    @tag_name => {
      get: {
        summary: 'Introduction',
        description: @readme,
        tags: [@tag_name]
      }
    }
  }
end
complete_tag() click to toggle source
# File lib/swagger_docs_generator/parser/readme.rb, line 37
def complete_tag
  {
    name: @tag_name,
    description: 'Display basic information to this API documentation'
  }
end
create_file() click to toggle source
# File lib/swagger_docs_generator/parser/readme.rb, line 44
def create_file
  File.delete(temporary_file) if File.exist?(temporary_file)
  base_file = { paths: {}, tags: {}, definitions: {} }
  File.open(temporary_file, 'a+') { |file| file.puts(base_file.to_json) }
end