tapioca 0.16.6 → 0.16.8

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: 5a42a478b0396f43dd9e6505c18ac69ca8c32e6ef00b298e6d6e4a8c12536b17
4
- data.tar.gz: f24ab38ee1d78f1633f7d580ea5be8f93e13c9c6550d11b5d5bc4171d974929b
3
+ metadata.gz: c9011a32f92aa24ce99e2ae84c523d45b390925a30fe43e49c92036c06bbb33d
4
+ data.tar.gz: 46e11aa96fc7cb29053f33d2c4a5bc79760d315801f6ba06296e57703bd6d2e6
5
5
  SHA512:
6
- metadata.gz: f623d3b5e66a081728d9ae4b3dde4c6c976829ffbd6e606a64def2e8aff489c09911396ca72146c901f72a11d432d6c86ae840e278b8d85fd8ee756e97776542
7
- data.tar.gz: e7686bcfed28858bfb8f162ee0bd8a7c9a6cdf286c7227a86032025934b04fa72c29f21c41d7a3c5668edb8aad2d39bf2808a2d98799a7434e94aa9b921c3cf8
6
+ metadata.gz: b6d5161d0b4301d62c544cebe5d923867f2530dceb67864a945000998d4eac78737e3ee5eb5ac213b61a7dc00e5e88e92739dcf2fafff900badffdacc8d49315
7
+ data.tar.gz: 4f8a54219803ed296644fa9e6fb5312ed7dc7ba57c7f9b89b2bb8a6e25a71920834ed5a0d0d905bc8f1fe26dbcd1a1257bb5d6e203d41ee87adc7d44f5726171
data/README.md CHANGED
@@ -180,7 +180,7 @@ Options:
180
180
  [--include-dependencies], [--no-include-dependencies], [--skip-include-dependencies] # Generate RBI files for dependencies of the given gem(s)
181
181
  # Default: false
182
182
  --typed, -t, [--typed-overrides=gem:level [gem:level ...]] # Override for typed sigils for generated gem RBIs
183
- # Default: {"activesupport"=>"false"}
183
+ # Default: {"activesupport" => "false"}
184
184
  [--verify], [--no-verify], [--skip-verify] # Verify RBIs are up-to-date
185
185
  # Default: false
186
186
  [--doc], [--no-doc], [--skip-doc] # Include YARD documentation from sources when generating RBIs. Warning: this might be slow
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.22.1", "< 0.23")
4
+ RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.1", "< 0.24")
5
5
 
6
6
  begin
7
7
  # The Tapioca add-on depends on the Rails add-on to add a runtime component to the runtime server. We can allow the
@@ -45,6 +45,11 @@ module RubyLsp
45
45
  @rails_runner_client = addon.rails_runner_client
46
46
  @outgoing_queue << Notification.window_log_message("Activating Tapioca add-on v#{version}")
47
47
  @rails_runner_client.register_server_addon(File.expand_path("server_addon.rb", __dir__))
48
+ @rails_runner_client.delegate_notification(
49
+ server_addon_name: "Tapioca",
50
+ request_name: "load_compilers_and_extensions",
51
+ workspace_path: @global_state.workspace_path,
52
+ )
48
53
  rescue IncompatibleApiError
49
54
  # The requested version for the Rails add-on no longer matches. We need to upgrade and fix the breaking
50
55
  # changes
@@ -79,7 +84,7 @@ module RubyLsp
79
84
  next if path.end_with?("_test.rb", "_spec.rb")
80
85
  next unless file_updated?(change, path)
81
86
 
82
- entries = T.must(@index).entries_for(path)
87
+ entries = T.must(@index).entries_for(change[:uri])
83
88
  next unless entries
84
89
 
85
90
  entries.filter_map do |entry|
@@ -12,6 +12,15 @@ module RubyLsp
12
12
 
13
13
  def execute(request, params)
14
14
  case request
15
+ when "load_compilers_and_extensions"
16
+ # Load DSL extensions and compilers ahead of time, so that we don't have to pay the price of invoking
17
+ # `Gem.find_files` on every execution, which is quite expensive
18
+ ::Tapioca::Loaders::Dsl.new(
19
+ tapioca_path: ::Tapioca::TAPIOCA_DIR,
20
+ eager_load: false,
21
+ app_root: params[:workspace_path],
22
+ halt_upon_load_error: false,
23
+ ).load_dsl_extensions_and_compilers
15
24
  when "dsl"
