Sha256: 0bd13f00e3651b746433e2ebdb2060cec5c2787ef73064d6eb2d9917a5b6f4da

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module SwaggerDocsGenerator
  # # 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
  class Parser
    attr_reader :controller, :tag_name

    def initialize(klass)
      @controller = klass::CONTROLLER
      @tag_name = defined?(klass::TAG) ? klass::TAG : controller_name
    end

    def temporary_file
      File.join(SwaggerDocsGenerator.temporary_folder, tmp_json)
    end

    private

    def controller_name
      @controller.controller_name
    end

    def tmp_json
      "#{@tag_name}.json"
    end

    def create_file
      base_file = { paths: {}, tags: {}, definitions: {} }
      File.open(temporary_file, 'a+') { |file| file.puts(base_file.to_json) }
    end
  end
end

require 'swagger_docs_generator/parser/controller'
require 'swagger_docs_generator/parser/action'
require 'swagger_docs_generator/parser/definition'
require 'swagger_docs_generator/parser/readme'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
swagger_docs_generator-0.5.1 lib/swagger_docs_generator/parser/parser.rb
swagger_docs_generator-0.5.0.pre.42 lib/swagger_docs_generator/parser/parser.rb