tapioca 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81caba98bdbde19ffbb78a1860f994a8b5c39a82dcd48832ce0daabcd9f6d77b
|
4
|
+
data.tar.gz: 803fe5c9b0ac3838f984455adf53fd2a470e13a877ea218d80bb74b2c309afbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75c2b49c410a6b9f558470a5ab6b59f464b41e4b03a88344fd8967d06e3b36b8b29669bd92c8103d106e234a91fb4ead51d617a365059342e03542cfe113c497
|
7
|
+
data.tar.gz: 4261f1657b92a65ba119f95e1e9be3211af056fe2ba5a5b225b0d920a2adda1fd7619d9e21bb8e034c3946b4cb931d8ef45beebd3bb429c2c5d8446bce09efa8
|
@@ -177,6 +177,7 @@ module Tapioca
|
|
177
177
|
|
178
178
|
[
|
179
179
|
compile_mixins(constant),
|
180
|
+
compile_mixes_in_class_methods(constant),
|
180
181
|
methods,
|
181
182
|
].select { |b| b != "" }.join("\n\n")
|
182
183
|
end
|
@@ -309,17 +310,61 @@ module Tapioca
|
|
309
310
|
indented("extend(#{qualified_name_of(mod)})")
|
310
311
|
end
|
311
312
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
313
|
+
(prepends + includes + extends).join("\n")
|
314
|
+
end
|
315
|
+
|
316
|
+
sig { params(constant: Module).returns(String) }
|
317
|
+
def compile_mixes_in_class_methods(constant)
|
318
|
+
return "" if constant.is_a?(Class)
|
319
|
+
|
320
|
+
mixins_from_modules = {}
|
321
|
+
|
322
|
+
Class.new do
|
323
|
+
# rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
324
|
+
def method_missing(symbol, *args)
|
325
|
+
end
|
326
|
+
|
327
|
+
define_singleton_method(:include) do |mod|
|
328
|
+
before = singleton_class.ancestors
|
329
|
+
super(mod).tap do
|
330
|
+
mixins_from_modules[mod] = singleton_class.ancestors - before
|
331
|
+
end
|
316
332
|
end
|
317
|
-
|
318
|
-
|
319
|
-
|
333
|
+
|
334
|
+
class << self
|
335
|
+
def method_missing(symbol, *args)
|
336
|
+
end
|
320
337
|
end
|
338
|
+
# rubocop:enable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
339
|
+
end.include(constant)
|
340
|
+
|
341
|
+
all_dynamic_extends = mixins_from_modules.delete(constant)
|
342
|
+
all_dynamic_includes = mixins_from_modules.keys
|
343
|
+
dynamic_extends_from_dynamic_includes = mixins_from_modules.values.flatten
|
344
|
+
dynamic_extends = all_dynamic_extends - dynamic_extends_from_dynamic_includes
|
321
345
|
|
322
|
-
|
346
|
+
result = all_dynamic_includes
|
347
|
+
.select { |mod| (name = name_of(mod)) && !name.start_with?("T::") }
|
348
|
+
.select(&method(:public_module?))
|
349
|
+
.map do |mod|
|
350
|
+
indented("include(#{qualified_name_of(mod)})")
|
351
|
+
end.join("\n")
|
352
|
+
|
353
|
+
mixed_in_module = dynamic_extends.find do |mod|
|
354
|
+
mod != constant && public_module?(mod)
|
355
|
+
end
|
356
|
+
|
357
|
+
return result if mixed_in_module.nil?
|
358
|
+
|
359
|
+
qualified_name = qualified_name_of(mixed_in_module)
|
360
|
+
return result if qualified_name == ""
|
361
|
+
|
362
|
+
[
|
363
|
+
result,
|
364
|
+
indented("mixes_in_class_methods(#{qualified_name})"),
|
365
|
+
].select { |b| b != "" }.join("\n\n")
|
366
|
+
rescue
|
367
|
+
""
|
323
368
|
end
|
324
369
|
|
325
370
|
sig { params(name: String, constant: Module).returns(T.nilable(String)) }
|
@@ -392,9 +437,12 @@ module Tapioca
|
|
392
437
|
parameters = params.map do |(type, name)|
|
393
438
|
name ||= :_
|
394
439
|
|
440
|
+
# Sanitize param names
|
441
|
+
name = name.to_s.gsub(/[^a-zA-Z0-9_]/, '_')
|
442
|
+
|
395
443
|
case type
|
396
444
|
when :req
|
397
|
-
name
|
445
|
+
name
|
398
446
|
when :opt
|
399
447
|
"#{name} = _"
|
400
448
|
when :rest
|
@@ -33,7 +33,7 @@ module Tapioca
|
|
33
33
|
file.write(Array(paths).join("\n"))
|
34
34
|
file.flush
|
35
35
|
|
36
|
-
symbol_table_json_from("@#{file.path}")
|
36
|
+
symbol_table_json_from("@#{file.path.shellescape}")
|
37
37
|
end, T.nilable(String))
|
38
38
|
|
39
39
|
return Set.new if output.nil? || output.empty?
|
@@ -44,7 +44,7 @@ module Tapioca
|
|
44
44
|
|
45
45
|
def ignored_symbols
|
46
46
|
unless @ignored_symbols
|
47
|
-
output = symbol_table_json_from("''", table_type: "symbol-table-full-json")
|
47
|
+
output = symbol_table_json_from("-e ''", table_type: "symbol-table-full-json")
|
48
48
|
json = JSON.parse(output)
|
49
49
|
@ignored_symbols = SymbolTableParser.parse(json)
|
50
50
|
end
|
@@ -55,16 +55,21 @@ module Tapioca
|
|
55
55
|
def symbol_table_json_from(input, table_type: "symbol-table-json")
|
56
56
|
IO.popen(
|
57
57
|
[
|
58
|
-
|
58
|
+
sorbet_path,
|
59
59
|
# We don't want to pick up any sorbet/config files in cwd
|
60
60
|
"--no-config",
|
61
61
|
"--print=#{table_type}",
|
62
62
|
"--quiet",
|
63
63
|
input,
|
64
|
-
].
|
64
|
+
].join(' '),
|
65
65
|
err: "/dev/null"
|
66
66
|
).read
|
67
67
|
end
|
68
|
+
|
69
|
+
sig { returns(String) }
|
70
|
+
def sorbet_path
|
71
|
+
SORBET.to_s.shellescape
|
72
|
+
end
|
68
73
|
end
|
69
74
|
|
70
75
|
class SymbolTableParser
|
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.3.
|
4
|
+
version: 0.3.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: 2020-
|
14
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: pry
|