tapioca 0.17.4 → 0.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b36e9553bee2459f120edeb6eeaf9a77b25051c352750d17f473445c36d6d4d
4
- data.tar.gz: f4777498dd0ed927e8d27f6f49fd0f01d372f2658bb1f6cd0c17494c436977cb
3
+ metadata.gz: dcd84d6187e59dc5b8e2a824d4e9e82182c242710a030fec89393e2c10f4419c
4
+ data.tar.gz: 4e92febe4971b06ac111faa2a544fc404a3b6f718734ac0c06cec97ee631e24e
5
5
  SHA512:
6
- metadata.gz: 9d1c5fd8a3af303cbeb24593e3f448c43592389cb28d94be69035d8ba84a33c82ca462e8445d55ef13bcde62a32bccf8333fcbc91d546468a2e5070732fb51c9
7
- data.tar.gz: edcc7dc4de8a1975ef2a396ce014137c6f20b796bfa680c8cf5a4e8fba37a04c5127f16bf6965af22993cb2c6e399937972176571e1fcb96efc260a74381f76d
6
+ metadata.gz: b4a8b2f9f6b3b69bd3241d5a0503cbf1866288e9dc92c821d410e031bcd91fcf801e003dd54036a1cd6552708d997f0ffb8c989eb5f033758412dca85c7d358e
7
+ data.tar.gz: 05101b64f9d9dab404aea76bf51c9966626efaf024ac31a07a181cdcc9cc276e6175f1e0824c8e4724b0795c36130adec8509d960b40eba39b97533fa89dba0c
@@ -19,13 +19,15 @@ module RubyLsp
19
19
  when "load_compilers_and_extensions"
20
20
  # Load DSL extensions and compilers ahead of time, so that we don't have to pay the price of invoking
21
21
  # `Gem.find_files` on every execution, which is quite expensive
22
- @loader = ::Tapioca::Loaders::Dsl.new(
23
- tapioca_path: ::Tapioca::TAPIOCA_DIR,
24
- eager_load: false,
25
- app_root: params[:workspace_path],
26
- halt_upon_load_error: false,
27
- )
28
- @loader.load_dsl_extensions_and_compilers
22
+ with_notification_wrapper("load_compilers_and_extensions", "Loading DSL compilers") do
23
+ @loader = ::Tapioca::Loaders::Dsl.new(
24
+ tapioca_path: ::Tapioca::TAPIOCA_DIR,
25
+ eager_load: false,
26
+ app_root: params[:workspace_path],
27
+ halt_upon_load_error: false,
28
+ )
29
+ @loader.load_dsl_extensions_and_compilers
30
+ end
29
31
  when "dsl"
30
32
  fork do
31
33
  with_notification_wrapper("dsl", "Generating DSL RBIs") do
@@ -116,7 +116,7 @@ module Tapioca
116
116
  mod.create_method(
117
117
  "build_#{role}",
118
118
  parameters: [create_rest_param("args", type: "T.untyped")],
119
- return_type: "T.any(#{types.join(", ")})",
119
+ return_type: types.size == 1 ? types.first : "T.any(#{types.join(", ")})",
120
120
  )
121
121
  end
122
122
 
@@ -836,7 +836,15 @@ module Tapioca
836
836
  end
837
837
  end
838
838
  when :ids
839
- create_common_method("ids", return_type: "Array")
839
+ if constant.table_exists?
840
+ primary_key_type = constant.type_for_attribute(constant.primary_key)
841
+ type = Tapioca::Dsl::Helpers::ActiveModelTypeHelper.type_for(primary_key_type)
842
+ type = RBIHelper.as_non_nilable_type(type)
843
+ create_common_method("ids", return_type: "T::Array[#{type}]")
844
+ else
845
+ create_common_method("ids", return_type: "Array")
846
+ end
847
+
840
848
  when :pick, :pluck
841
849
  create_common_method(
842
850
  method_name,
@@ -29,29 +29,33 @@ module Tapioca
29
29
  # # post.rbi
30
30
  # # typed: true
31
31
  # class Post
32
- # sig { returns(T.nilable(::String)) }
33
- # def title; end
32
+ # include SmartPropertiesGeneratedMethods
34
33
  #
35
- # sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
36
- # def title=(title); end
34
+ # module SmartPropertiesGeneratedMethods
35
+ # sig { returns(T.nilable(::String)) }
36
+ # def title; end
37
37
  #
38
- # sig { returns(::String) }
39
- # def description; end
38
+ # sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
39
+ # def title=(title); end
40
40
  #
41
- # sig { params(description: ::String).returns(::String) }
42
- # def description=(description); end
41
+ # sig { returns(::String) }
42
+ # def description; end
43
43
  #
44
- # sig { returns(T.nilable(T::Boolean)) }
45
- # def published?; end
44
+ # sig { params(description: ::String).returns(::String) }
45
+ # def description=(description); end
46
46
  #
47
- # sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
48
- # def published=(published); end
47
+ # sig { returns(T.nilable(T::Boolean)) }
48
+ # def published?; end
49
49
  #
50
- # sig { returns(T.nilable(T::Boolean)) }
51
- # def enabled; end
50
+ # sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
51
+ # def published=(published); end
52
52
  #
53
- # sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
54
- # def enabled=(enabled); end
53
+ # sig { returns(T.nilable(T::Boolean)) }
54
+ # def enabled; end
55
+ #
56
+ # sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
57
+ # def enabled=(enabled); end
58
+ # end
55
59
  # end
56
60
  # ~~~
57
61
  #: [ConstantType = singleton(::SmartProperties)]
@@ -43,7 +43,7 @@ Module.include(T::Sig)
43
43
  # Trigger the source transformation for each Ruby file being loaded.
44
44
  RequireHooks.source_transform(patterns: ["**/*.rb"]) do |path, source|
45
45
  # The source is most likely nil since no `source_transform` hook was triggered before this one.
46
- source ||= File.read(path)
46
+ source ||= File.read(path, encoding: "UTF-8")
47
47
 
48
48
  # For performance reasons, we only rewrite files that use Sorbet.
49
49
  if source =~ /^\s*#\s*typed: (ignore|false|true|strict|strong|__STDLIB_INTERNAL)/
@@ -16,7 +16,7 @@ module T
16
16
  def qualified_name_of(constant)
17
17
  name = NAME_METHOD.bind_call(constant)
18
18
  name = nil if name&.start_with?("#<")
19
- return if name.nil?
19
+ return "::T.untyped" if name.nil?
20
20
 
21
21
  if name.start_with?("::")
22
22
  name
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.17.4"
5
+ VERSION = "0.17.6"
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.17.4
4
+ version: 0.17.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu