Skip to content

Generating definitions for custom ruby app configuration #1001

@johnernaut

Description

@johnernaut

Hello,

I have a custom Ruby app that I'd like to generate RBI files for. I do use active record and an app/models directory structure, but I'm handling loading myself in what's most likely a non-standard way, so I don't think that tapioca is able to find the files within my structure to create RBI definitions for them. My folder structure looks roughly like the following:

├── Gemfile
├── Gemfile.lock
├── app
│   ├── models
│   ├── services
│   └── workers
├── bin
│   ├── server
│   └── tapioca
├── config
│   ├── environment.rb
│   ├── initializers
├── db
│   ├── migrate
│   ├── seeds.rb
├── sorbet
│   ├── config
│   ├── rbi
│   └── tapioca

I updated my sorbet/tapioca/require.rb file to attempt to require each file in my app/models folder individually so tapioca could find them, but that doesn't generate any definitions for them (there are no errors or warnings either):

app_root = File.expand_path("../..", File.dirname(__FILE__))

require "active_record"
# require ...other things ...

Dir[File.expand_path "#{app_root}/app/models/**/*.rb"].sort.each do |file|
  require file
end

Dir[File.expand_path "#{app_root}/app/services/**/*.rb"].sort.each do |file|
  require file
end

Dir[File.expand_path "#{app_root}/app/workers/**/*.rb"].sort.each do |file|
  require file
end

I was wondering if you all had any ideas as to how I might generate those definitions based on the above. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions