tapioca 0.17.6 → 0.17.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 +4 -4
- data/exe/tapioca +6 -1
- data/lib/ruby_lsp/tapioca/addon.rb +1 -1
- data/lib/ruby_lsp/tapioca/server_addon.rb +4 -4
- data/lib/tapioca/cli.rb +2 -1
- data/lib/tapioca/commands/abstract_dsl.rb +2 -2
- data/lib/tapioca/commands/abstract_gem.rb +7 -4
- data/lib/tapioca/commands/annotations.rb +6 -5
- data/lib/tapioca/commands/check_shims.rb +2 -2
- data/lib/tapioca/commands/gem_generate.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +14 -6
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +8 -3
- data/lib/tapioca/dsl/pipeline.rb +2 -2
- data/lib/tapioca/gem/listeners/mixins.rb +7 -1
- data/lib/tapioca/gem/listeners/yard_doc.rb +2 -2
- data/lib/tapioca/gem_info.rb +1 -1
- data/lib/tapioca/helpers/config_helper.rb +1 -1
- data/lib/tapioca/helpers/rbi_files_helper.rb +1 -1
- data/lib/tapioca/loaders/gem.rb +9 -2
- data/lib/tapioca/runtime/trackers/autoload.rb +1 -21
- data/lib/tapioca/runtime/trackers/method_definition.rb +2 -2
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +21 -0
- 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: 489bd75ab0b8322c633ee51dbdb7f0bf4701fbca5cf64401c418d8a7fb454418
|
|
4
|
+
data.tar.gz: 62e4137c4fb603186d93b2f470148f5a8b7baa73bcfb6ed8b000a519dc1f106a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef5107149d789dda2d5c426a14b611ab1062f8aaa919ec179805c95bf7ad7d22eaae368ac9e0ed86b61cfac38b5bbbfc2fa65fa262837ce22ff4ee054b5cbf31
|
|
7
|
+
data.tar.gz: e568320ce79f3e9afa07d1ea1fc58aa7aef422f782b77c4b93707016b680bd2e3c2c971b136016dbf754ed82199e461178467195166f2c7738dec40632ac5de1
|
data/exe/tapioca
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.10", "< 0.
|
|
4
|
+
RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.10", "< 0.27")
|
|
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
|
|
@@ -20,6 +20,7 @@ module RubyLsp
|
|
|
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
22
|
with_notification_wrapper("load_compilers_and_extensions", "Loading DSL compilers") do
|
|
23
|
+
::Tapioca::Dsl::Compiler.extend(T::Generic)
|
|
23
24
|
@loader = ::Tapioca::Loaders::Dsl.new(
|
|
24
25
|
tapioca_path: ::Tapioca::TAPIOCA_DIR,
|
|
25
26
|
eager_load: false,
|
|
@@ -38,14 +39,14 @@ module RubyLsp
|
|
|
38
39
|
fork do
|
|
39
40
|
with_notification_wrapper("route_dsl", "Generating route DSL RBIs") do
|
|
40
41
|
constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
|
|
41
|
-
dsl(constants.map(&:name)
|
|
42
|
+
dsl(constants.map(&:name))
|
|
42
43
|
end
|
|
43
44
|
end
|
|
44
45
|
when "fixtures_dsl"
|
|
45
46
|
fork do
|
|
46
47
|
with_notification_wrapper("fixture_dsl", "Generating fixture DSL RBIs") do
|
|
47
48
|
constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
|
|
48
|
-
dsl(constants.map(&:name)
|
|
49
|
+
dsl(constants.map(&:name))
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
end
|
|
@@ -59,7 +60,7 @@ module RubyLsp
|
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
|
|
62
|
-
def dsl(constants
|
|
63
|
+
def dsl(constants)
|
|
63
64
|
load("tapioca/cli.rb") # Reload the CLI to reset thor defaults between requests
|
|
64
65
|
|
|
65
66
|
::Tapioca::Cli.addon_mode!
|
|
@@ -67,7 +68,6 @@ module RubyLsp
|
|
|
67
68
|
# Order here is important to avoid having Thor confuse arguments. Do not put an array argument at the end before
|
|
68
69
|
# the list of constants
|
|
69
70
|
arguments = ["dsl"]
|
|
70
|
-
arguments.concat(args)
|
|
71
71
|
arguments.push("--workers=1")
|
|
72
72
|
arguments.concat(constants)
|
|
73
73
|
|
data/lib/tapioca/cli.rb
CHANGED
|
@@ -301,6 +301,7 @@ module Tapioca
|
|
|
301
301
|
rbi_formatter: rbi_formatter(options),
|
|
302
302
|
halt_upon_load_error: options[:halt_upon_load_error],
|
|
303
303
|
lsp_addon: options[:lsp_addon],
|
|
304
|
+
verbose: options[:verbose],
|
|
304
305
|
}
|
|
305
306
|
|
|
306
307
|
command = if verify
|
|
@@ -353,7 +354,7 @@ module Tapioca
|
|
|
353
354
|
default: {}
|
|
354
355
|
def annotations
|
|
355
356
|
if !options[:netrc] && options[:netrc_file]
|
|
356
|
-
raise
|
|
357
|
+
raise Tapioca::Error, set_color("Options `--no-netrc` and `--netrc-file` can't be used together", :bold, :red)
|
|
357
358
|
end
|
|
358
359
|
|
|
359
360
|
command = Commands::Annotations.new(
|
|
@@ -160,7 +160,7 @@ module Tapioca
|
|
|
160
160
|
remove_file(filename) if File.file?(filename)
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
raise
|
|
163
|
+
raise Tapioca::Error, ""
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
processable_constants
|
|
@@ -295,7 +295,7 @@ module Tapioca
|
|
|
295
295
|
build_error_for_files(cause, diff_for_cause.map(&:first))
|
|
296
296
|
end.join("\n")
|
|
297
297
|
|
|
298
|
-
raise
|
|
298
|
+
raise Tapioca::Error, <<~ERROR
|
|
299
299
|
#{set_color("RBI files are out-of-date. In your development environment, please run:", :green)}
|
|
300
300
|
#{set_color("`#{default_command(command)}`", :green, :bold)}
|
|
301
301
|
#{set_color("Once it is complete, be sure to commit and push any changes", :green)}
|
|
@@ -8,7 +8,7 @@ module Tapioca
|
|
|
8
8
|
include SorbetHelper
|
|
9
9
|
include RBIFilesHelper
|
|
10
10
|
|
|
11
|
-
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?) -> void
|
|
11
|
+
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?, ?verbose: bool?) -> void
|
|
12
12
|
def initialize(
|
|
13
13
|
gem_names:,
|
|
14
14
|
exclude:,
|
|
@@ -26,7 +26,8 @@ module Tapioca
|
|
|
26
26
|
dsl_dir: DEFAULT_DSL_DIR,
|
|
27
27
|
rbi_formatter: DEFAULT_RBI_FORMATTER,
|
|
28
28
|
halt_upon_load_error: true,
|
|
29
|
-
lsp_addon: false
|
|
29
|
+
lsp_addon: false,
|
|
30
|
+
verbose: false
|
|
30
31
|
)
|
|
31
32
|
@gem_names = gem_names
|
|
32
33
|
@exclude = exclude
|
|
@@ -41,6 +42,7 @@ module Tapioca
|
|
|
41
42
|
@dsl_dir = dsl_dir
|
|
42
43
|
@rbi_formatter = rbi_formatter
|
|
43
44
|
@lsp_addon = lsp_addon
|
|
45
|
+
@verbose = verbose
|
|
44
46
|
|
|
45
47
|
super()
|
|
46
48
|
|
|
@@ -58,6 +60,7 @@ module Tapioca
|
|
|
58
60
|
#: (Gemfile::GemSpec gem) -> void
|
|
59
61
|
def compile_gem_rbi(gem)
|
|
60
62
|
gem_name = set_color(gem.name, :yellow, :bold)
|
|
63
|
+
say("Currently compiling #{gem_name}", :cyan) if @verbose
|
|
61
64
|
|
|
62
65
|
rbi = RBI::File.new(strictness: @typed_overrides[gem.name] || "true")
|
|
63
66
|
|
|
@@ -67,7 +70,7 @@ module Tapioca
|
|
|
67
70
|
reason: "types exported from the `#{gem.name}` gem",
|
|
68
71
|
) if @file_header
|
|
69
72
|
|
|
70
|
-
rbi.root =
|
|
73
|
+
rbi.root = Tapioca.with_disabled_exits do
|
|
71
74
|
Tapioca::Gem::Pipeline.new(
|
|
72
75
|
gem,
|
|
73
76
|
include_doc: @include_doc,
|
|
@@ -201,7 +204,7 @@ module Tapioca
|
|
|
201
204
|
build_error_for_files(cause, diff_for_cause.map(&:first))
|
|
202
205
|
end.join("\n")
|
|
203
206
|
|
|
204
|
-
raise
|
|
207
|
+
raise Tapioca::Error, <<~ERROR
|
|
205
208
|
#{set_color("RBI files are out-of-date. In your development environment, please run:", :green)}
|
|
206
209
|
#{set_color("`#{default_command(command)}`", :green, :bold)}
|
|
207
210
|
#{set_color("Once it is complete, be sure to commit and push any changes", :green)}
|
|
@@ -41,10 +41,11 @@ module Tapioca
|
|
|
41
41
|
|
|
42
42
|
#: -> Array[GemInfo]
|
|
43
43
|
def list_gemfile_gems
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
lockfile_path = Bundler.definition.lockfile.basename
|
|
45
|
+
say("Listing gems from #{lockfile_path}... ", [:blue, :bold])
|
|
46
|
+
|
|
47
|
+
specs = Bundler.definition.specs
|
|
48
|
+
gem_info = specs.map { |spec| GemInfo.from_spec(spec) }
|
|
48
49
|
say("Done", :green)
|
|
49
50
|
gem_info
|
|
50
51
|
end
|
|
@@ -85,7 +86,7 @@ module Tapioca
|
|
|
85
86
|
end
|
|
86
87
|
|
|
87
88
|
if indexes.empty?
|
|
88
|
-
raise
|
|
89
|
+
raise Tapioca::Error, set_color("Can't fetch annotations without sources (no index fetched)", :bold, :red)
|
|
89
90
|
end
|
|
90
91
|
|
|
91
92
|
indexes
|
|
@@ -49,7 +49,7 @@ module Tapioca
|
|
|
49
49
|
result = sorbet("--no-config --print=payload-sources:#{payload_path}")
|
|
50
50
|
|
|
51
51
|
unless result.status
|
|
52
|
-
raise
|
|
52
|
+
raise Tapioca::Error, <<~ERROR
|
|
53
53
|
"Sorbet failed to dump payload"
|
|
54
54
|
#{result.err}
|
|
55
55
|
ERROR
|
|
@@ -87,7 +87,7 @@ module Tapioca
|
|
|
87
87
|
"\nPlease remove the duplicated definitions from #{@shim_rbi_dir} and #{@todo_rbi_file}", :red
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
-
raise
|
|
90
|
+
raise Tapioca::Error, messages.join("\n")
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
say("\nNo duplicates found in shim RBIs", :green)
|
|
@@ -58,7 +58,7 @@ module Tapioca
|
|
|
58
58
|
if gem.nil?
|
|
59
59
|
next if @lsp_addon
|
|
60
60
|
|
|
61
|
-
raise
|
|
61
|
+
raise Tapioca::Error, set_color("Error: Cannot find gem '#{gem_name}'", :red)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
gems.concat(gem_dependencies(gem)) if @include_dependencies
|
|
@@ -26,12 +26,16 @@ module Tapioca
|
|
|
26
26
|
# # typed: true
|
|
27
27
|
#
|
|
28
28
|
# class Shop
|
|
29
|
+
# include GeneratedAttributeMethods
|
|
29
30
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
31
|
+
# module GeneratedAttributeMethods
|
|
32
|
+
# sig { returns(T.nilable(::String)) }
|
|
33
|
+
# def name; end
|
|
34
|
+
#
|
|
35
|
+
# sig { params(name: T.nilable(::String)).returns(T.nilable(::String)) }
|
|
36
|
+
# def name=(name); end
|
|
37
|
+
# end
|
|
32
38
|
#
|
|
33
|
-
# sig { params(name: T.nilable(::String)).returns(T.nilable(::String)) }
|
|
34
|
-
# def name=(name); end
|
|
35
39
|
# end
|
|
36
40
|
# ~~~
|
|
37
41
|
#: [ConstantType = (Class[::ActiveModel::Attributes] & ::ActiveModel::Attributes::ClassMethods)]
|
|
@@ -45,9 +49,13 @@ module Tapioca
|
|
|
45
49
|
return if attribute_methods.empty?
|
|
46
50
|
|
|
47
51
|
root.create_path(constant) do |klass|
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
klass.create_module("GeneratedAttributeMethods") do |mod|
|
|
53
|
+
attribute_methods.each do |method, attribute_type|
|
|
54
|
+
generate_method(mod, method, attribute_type)
|
|
55
|
+
end
|
|
50
56
|
end
|
|
57
|
+
|
|
58
|
+
klass.create_include("GeneratedAttributeMethods")
|
|
51
59
|
end
|
|
52
60
|
end
|
|
53
61
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
return unless defined?(ActiveRecord::Base)
|
|
5
5
|
|
|
6
6
|
require "tapioca/dsl/helpers/active_model_type_helper"
|
|
7
|
+
require "tapioca/dsl/helpers/active_record_column_type_helper"
|
|
7
8
|
require "tapioca/dsl/helpers/active_record_constants_helper"
|
|
8
9
|
|
|
9
10
|
module Tapioca
|
|
@@ -837,9 +838,13 @@ module Tapioca
|
|
|
837
838
|
end
|
|
838
839
|
when :ids
|
|
839
840
|
if constant.table_exists?
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
841
|
+
column_type_helper = Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper.new(
|
|
842
|
+
constant,
|
|
843
|
+
column_type_option: Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper::ColumnTypeOption::Persisted,
|
|
844
|
+
)
|
|
845
|
+
primary_key = constant.primary_key
|
|
846
|
+
getter_type, _setter_type = column_type_helper.type_for(primary_key)
|
|
847
|
+
type = getter_type
|
|
843
848
|
create_common_method("ids", return_type: "T::Array[#{type}]")
|
|
844
849
|
else
|
|
845
850
|
create_common_method("ids", return_type: "Array")
|
data/lib/tapioca/dsl/pipeline.rb
CHANGED
|
@@ -60,7 +60,7 @@ module Tapioca
|
|
|
60
60
|
No classes/modules can be matched for RBI generation.
|
|
61
61
|
Please check that the requested classes/modules include processable DSL methods.
|
|
62
62
|
ERROR
|
|
63
|
-
raise
|
|
63
|
+
raise Tapioca::Error, ""
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
if defined?(::ActiveRecord::Base) && constants_to_process.any? { |c| ::ActiveRecord::Base > c }
|
|
@@ -82,7 +82,7 @@ module Tapioca
|
|
|
82
82
|
report_error(msg)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
raise
|
|
85
|
+
raise Tapioca::Error, ""
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
result.compact
|
|
@@ -98,7 +98,13 @@ module Tapioca
|
|
|
98
98
|
# inherited ancestors, past the location of the constant itself.
|
|
99
99
|
ancestors = Set.new.compare_by_identity.merge(ancestors_of(constant))
|
|
100
100
|
|
|
101
|
-
(ancestors - inherited_ancestors).to_a
|
|
101
|
+
result = (ancestors - inherited_ancestors).to_a
|
|
102
|
+
|
|
103
|
+
# Filter out Kernel for modules (but not classes) since modules shouldn't
|
|
104
|
+
# need to explicitly include Kernel in RBIs
|
|
105
|
+
result.delete(Kernel) unless Class === constant
|
|
106
|
+
|
|
107
|
+
result
|
|
102
108
|
end
|
|
103
109
|
end
|
|
104
110
|
end
|
|
@@ -32,7 +32,7 @@ module Tapioca
|
|
|
32
32
|
|
|
33
33
|
#: (String line) -> bool
|
|
34
34
|
def rbs_comment?(line)
|
|
35
|
-
line.
|
|
35
|
+
line.start_with?(": ", "| ")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# @override
|
|
@@ -74,7 +74,7 @@ module Tapioca
|
|
|
74
74
|
|
|
75
75
|
comments << RBI::Comment.new("") if comments.any? && tags.any?
|
|
76
76
|
|
|
77
|
-
tags.sort_by
|
|
77
|
+
tags.sort_by { |tag| [tag.tag_name, tag.name.to_s] }.each do |tag|
|
|
78
78
|
line = +"@#{tag.tag_name}"
|
|
79
79
|
|
|
80
80
|
tag_name = tag.name
|
data/lib/tapioca/gem_info.rb
CHANGED
|
@@ -128,7 +128,7 @@ module Tapioca
|
|
|
128
128
|
update_gem_rbis_strictnesses(redef_errors, gem_dir)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
Kernel.raise
|
|
131
|
+
Kernel.raise Tapioca::Error, error_messages.join("\n") if parse_errors.any?
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
private
|
data/lib/tapioca/loaders/gem.rb
CHANGED
|
@@ -44,13 +44,20 @@ module Tapioca
|
|
|
44
44
|
#: -> void
|
|
45
45
|
def require_gem_file
|
|
46
46
|
say("Requiring all gems to prepare for compiling... ")
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
bundle_loaded = true #: bool
|
|
49
|
+
|
|
50
|
+
Tapioca.with_disabled_exits do
|
|
48
51
|
load_bundle(@bundle, @prerequire, @postrequire, @halt_upon_load_error)
|
|
49
52
|
rescue LoadError => e
|
|
53
|
+
bundle_loaded = false
|
|
50
54
|
explain_failed_require(@postrequire, e)
|
|
51
|
-
exit(1)
|
|
52
55
|
end
|
|
53
56
|
|
|
57
|
+
# Can't call exit in the rescue block above, since it will be disabled,
|
|
58
|
+
# so we check the flag after the block.
|
|
59
|
+
exit(1) unless bundle_loaded
|
|
60
|
+
|
|
54
61
|
Runtime::Trackers::Autoload.eager_load_all!
|
|
55
62
|
|
|
56
63
|
say(" Done", :green)
|
|
@@ -8,8 +8,6 @@ module Tapioca
|
|
|
8
8
|
extend Tracker
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
11
|
-
NOOP_METHOD = ->(*_args, **_kwargs, &_block) {}
|
|
12
|
-
|
|
13
11
|
@constant_names_registered_for_autoload = [] #: Array[String]
|
|
14
12
|
|
|
15
13
|
class << self
|
|
@@ -17,7 +15,7 @@ module Tapioca
|
|
|
17
15
|
|
|
18
16
|
#: -> void
|
|
19
17
|
def eager_load_all!
|
|
20
|
-
with_disabled_exits do
|
|
18
|
+
Tapioca.with_disabled_exits do
|
|
21
19
|
until @constant_names_registered_for_autoload.empty?
|
|
22
20
|
# Grab the next constant name
|
|
23
21
|
constant_name = T.must(@constant_names_registered_for_autoload.shift)
|
|
@@ -33,24 +31,6 @@ module Tapioca
|
|
|
33
31
|
|
|
34
32
|
@constant_names_registered_for_autoload << constant_name
|
|
35
33
|
end
|
|
36
|
-
|
|
37
|
-
#: [Result] { -> Result } -> Result
|
|
38
|
-
def with_disabled_exits(&block)
|
|
39
|
-
original_abort = Kernel.instance_method(:abort)
|
|
40
|
-
original_exit = Kernel.instance_method(:exit)
|
|
41
|
-
|
|
42
|
-
begin
|
|
43
|
-
Kernel.define_method(:abort, NOOP_METHOD)
|
|
44
|
-
Kernel.define_method(:exit, NOOP_METHOD)
|
|
45
|
-
|
|
46
|
-
Tapioca.silence_warnings do
|
|
47
|
-
block.call
|
|
48
|
-
end
|
|
49
|
-
ensure
|
|
50
|
-
Kernel.define_method(:exit, original_exit)
|
|
51
|
-
Kernel.define_method(:abort, original_abort)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
34
|
end
|
|
55
35
|
end
|
|
56
36
|
end
|
|
@@ -53,12 +53,12 @@ end
|
|
|
53
53
|
class Module
|
|
54
54
|
prepend(Module.new do
|
|
55
55
|
def singleton_method_added(method_name)
|
|
56
|
-
Tapioca::Runtime::Trackers::MethodDefinition.register(method_name, singleton_class, caller_locations)
|
|
56
|
+
Tapioca::Runtime::Trackers::MethodDefinition.register(method_name, singleton_class, Kernel.caller_locations)
|
|
57
57
|
super
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def method_added(method_name)
|
|
61
|
-
Tapioca::Runtime::Trackers::MethodDefinition.register(method_name, self, caller_locations)
|
|
61
|
+
Tapioca::Runtime::Trackers::MethodDefinition.register(method_name, self, Kernel.caller_locations)
|
|
62
62
|
super
|
|
63
63
|
end
|
|
64
64
|
end)
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
|
@@ -9,6 +9,9 @@ module Tapioca
|
|
|
9
9
|
|
|
10
10
|
@traces = [] #: Array[TracePoint]
|
|
11
11
|
|
|
12
|
+
NOOP_METHOD = ->(*_args, **_kwargs, &_block) {} #: ^() -> void
|
|
13
|
+
private_constant :NOOP_METHOD
|
|
14
|
+
|
|
12
15
|
class << self
|
|
13
16
|
extend T::Sig
|
|
14
17
|
|
|
@@ -22,6 +25,24 @@ module Tapioca
|
|
|
22
25
|
ensure
|
|
23
26
|
$VERBOSE = original_verbosity
|
|
24
27
|
end
|
|
28
|
+
|
|
29
|
+
#: [Result] { -> Result } -> Result
|
|
30
|
+
def with_disabled_exits(&block)
|
|
31
|
+
original_abort = Kernel.instance_method(:abort)
|
|
32
|
+
original_exit = Kernel.instance_method(:exit)
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
Kernel.define_method(:abort, NOOP_METHOD)
|
|
36
|
+
Kernel.define_method(:exit, NOOP_METHOD)
|
|
37
|
+
|
|
38
|
+
Tapioca.silence_warnings do
|
|
39
|
+
block.call
|
|
40
|
+
end
|
|
41
|
+
ensure
|
|
42
|
+
Kernel.define_method(:exit, original_exit)
|
|
43
|
+
Kernel.define_method(:abort, original_abort)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
25
46
|
end
|
|
26
47
|
|
|
27
48
|
class Error < StandardError; 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
|
+
version: 0.17.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
316
316
|
- !ruby/object:Gem::Version
|
|
317
317
|
version: '0'
|
|
318
318
|
requirements: []
|
|
319
|
-
rubygems_version: 3.
|
|
319
|
+
rubygems_version: 3.7.2
|
|
320
320
|
specification_version: 4
|
|
321
321
|
summary: A Ruby Interface file generator for gems, core types and the Ruby standard
|
|
322
322
|
library
|