tapioca 0.2.6 → 0.2.7
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/README.md +2 -2
- data/lib/tapioca/compilers/symbol_table/symbol_generator.rb +27 -10
- data/lib/tapioca/compilers/symbol_table/symbol_loader.rb +1 -0
- data/lib/tapioca/gemfile.rb +32 -17
- data/lib/tapioca/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a3d27cc18a2cc1afcfd1f9c9cb1e833078ea06b1c4a4900e76614b2b54478b7
|
4
|
+
data.tar.gz: 9b8e0b109fbdc3a7d6393a67df9f53031c8e29aa1479eb0a1fb644783998bc36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5601255b31b7cec6eb03ec8553f03450148de320ef48ab3370f278797d7189c020d1a7a2c04b6ab5b2e509321df4df0fbb022dd9e0ae9477aceaca4a195b620a
|
7
|
+
data.tar.gz: 1b3fcf4e9c997f60199e60e9206d2113e3d1292334d38db0d670ba0e3d5f4f0e8f348c88e74b8c1f8df0524bc9f40c59c1f214273b76259db5d88246610ccc55
|
data/README.md
CHANGED
@@ -85,8 +85,8 @@ This will sync the RBIs with the gems in the Gemfile and will add, update, and r
|
|
85
85
|
- `--prerequire [file]`: A file to be required before `Bundler.require` is called.
|
86
86
|
- `--postrequire [file]`: A file to be required after `Bundler.require` is called.
|
87
87
|
- `--out [directory]`: The output directory for generated RBI files, default to `sorbet/rbi/gems`.
|
88
|
-
- `--
|
89
|
-
- `--
|
88
|
+
- `--generate-command [command]`: The command to run to regenerate RBI files (used in header comment of the RBI files), defaults to the current command.
|
89
|
+
- `--typed-overrides [gem:level]`: Overrides typed sigils for generated gem RBIs for gem `gem` to level `level` (`level` can be one of `ignore`, `false`, `true`, `strict`, or `strong`, see [the Sorbet docs](https://sorbet.org/docs/static#file-level-granularity-strictness-levels) for more details).
|
90
90
|
|
91
91
|
## Contributing
|
92
92
|
|
@@ -74,14 +74,18 @@ module Tapioca
|
|
74
74
|
compile(symbol, constant)
|
75
75
|
end
|
76
76
|
|
77
|
-
sig { params(symbol: String).returns(BasicObject) }
|
77
|
+
sig { params(symbol: String).returns(BasicObject).checked(:never) }
|
78
78
|
def resolve_constant(symbol)
|
79
79
|
Object.const_get(symbol, false)
|
80
80
|
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError
|
81
81
|
nil
|
82
82
|
end
|
83
83
|
|
84
|
-
sig
|
84
|
+
sig do
|
85
|
+
params(name: T.nilable(String), constant: BasicObject)
|
86
|
+
.returns(T.nilable(String))
|
87
|
+
.checked(:never)
|
88
|
+
end
|
85
89
|
def compile(name, constant)
|
86
90
|
return unless constant
|
87
91
|
return unless name
|
@@ -96,7 +100,11 @@ module Tapioca
|
|
96
100
|
compile_constant(name, constant)
|
97
101
|
end
|
98
102
|
|
99
|
-
sig
|
103
|
+
sig do
|
104
|
+
params(name: String, constant: BasicObject)
|
105
|
+
.returns(T.nilable(String))
|
106
|
+
.checked(:never)
|
107
|
+
end
|
100
108
|
def compile_constant(name, constant)
|
101
109
|
case constant
|
102
110
|
when Module
|
@@ -122,12 +130,17 @@ module Tapioca
|
|
122
130
|
indented("#{name} = #{constant_name}")
|
123
131
|
end
|
124
132
|
|
125
|
-
sig
|
133
|
+
sig do
|
134
|
+
params(name: String, value: BasicObject)
|
135
|
+
.returns(T.nilable(String))
|
136
|
+
.checked(:never)
|
137
|
+
end
|
126
138
|
def compile_object(name, value)
|
139
|
+
return if symbol_ignored?(name)
|
127
140
|
indented("#{name} = T.let(T.unsafe(nil), #{type_name_of(value)})")
|
128
141
|
end
|
129
142
|
|
130
|
-
sig { params(value: BasicObject).returns(String) }
|
143
|
+
sig { params(value: BasicObject).returns(String).checked(:never) }
|
131
144
|
def type_name_of(value)
|
132
145
|
klass = class_of(value)
|
133
146
|
|
@@ -528,7 +541,7 @@ module Tapioca
|
|
528
541
|
end
|
529
542
|
end
|
530
543
|
|
531
|
-
sig { params(constant: BasicObject).returns(Class) }
|
544
|
+
sig { params(constant: BasicObject).returns(Class).checked(:never) }
|
532
545
|
def class_of(constant)
|
533
546
|
Kernel.instance_method(:class).bind(constant).call
|
534
547
|
end
|
@@ -543,7 +556,7 @@ module Tapioca
|
|
543
556
|
Module.instance_method(:name).bind(constant).call
|
544
557
|
end
|
545
558
|
|
546
|
-
sig { params(constant: BasicObject).returns(Class) }
|
559
|
+
sig { params(constant: BasicObject).returns(Class).checked(:never) }
|
547
560
|
def singleton_class_of(constant)
|
548
561
|
Object.instance_method(:singleton_class).bind(constant).call
|
549
562
|
end
|
@@ -578,8 +591,12 @@ module Tapioca
|
|
578
591
|
def qualified_name_of(constant)
|
579
592
|
name = name_of(constant)
|
580
593
|
return if name.nil?
|
581
|
-
|
582
|
-
name
|
594
|
+
|
595
|
+
if name.start_with?("::")
|
596
|
+
name
|
597
|
+
else
|
598
|
+
"::#{name}"
|
599
|
+
end
|
583
600
|
end
|
584
601
|
|
585
602
|
sig { params(constant: Class).returns(T.nilable(Class)) }
|
@@ -587,7 +604,7 @@ module Tapioca
|
|
587
604
|
Class.instance_method(:superclass).bind(constant).call
|
588
605
|
end
|
589
606
|
|
590
|
-
sig { params(constant: Module, other: BasicObject).returns(T::Boolean) }
|
607
|
+
sig { params(constant: Module, other: BasicObject).returns(T::Boolean).checked(:never) }
|
591
608
|
def are_equal?(constant, other)
|
592
609
|
BasicObject.instance_method(:equal?).bind(constant).call(other)
|
593
610
|
end
|
data/lib/tapioca/gemfile.rb
CHANGED
@@ -7,7 +7,7 @@ module Tapioca
|
|
7
7
|
class Gemfile
|
8
8
|
extend(T::Sig)
|
9
9
|
|
10
|
-
Spec = T.type_alias
|
10
|
+
Spec = T.type_alias do
|
11
11
|
T.any(
|
12
12
|
T.all(
|
13
13
|
::Bundler::StubSpecification,
|
@@ -15,7 +15,7 @@ module Tapioca
|
|
15
15
|
),
|
16
16
|
::Gem::Specification
|
17
17
|
)
|
18
|
-
|
18
|
+
end
|
19
19
|
|
20
20
|
sig { void }
|
21
21
|
def initialize
|
@@ -33,8 +33,8 @@ module Tapioca
|
|
33
33
|
definition
|
34
34
|
.resolve
|
35
35
|
.materialize(specs)
|
36
|
-
.reject { |spec| ignore_gem_spec?(spec) }
|
37
36
|
.map { |spec| Gem.new(spec) }
|
37
|
+
.reject { |gem| gem.ignore?(dir) }
|
38
38
|
.uniq(&:rbi_file_name)
|
39
39
|
.sort_by(&:rbi_file_name)
|
40
40
|
end
|
@@ -70,32 +70,30 @@ module Tapioca
|
|
70
70
|
@definition ||= Bundler::Dsl.evaluate(gemfile, lockfile, {})
|
71
71
|
end
|
72
72
|
|
73
|
-
IGNORED_GEMS = T.let(%w{
|
74
|
-
sorbet sorbet-static sorbet-runtime tapioca
|
75
|
-
}.freeze, T::Array[String])
|
76
|
-
|
77
|
-
sig { params(spec: Spec).returns(T::Boolean) }
|
78
|
-
def ignore_gem_spec?(spec)
|
79
|
-
IGNORED_GEMS.include?(spec.name) ||
|
80
|
-
spec.full_gem_path.start_with?(gemfile_dir)
|
81
|
-
end
|
82
|
-
|
83
73
|
sig { returns(String) }
|
84
|
-
def
|
74
|
+
def dir
|
85
75
|
File.expand_path(gemfile.path + "/..")
|
86
76
|
end
|
87
77
|
|
88
78
|
class Gem
|
89
79
|
extend(T::Sig)
|
90
80
|
|
81
|
+
IGNORED_GEMS = T.let(%w{
|
82
|
+
sorbet sorbet-static sorbet-runtime tapioca
|
83
|
+
}.freeze, T::Array[String])
|
84
|
+
|
85
|
+
sig { returns(String) }
|
86
|
+
attr_reader :full_gem_path
|
87
|
+
|
91
88
|
sig { params(spec: Spec).void }
|
92
89
|
def initialize(spec)
|
93
90
|
@spec = T.let(spec, Tapioca::Gemfile::Spec)
|
91
|
+
@full_gem_path = T.let(@spec.full_gem_path.to_s, String)
|
94
92
|
end
|
95
93
|
|
96
|
-
sig {
|
97
|
-
def
|
98
|
-
|
94
|
+
sig { params(gemfile_dir: String).returns(T::Boolean) }
|
95
|
+
def ignore?(gemfile_dir)
|
96
|
+
gem_ignored? || gem_in_app_dir?(gemfile_dir)
|
99
97
|
end
|
100
98
|
|
101
99
|
sig { returns(T::Array[Pathname]) }
|
@@ -119,6 +117,23 @@ module Tapioca
|
|
119
117
|
def rbi_file_name
|
120
118
|
"#{name}@#{version}.rbi"
|
121
119
|
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
sig { returns(T::Boolean) }
|
124
|
+
def gem_ignored?
|
125
|
+
IGNORED_GEMS.include?(name)
|
126
|
+
end
|
127
|
+
|
128
|
+
sig { params(gemfile_dir: String).returns(T::Boolean) }
|
129
|
+
def gem_in_app_dir?(gemfile_dir)
|
130
|
+
!gem_in_bundle_path? && full_gem_path.start_with?(gemfile_dir)
|
131
|
+
end
|
132
|
+
|
133
|
+
sig { returns(T::Boolean) }
|
134
|
+
def gem_in_bundle_path?
|
135
|
+
full_gem_path.start_with?(Bundler.bundle_path.to_s)
|
136
|
+
end
|
122
137
|
end
|
123
138
|
end
|
124
139
|
end
|
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.2.
|
4
|
+
version: 0.2.7
|
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-02-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: pry
|