tapioca 0.7.0 → 0.7.1
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 +4 -4
- data/lib/tapioca/commands/todo.rb +4 -2
- data/lib/tapioca/dsl/compiler.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +2 -0
- data/lib/tapioca/dsl/compilers/url_helpers.rb +4 -1
- data/lib/tapioca/dsl/helpers/param_helper.rb +4 -1
- data/lib/tapioca/dsl/pipeline.rb +28 -1
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +1 -1
- data/lib/tapioca/helpers/{rbi_helper.rb → signatures_helper.rb} +1 -1
- data/lib/tapioca/internal.rb +1 -1
- data/lib/tapioca/runtime/generic_type_registry.rb +4 -2
- data/lib/tapioca/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4335f63c05a29d9ccaa0e0499af63ed4473f55532bd0a9aa012bbacf16a26666
|
4
|
+
data.tar.gz: 44edcd5f1de4552dd538a116ecc695d58f38837ad57c3f1979b65b6b649ccd82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f735efb4a5f069fa42fdfc7b7b4e0d62f7a962c816f35ebec0f02341d08984363656d384f91c42f1eecde2bcc574dbda4d4a05095bb367c81ac2b1e2fc7bb65
|
7
|
+
data.tar.gz: 6d76e4cc1e9ec2f725efa9332dc66883609ab8a49d70cd3edb31bda2d892928a0d9a879e18e6d2af94d6effee49ce0bb5ed79b9efa91dc4b4ede7d273de69ef6
|
@@ -74,10 +74,12 @@ module Tapioca
|
|
74
74
|
.each_line
|
75
75
|
.map do |line|
|
76
76
|
next if line.include?("<")
|
77
|
-
|
78
|
-
line.strip
|
77
|
+
|
78
|
+
line.strip
|
79
|
+
.gsub(/T\.class_of\(([:\w]+)\)/, '\1') # Turn T.class_of(Foo)::Bar into Foo::Bar
|
79
80
|
end
|
80
81
|
.compact
|
82
|
+
.sort
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
data/lib/tapioca/dsl/compiler.rb
CHANGED
@@ -54,7 +54,7 @@ module Tapioca
|
|
54
54
|
sig { returns(T::Set[Module]) }
|
55
55
|
def self.processable_constants
|
56
56
|
@processable_constants ||= T.let(
|
57
|
-
Set.new(gather_constants).
|
57
|
+
T::Set[Module].new(gather_constants).compare_by_identity,
|
58
58
|
T.nilable(T::Set[Module])
|
59
59
|
)
|
60
60
|
T.must(@processable_constants)
|
@@ -109,6 +109,8 @@ module Tapioca
|
|
109
109
|
|
110
110
|
sig { override.returns(T::Enumerable[Module]) }
|
111
111
|
def self.gather_constants
|
112
|
+
return [] unless Rails.application
|
113
|
+
|
112
114
|
Object.const_set(:GeneratedUrlHelpersModule, Rails.application.routes.named_routes.url_helpers_module)
|
113
115
|
Object.const_set(:GeneratedPathHelpersModule, Rails.application.routes.named_routes.path_helpers_module)
|
114
116
|
|
@@ -160,7 +162,8 @@ module Tapioca
|
|
160
162
|
superclass_ancestors = ancestors_of(superclass) if superclass
|
161
163
|
end
|
162
164
|
|
163
|
-
(ancestors_of(mod)
|
165
|
+
ancestors = Set.new.compare_by_identity.merge(ancestors_of(mod)).subtract(superclass_ancestors)
|
166
|
+
ancestors.any? { |ancestor| helper == ancestor }
|
164
167
|
end
|
165
168
|
end
|
166
169
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require "tapioca/helpers/signatures_helper"
|
5
|
+
|
4
6
|
module Tapioca
|
5
7
|
module Dsl
|
6
8
|
module Helpers
|
7
9
|
module ParamHelper
|
8
10
|
extend T::Sig
|
11
|
+
include SignaturesHelper
|
9
12
|
|
10
13
|
sig { params(name: String, type: String).returns(RBI::TypedParam) }
|
11
14
|
def create_param(name, type:)
|
@@ -44,7 +47,7 @@ module Tapioca
|
|
44
47
|
|
45
48
|
sig { params(param: RBI::Param, type: String).returns(RBI::TypedParam) }
|
46
49
|
def create_typed_param(param, type)
|
47
|
-
RBI::TypedParam.new(param: param, type: type)
|
50
|
+
RBI::TypedParam.new(param: param, type: sanitize_signature_types(type))
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/tapioca/dsl/pipeline.rb
CHANGED
@@ -53,7 +53,7 @@ module Tapioca
|
|
53
53
|
end
|
54
54
|
def run(&blk)
|
55
55
|
constants_to_process = gather_constants(requested_constants)
|
56
|
-
.select { |c|
|
56
|
+
.select { |c| Module === c } # Filter value constants out
|
57
57
|
.sort_by! { |c| T.must(Runtime::Reflection.name_of(c)) }
|
58
58
|
|
59
59
|
if constants_to_process.empty?
|
@@ -112,10 +112,37 @@ module Tapioca
|
|
112
112
|
sig { params(requested_constants: T::Array[Module]).returns(T::Set[Module]) }
|
113
113
|
def gather_constants(requested_constants)
|
114
114
|
constants = compilers.map(&:processable_constants).reduce(Set.new, :union)
|
115
|
+
constants = filter_anonymous_and_reloaded_constants(constants)
|
116
|
+
|
115
117
|
constants &= requested_constants unless requested_constants.empty?
|
116
118
|
constants
|
117
119
|
end
|
118
120
|
|
121
|
+
sig { params(constants: T::Set[Module]).returns(T::Set[Module]) }
|
122
|
+
def filter_anonymous_and_reloaded_constants(constants)
|
123
|
+
# Group constants by their names
|
124
|
+
constants_by_name = constants
|
125
|
+
.group_by { |c| T.must(Runtime::Reflection.name_of(c)) }
|
126
|
+
.select { |name, _| !name.nil? }
|
127
|
+
|
128
|
+
# Find the constants that have been reloaded
|
129
|
+
reloaded_constants = constants_by_name.select { |_, constants| constants.size > 1 }.keys
|
130
|
+
|
131
|
+
unless reloaded_constants.empty?
|
132
|
+
reloaded_constant_names = reloaded_constants.map { |name| "`#{name}`" }.join(", ")
|
133
|
+
|
134
|
+
$stderr.puts("WARNING: Multiple constants with the same name: #{reloaded_constant_names}")
|
135
|
+
$stderr.puts("Make sure some object is not holding onto these constants during an app reload.")
|
136
|
+
end
|
137
|
+
|
138
|
+
# Look up all the constants back from their names. The resulting constant set will be the
|
139
|
+
# set of constants that are actually in memory with those names.
|
140
|
+
constants_by_name
|
141
|
+
.keys
|
142
|
+
.map { |name| T.cast(Runtime::Reflection.constantize(name), Module) }
|
143
|
+
.to_set
|
144
|
+
end
|
145
|
+
|
119
146
|
sig { params(constant: Module).returns(T.nilable(RBI::File)) }
|
120
147
|
def rbi_for_constant(constant)
|
121
148
|
file = RBI::File.new(strictness: "true")
|
data/lib/tapioca/gem/pipeline.rb
CHANGED
data/lib/tapioca/internal.rb
CHANGED
@@ -11,7 +11,7 @@ require "tapioca/sorbet_ext/fixed_hash_patch"
|
|
11
11
|
require "tapioca/runtime/generic_type_registry"
|
12
12
|
require "tapioca/helpers/cli_helper"
|
13
13
|
require "tapioca/helpers/config_helper"
|
14
|
-
require "tapioca/helpers/
|
14
|
+
require "tapioca/helpers/signatures_helper"
|
15
15
|
require "tapioca/helpers/shims_helper"
|
16
16
|
require "tapioca/helpers/sorbet_helper"
|
17
17
|
require "tapioca/commands"
|
@@ -111,8 +111,10 @@ module Tapioca
|
|
111
111
|
constant.clone
|
112
112
|
end
|
113
113
|
|
114
|
-
# Let's set the `name`
|
115
|
-
|
114
|
+
# Let's set the `name` and `to_s` methods to return the proper generic name
|
115
|
+
name_proc = -> { name }
|
116
|
+
generic_type.define_singleton_method(:name, name_proc)
|
117
|
+
generic_type.define_singleton_method(:to_s, name_proc)
|
116
118
|
|
117
119
|
# We need to define a `<=` method on the cloned constant, so that Sorbet
|
118
120
|
# can do covariance/contravariance checks on the type variables.
|
data/lib/tapioca/version.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.1
|
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: 2022-
|
14
|
+
date: 2022-03-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: 0.0.0
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
53
|
+
version: 0.0.14
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
version: 0.0.0
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.0.
|
63
|
+
version: 0.0.14
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: sorbet-runtime
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,8 +212,8 @@ files:
|
|
212
212
|
- lib/tapioca/gemfile.rb
|
213
213
|
- lib/tapioca/helpers/cli_helper.rb
|
214
214
|
- lib/tapioca/helpers/config_helper.rb
|
215
|
-
- lib/tapioca/helpers/rbi_helper.rb
|
216
215
|
- lib/tapioca/helpers/shims_helper.rb
|
216
|
+
- lib/tapioca/helpers/signatures_helper.rb
|
217
217
|
- lib/tapioca/helpers/sorbet_helper.rb
|
218
218
|
- lib/tapioca/helpers/test/content.rb
|
219
219
|
- lib/tapioca/helpers/test/dsl_compiler.rb
|