tapioca 0.11.16 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tapioca/dsl/compilers/aasm.rb +1 -6
  3. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -5
  4. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -5
  5. data/lib/tapioca/dsl/compilers/action_text.rb +1 -5
  6. data/lib/tapioca/dsl/compilers/active_job.rb +1 -5
  7. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -5
  8. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -5
  9. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -5
  10. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -5
  11. data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -5
  12. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -5
  13. data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -7
  14. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +2 -9
  15. data/lib/tapioca/dsl/compilers/active_record_relations.rb +1 -5
  16. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -5
  17. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -5
  18. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -5
  19. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -7
  20. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -5
  21. data/lib/tapioca/dsl/compilers/active_storage.rb +1 -6
  22. data/lib/tapioca/dsl/compilers/active_support_concern.rb +1 -5
  23. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +6 -16
  24. data/lib/tapioca/dsl/compilers/config.rb +1 -5
  25. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -5
  26. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +2 -6
  27. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +2 -6
  28. data/lib/tapioca/dsl/compilers/identity_cache.rb +7 -16
  29. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -7
  30. data/lib/tapioca/dsl/compilers/kredis.rb +1 -5
  31. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +1 -5
  32. data/lib/tapioca/dsl/compilers/protobuf.rb +1 -5
  33. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -6
  34. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -5
  35. data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -7
  36. data/lib/tapioca/dsl/compilers/state_machines.rb +1 -7
  37. data/lib/tapioca/dsl/compilers/url_helpers.rb +17 -16
  38. data/lib/tapioca/dsl/extensions/active_record.rb +4 -2
  39. data/lib/tapioca/dsl/extensions/frozen_record.rb +6 -2
  40. data/lib/tapioca/dsl/extensions/kredis.rb +6 -2
  41. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +2 -2
  42. data/lib/tapioca/gem/listeners/sorbet_props.rb +2 -1
  43. data/lib/tapioca/gem/pipeline.rb +1 -0
  44. data/lib/tapioca/runtime/reflection.rb +17 -0
  45. data/lib/tapioca/version.rb +1 -1
  46. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38dec6aff4cfc2907111dda6a6ee1411d5ae7bf58f467a7e8a47094a606f7593
4
- data.tar.gz: aa5c4ce427eb9e33513ef4b42f69572030c21be2ea12367abc1755fda0c76202
3
+ metadata.gz: 0a3ddc2c5d6e123488c0c4f2d0aad9a5de62a8145f2c3eb2d6b73de6f814afc0
4
+ data.tar.gz: 908740542e026711e9ee85d46ce3828533f965c302039b645213adc016d74258
5
5
  SHA512:
6
- metadata.gz: 1640eb00441de0826936170a8e40010ab5bf3567329ad64e283d8cad4161a37ff16cf02cea1e41eba50816a6f315af8db69be70b65249b61b015532d86c6da05
7
- data.tar.gz: 410060c7ef464f8fe07b28582cef2a86875fa80ff319051aaea31946cd96ad1e40b07c56165421e99b0d300ea19223a3f20756a520a2cb6bd9c76bf16abca230
6
+ metadata.gz: 0622e47a67918e24c8ec4434892265039b38c0de522b3e2ad1ca156d62b1487317384a7dcc928249c7d5cec62493bee5e36d0cbd2342b97a39011056485d6f30
7
+ data.tar.gz: 3082afd8096436fee4ecf4cb46b3a4232f77e34fa53bfb60b3182d12a7fcb5b3df58fe8ce67d1c8dcfb9b4a68dd859429bb6f0cf65eb8708991dfb2ff018720b
@@ -1,12 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- require "aasm"
7
- rescue LoadError
8
- return
9
- end
4
+ return unless defined?(AASM)
10
5
 
11
6
  module Tapioca
12
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "action_controller"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActionController::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "action_mailer"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActionMailer::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "action_text"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_job"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveJob::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_model"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveModel::Attributes)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_model"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveModel::SecurePassword)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_model"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveModel::Validations)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_constants_helper"
11
7
 
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_column_type_helper"
11
7
  require "tapioca/dsl/helpers/active_record_constants_helper"
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_column_type_helper"
11
7
  require "tapioca/dsl/helpers/active_record_constants_helper"
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- # means ActiveRecord is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(ActiveRecord::Base)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -1,14 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "rails"
6
- require "active_record"
7
- require "active_record/fixtures"
8
- require "active_support/test_case"
9
- rescue LoadError
10
- return
11
- end
4
+ return unless defined?(Rails) && defined?(ActiveSupport::TestCase) && defined?(ActiveRecord::TestFixtures)
12
5
 
