Class: RailsOpenapiGen::Parsers::Jbuilder::JbuilderParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-openapi-gen/parsers/jbuilder/jbuilder_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jbuilder_path) ⇒ JbuilderParser

Initializes Jbuilder parser with template path

Parameters:

  • jbuilder_path (String)

    Path to Jbuilder template file



16
17
18
19
20
21
22
23
24
# File 'lib/rails-openapi-gen/parsers/jbuilder/jbuilder_parser.rb', line 16

def initialize(jbuilder_path)
  @jbuilder_path = jbuilder_path
  @properties = []
  @operation_info = nil
  @parsed_files = Set.new
  @operation_parser = nil
  @property_parser = nil
  @ast_parser = nil
end

Instance Attribute Details

#ast_parserObject (readonly)

Returns the value of attribute ast_parser.



12
13
14
# File 'lib/rails-openapi-gen/parsers/jbuilder/jbuilder_parser.rb', line 12

def ast_parser
  @ast_parser
end

#jbuilder_pathObject (readonly)

Returns the value of attribute jbuilder_path.



12
13
14
# File 'lib/rails-openapi-gen/parsers/jbuilder/jbuilder_parser.rb', line 12

def jbuilder_path
  @jbuilder_path
end

Instance Method Details

#parseRailsOpenapiGen::AstNodes::BaseNode Also known as: parse_ast

Main parsing method using AST-based architecture

Returns:



28
29
30
31
32
33
34
# File 'lib/rails-openapi-gen/parsers/jbuilder/jbuilder_parser.rb', line 28

def parse
  @ast_parser = AstParser.new(jbuilder_path)

  return nil unless File.exist?(jbuilder_path)

  @ast_parser.parse
end