16
25
  fork do
17
26
  dsl(params)
@@ -118,12 +118,14 @@ module Tapioca
118
118
 
119
119
  sig { void }
120
120
  def load_application
121
+ # Loaded ahead of time when using the add-on to avoid reloading multiple times
122
+ return if @lsp_addon
123
+
121
124
  Loaders::Dsl.load_application(
122
125
  tapioca_path: @tapioca_path,
123
126
  eager_load: @requested_constants.empty? && @requested_paths.empty?,
124
127
  app_root: @app_root,
125
128
  halt_upon_load_error: @halt_upon_load_error,
126
- lsp_addon: @lsp_addon,
127
129
  )
128
130
  end
129
131
 
@@ -372,7 +372,12 @@ module Tapioca
372
372
  return_type: "T.self_type",
373
373
  )
374
374
 
375
- (CALCULATION_METHODS + [:size]).each do |method_name|
375
+ klass.create_method(
376
+ "size",
377
+ return_type: "Integer",
378
+ )
379
+
380
+ CALCULATION_METHODS.each do |method_name|
376
381
  case method_name
377
382
  when :average, :maximum, :minimum
378
383
  klass.create_method(
@@ -400,9 +405,9 @@ module Tapioca
400
405
  ],
401
406
  return_type: "T::Hash[T.untyped, Integer]",
402
407
  )
403
- when :sum, :size
408
+ when :sum
404
409
  klass.create_method(
405
- method_name.to_s,
410
+ "sum",
406
411
  parameters: [
407
412
  create_opt_param("column_name", type: "T.nilable(T.any(String, Symbol))", default: "nil"),
408
413
  create_block_param("block", type: "T.nilable(T.proc.params(record: T.untyped).returns(T.untyped))"),
@@ -597,7 +602,7 @@ module Tapioca
597
602
  sig.return_type = mod == relation_methods_module ? RelationClassName : AssociationRelationClassName
598
603
  end
599
604
  method.add_sig do |sig|
600
- sig.add_param("blk", "T.proc.params(record: #{constant_name}).returns(T::Boolean)")
605
+ sig.add_param("blk", "T.proc.params(record: #{constant_name}).returns(BasicObject)")
601
606
  sig.return_type = "T::Array[#{constant_name}]"
602
607
  end
603
608
  end
@@ -216,6 +216,11 @@ module Tapioca
216
216
  ActiveRecord::Locking::LockingType === type
217
217
  }
218
218
  as_non_nilable_if_persisted_and_not_nullable("::Integer", column_nullability:)
219
+ when ->(type) {
220
+ defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Enum) &&
221
+ ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Enum === type
222
+ }
223
+ "::String"
219
224
  else
220
225
  as_non_nilable_if_persisted_and_not_nullable(
221
226
  ActiveModelTypeHelper.type_for(column_type),
@@ -15,27 +15,20 @@ module Tapioca
15
15
  eager_load: T::Boolean,
16
16
  app_root: String,
17
17
  halt_upon_load_error: T::Boolean,
18
- lsp_addon: T::Boolean,
19
18
  ).void
20
19
  end
21
20
  def load_application(
22
21
  tapioca_path:,
23
22
  eager_load: true,
24
23
  app_root: ".",
25
- halt_upon_load_error: true,
26
- lsp_addon: false
24
+ halt_upon_load_error: true
27
25
  )
28
- loader = new(
26
+ new(
29
27
  tapioca_path: tapioca_path,
30
28
  eager_load: eager_load,
31
29
  app_root: app_root,
32
30
  halt_upon_load_error: halt_upon_load_error,
33
- )
34
- if lsp_addon
35
- loader.load_dsl_extensions_and_compilers
36
- else
37
- loader.load
38
- end
31
+ ).load
39
32
  end
40
33
  end
41
34
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.16.6"
5
+ VERSION = "0.16.8"
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.16.6
4
+ version: 0.16.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -10,8 +10,22 @@ authors:
10
10
  - Peter Zhu
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2025-01-06 00:00:00.000000000 Z
13
+ date: 2025-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: benchmark
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: bundler
17
31
  requirement: !ruby/object:Gem::Requirement