13
6
  module Tapioca
14
7
  module Dsl
@@ -62,7 +55,7 @@ module Tapioca
62
55
 
63
56
  sig { override.returns(T::Enumerable[Module]) }
64
57
  def gather_constants
65
- return [] unless Rails.application
58
+ return [] unless defined?(Rails.application) && Rails.application
66
59
 
67
60
  [ActiveSupport::TestCase]
68
61
  end
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_constants_helper"
11
7
 
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_constants_helper"
11
7
 
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_constants_helper"
11
7
 
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveRecord::Base)
9
5
 
10
6
  require "tapioca/dsl/helpers/active_record_constants_helper"
11
7
 
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "activerecord-typedstore"
6
- rescue LoadError
7
- # means ActiveRecord::TypedStore is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(ActiveRecord::Base) && defined?(ActiveRecord::TypedStore)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_resource"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveResource::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,12 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_storage"
6
- require "active_storage/reflection"
7
- rescue LoadError
8
- return
9
- end
4
+ return unless defined?(ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)
10
5
 
11
6
  module Tapioca
12
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_support"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveSupport::Concern)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_support"
6
- # The following is needed due to https://github.com/rails/rails/pull/41610
7
- require "active_support/core_ext/module/delegation"
8
- rescue LoadError
9
- return
10
- end
4
+ return unless defined?(ActiveSupport::CurrentAttributes)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -122,17 +116,13 @@ module Tapioca
122
116
 
123
117
  sig { params(klass: RBI::Scope, method: String, class_method: T::Boolean).void }
124
118
  def generate_method(klass, method, class_method:)
125
- if method.end_with?("=")
126
- parameter = create_param("value", type: "T.untyped")
127
- klass.create_method(
128
- method,
129
- class_method: class_method,
130
- parameters: [parameter],
131
- return_type: "T.untyped",
132
- )
119
+ method_def = if class_method
120
+ constant.method(method)
133
121
  else
134
- klass.create_method(method, class_method: class_method, return_type: "T.untyped")
122
+ constant.instance_method(method)
135
123
  end
124
+
125
+ create_method_from_def(klass, method_def, class_method: class_method)
136
126
  end
137
127
  end
138
128
  end
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "config"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(Config)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "frozen_record"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(FrozenRecord::Base)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,12 +1,8 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- gem("graphql", ">= 1.13")
6
- require "graphql"
7
- rescue LoadError
8
- return
9
- end
4
+ return unless defined?(GraphQL::Schema::InputObject)
5
+ return unless Gem::Requirement.new(">= 1.13").satisfied_by?(Gem::Version.new(GraphQL::VERSION))
10
6
 
11
7
  require "tapioca/dsl/helpers/graphql_type_helper"
12
8
 
@@ -1,12 +1,8 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- gem("graphql", ">= 1.13")
6
- require "graphql"
7
- rescue LoadError
8
- return
9
- end
4
+ return unless defined?(GraphQL::Schema::InputObject)
5
+ return unless Gem::Requirement.new(">= 1.13").satisfied_by?(Gem::Version.new(GraphQL::VERSION))
10
6
 
11
7
  require "tapioca/dsl/helpers/graphql_type_helper"
12
8
 
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "identity_cache"
6
- rescue LoadError
7
- # means IdentityCache is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(ActiveRecord::Base) && defined?(IdentityCache::WithoutPrimaryIndex)
11
5
 
12
6
  require "tapioca/dsl/helpers/active_record_column_type_helper"
13
7
 
@@ -224,7 +218,6 @@ module Tapioca
224
218
  def create_aliased_fetch_by_methods(field, klass)
225
219
  type, _ = Helpers::ActiveRecordColumnTypeHelper.new(constant).type_for(field.alias_name.to_s)
226
220
  multi_type = type.delete_prefix("T.nilable(").delete_suffix(")").delete_prefix("::")
227
- length = field.key_fields.length
228
221
  suffix = field.send(:fetch_method_suffix)
229
222
 
230
223
  parameters = field.key_fields.map do |arg|
@@ -238,14 +231,12 @@ module Tapioca
238
231
  return_type: type,
239
232
  )
240
233
 
