Sha256: ab2bd83b2c6af3aae02e13007d9f78cec3b16d8270e2afc0cf657ceca5386642

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

require "speek/export/rbs"
require "speek/export/graphql"
require "speek/parser"

ColumnData = Struct.new(:name, :type, :nullable, :option, keyword_init: true)
SchemaData = Struct.new(:table_name, :id_type, :columns, keyword_init: true)

module Speek
  # parse code and generate schema by included modules
  class Application
    include Speek::Export
    include Speek::Parser

    attr_reader :ast

    def initialize(code)
      @ast = RubyVM::AbstractSyntaxTree.parse(code)
    end

    def self.read(filename)
      code = File.read(filename)
      new(code)
    end

    def schema_data
      @schema_data ||= SchemaData.new(table_name:, id_type:, columns:)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
speek-0.1.1 lib/speek/application.rb
speek-0.1.0 lib/speek/application.rb