Sha256: 2aeaf2b25011d1dba5cae21ad44fec8ad0df9f2bb9d6acb2da4af99f9ef7eff7

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

module Ryakuzu
  class SchemaService
    include Ryakuzu::SchemaExtenstions

    def initialize
      @file        = File.open(Rails.root.join('db', 'schema.rb'))
      @schema_hash = Ryakuzu::Ripper.parse(file)
    end

    def call
      schema_hash.each_with_object([]) { |schema, klass| klass << Ryakuzu::Table.generate_models(schema[0], schema[1]) }
    end

    def schema_to_csv
      CSV.open('schema.csv', 'wb') { |csv| schema_hash.to_a.map { |elem| csv << elem } }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ryakuzu-0.3.0 lib/ryakuzu/schema_parsing/schema_service.rb