Sha256: ace8deb2d41e863ab976c7eb30254dd6784abaedec4ccb34a184a6bd0704e588
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
# typed: ignore # frozen_string_literal: true def generate_type(model, model_name, file_name) establish_connection create_database formatter = SorbetRails::ModelRbiFormatter.new(model, Set.new([model_name])) file_path = File.expand_path("../sorbet/rbi/models/acts-as-messageable/#{file_name}.rbi", __dir__) FileUtils.mkdir_p(File.dirname(file_path)) File.write(file_path, formatter.generate_rbi) drop_database end def generate_types_for_active_record_runtime establish_connection create_database dir_path = File.expand_path('../sorbet/rbi/rails-rbi/', __dir__) FileUtils.mkdir_p(dir_path) formatter = SorbetRails::ActiveRecordRbiFormatter.new file_path = File.expand_path('../sorbet/rbi/rails-rbi/active_record_base.rbi', __dir__) File.write(file_path, formatter.generate_active_record_base_rbi) file_path = File.expand_path('../sorbet/rbi/rails-rbi/active_record_relation.rbi', __dir__) File.write(file_path, formatter.generate_active_record_relation_rbi) drop_database end desc 'Generate types for model' task :generate_rbi_for_model do require_relative '../spec/spec_helper' require 'active_support/core_ext/string' require 'sorbet-rails' require 'sorbet-rails/active_record_rbi_formatter' SorbetRails.configure {} # rubocop:disable Lint/EmptyBlock generate_type(ActsAsMessageable::Message, 'ActsAsMessageable::Message', 'message') generate_type(CustomSearchUser, 'CustomSearchUser', 'user') generate_types_for_active_record_runtime end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
acts-as-messageable-1.0.2 | tasks/types.rake |
acts-as-messageable-1.0.1 | tasks/types.rake |
acts-as-messageable-1.0.0 | tasks/types.rake |