241
- if length == 1
242
- klass.create_method(
243
- "fetch_multi_#{suffix}",
244
- class_method: true,
245
- parameters: [create_param("keys", type: "T::Enumerable[T.untyped]")],
246
- return_type: COLLECTION_TYPE.call(multi_type),
247
- )
248
- end
234
+ klass.create_method(
235
+ "fetch_multi_#{suffix}",
236
+ class_method: true,
237
+ parameters: [create_param("keys", type: "T::Enumerable[T.untyped]")],
238
+ return_type: COLLECTION_TYPE.call(multi_type),
239
+ )
249
240
  end
250
241
  end
251
242
  end
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "json_api_client"
6
- rescue LoadError
7
- # means JsonApiClient is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(JsonApiClient::Resource)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "kredis"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(Kredis::Attributes)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "active_support/core_ext/class/attribute"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(ActiveSupport)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "google/protobuf"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(Google::Protobuf)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,12 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "rails/generators"
6
- require "rails/generators/app_base"
7
- rescue LoadError
8
- return
9
- end
4
+ return unless defined?(Rails::Generators::Base)
10
5
 
11
6
  module Tapioca
12
7
  module Dsl
@@ -1,11 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "sidekiq"
6
- rescue LoadError
7
- return
8
- end
4
+ return unless defined?(Sidekiq::Worker)
9
5
 
10
6
  module Tapioca
11
7
  module Dsl
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "smart_properties"
6
- rescue LoadError
7
- # means SmartProperties is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(SmartProperties)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "state_machines"
6
- rescue LoadError
7
- # means StateMachines is not installed,
8
- # so let's not even define the compiler.
9
- return
10
- end
4
+ return unless defined?(StateMachines)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -1,13 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- begin
5
- require "rails"
6
- require "action_controller"
7
- require "action_view"
8
- rescue LoadError
9
- return
10
- end
4
+ return unless defined?(Rails) && defined?(ActionDispatch::Routing)
11
5
 
12
6
  module Tapioca
13
7
  module Dsl
@@ -102,19 +96,11 @@ module Tapioca
102
96
  end
103
97
  end
104
98
 
105
- NON_DISCOVERABLE_INCLUDERS = T.let(
106
- [
107
- ActionDispatch::IntegrationTest,
108
- ActionView::Helpers,
109
- ],
110
- T::Array[Module],
111
- )
112
-
113
99
  class << self
114
100
  extend T::Sig
115
101
  sig { override.returns(T::Enumerable[Module]) }
116
102
  def gather_constants
117
- return [] unless Rails.application
103
+ return [] unless defined?(Rails.application) && Rails.application
118
104
 
119
105
  Object.const_set(:GeneratedUrlHelpersModule, Rails.application.routes.named_routes.url_helpers_module)
120
106
  Object.const_set(:GeneratedPathHelpersModule, Rails.application.routes.named_routes.path_helpers_module)
@@ -131,6 +117,19 @@ module Tapioca
131
117
  constants.concat(NON_DISCOVERABLE_INCLUDERS)
132
118
  end
133
119
 
120
+ sig { returns(T::Array[Module]) }
121
+ def gather_non_discoverable_includers
122
+ [].tap do |includers|
123
+ if defined?(ActionController::TemplateAssertions) && defined?(ActionDispatch::IntegrationTest)
124
+ includers << ActionDispatch::IntegrationTest
125
+ end
126
+
127
+ if defined?(ActionView::Helpers)
128
+ includers << ActionView::Helpers
129
+ end
130
+ end.freeze
131
+ end
132
+
134
133
  sig { params(mod: Module, helper: Module).returns(T::Boolean) }
135
134
  private def includes_helper?(mod, helper)
136
135
  superclass_ancestors = []
@@ -145,6 +144,8 @@ module Tapioca
145
144
  end
146
145
  end
147
146
 
147
+ NON_DISCOVERABLE_INCLUDERS = T.let(gather_non_discoverable_includers, T::Array[Module])
148
+
148
149
  private
149
150
 
150
151
  sig { params(root: RBI::Tree, constant: Module).void }
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  begin
5
- require "active_record"
5
+ require "active_support"
6
6
  rescue LoadError
7
7
  return
8
8
  end
@@ -39,7 +39,9 @@ module Tapioca
39
39
  super
40
40
  end
41
41
 
42
- ::ActiveRecord::Base.singleton_class.prepend(self)
42
+ ::ActiveSupport.on_load(:active_record) do
43
+ ::ActiveRecord::Base.singleton_class.prepend(::Tapioca::Dsl::Compilers::Extensions::ActiveRecord)
44
+ end
43
45
  end
44
46
  end
45
47
  end
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  begin
5
- require "frozen_record"
5
+ require "active_support"
6
6
  rescue LoadError
7
7
  return
8
8
  end
@@ -21,7 +21,11 @@ module Tapioca
21
21
  super
22
22
  end
23
23
 
24
- ::FrozenRecord::Base.singleton_class.prepend(self)
24
+ ::ActiveSupport.on_load(:before_configuration) do
25
+ next unless defined?(::FrozenRecord::Base)
26
+
27
+ ::FrozenRecord::Base.singleton_class.prepend(::Tapioca::Dsl::Compilers::Extensions::FrozenRecord)
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  begin
5
- require "kredis"
5
+ require "active_support"
6
6
  rescue LoadError
7
7
  return
8
8
  end
@@ -106,7 +106,11 @@ module Tapioca
106
106
  @__tapioca_kredis_types[method.to_s] = { type: type, values: values }
107
107
  end
108
108
 
109
- ::Kredis::Attributes::ClassMethods.prepend(self)
109
+ ::ActiveSupport.on_load(:before_configuration) do
110
+ next unless defined?(::Kredis::Attributes::ClassMethods)
111
+
112
+ ::Kredis::Attributes::ClassMethods.prepend(::Tapioca::Dsl::Compilers::Extensions::Kredis)
113
+ end
110
114
  end
111
115
  end
112
116
  end
@@ -26,9 +26,9 @@ module Tapioca
26
26
  end
27
27
 
28
28
  prepare = argument.prepare
29
- prepare_method = if prepare
29
+ prepare_method = if prepare.is_a?(Symbol) || prepare.is_a?(String)
30
30
  if constant.respond_to?(prepare)
31
- constant.method(prepare)
31
+ constant.method(prepare.to_sym)
32
32
  end
33
33
  end
34
34
 
@@ -6,6 +6,7 @@ module Tapioca
6
6
  module Listeners
7
7
  class SorbetProps < Base
8
8
  extend T::Sig
9
+ include RBIHelper
9
10
 
10
11
  private
11
12
 
@@ -17,7 +18,7 @@ module Tapioca
17
18
  return unless T::Props::ClassMethods === constant
18
19
 
19
20
  constant.props.map do |name, prop|
20
- type = prop.fetch(:type_object, "T.untyped").to_s.gsub(".returns(<VOID>)", ".void")
21
+ type = sanitize_signature_types(prop.fetch(:type_object, "T.untyped").to_s)
21
22
 
22
23
  default = prop.key?(:default) || prop.key?(:factory) ? "T.unsafe(nil)" : nil
23
24
  node << if prop.fetch(:immutable, false)
@@ -391,6 +391,7 @@ module Tapioca
391
391
  def skip_alias?(name, constant)
392
392
  return true if symbol_in_payload?(name)
393
393
  return true unless constant_in_gem?(name)
394
+ return true if has_aliased_namespace?(name)
394
395
 
395
396
  false
396
397
  end
@@ -255,6 +255,23 @@ module Tapioca
255
255
  def method_defined_by_forwardable_module?(method)
256
256
  method.source_location&.first == Object.const_source_location(:Forwardable)&.first
257
257
  end
258
+
259
+ sig { params(name: String).returns(T::Boolean) }
260
+ def has_aliased_namespace?(name)
261
+ name_parts = name.split("::")
262
+ name_parts.pop # drop the constant name, leaving just the namespace
263
+
264
+ name_parts.each_with_object([]) do |name_part, namespaces|
265
+ namespaces << "#{namespaces.last}::#{name_part}".delete_prefix("::")
266
+ end.any? do |namespace|
267
+ constant = constantize(namespace)
268
+ next unless Module === constant
269
+
270
+ # If the constant name doesn't match the namespace,
271
+ # the namespace must contain an alias
272
+ name_of(constant) != namespace
273
+ end
274
+ end
258
275
  end
259
276
  end
260
277
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.11.16"
5
+ VERSION = "0.12.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.16
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2024-01-12 00:00:00.000000000 Z
14
+ date: 2024-01-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.5.4
296
+ rubygems_version: 3.5.5
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: A Ruby Interface file generator for gems, core types and the Ruby standard