sorbet 0.4.4250 → 0.4.4253
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/srb +117 -0
- data/bin/srb-rbi +232 -0
- data/lib/constant_cache.rb +193 -0
- data/lib/create-config.rb +32 -0
- data/lib/fetch-rbis.rb +127 -0
- data/lib/find-gem-rbis.rb +52 -0
- data/lib/gem-generator-tracepoint.rb +54 -0
- data/lib/gem-generator-tracepoint/tracepoint_serializer.rb +256 -0
- data/lib/gem-generator-tracepoint/tracer.rb +180 -0
- data/lib/gem_loader.rb +579 -0
- data/lib/gem_loader.rbi +15 -0
- data/lib/hidden-definition-finder.rb +441 -0
- data/lib/real_stdlib.rb +79 -0
- data/lib/require_everything.rb +128 -0
- data/lib/serialize.rb +360 -0
- data/lib/status.rb +21 -0
- data/lib/step_interface.rb +11 -0
- data/lib/suggest-typed.rb +41 -0
- data/lib/t.rb +58 -0
- data/lib/todo-rbi.rb +48 -0
- metadata +101 -11
@@ -0,0 +1,180 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
require_relative '../real_stdlib'
|
5
|
+
|
6
|
+
require 'set'
|
7
|
+
|
8
|
+
if defined?(DelegateClass)
|
9
|
+
alias DelegateClass_without_rbi_generator DelegateClass
|
10
|
+
def DelegateClass(superclass)
|
11
|
+
result = DelegateClass_without_rbi_generator(superclass)
|
12
|
+
Sorbet::Private::GemGeneratorTracepoint::Tracer.register_delegate_class(superclass, result)
|
13
|
+
result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Sorbet::Private
|
18
|
+
module GemGeneratorTracepoint
|
19
|
+
class Tracer
|
20
|
+
module ModuleOverride
|
21
|
+
def include(mod, *smth)
|
22
|
+
result = super
|
23
|
+
Sorbet::Private::GemGeneratorTracepoint::Tracer.module_included(mod, self)
|
24
|
+
result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
Module.prepend(ModuleOverride)
|
28
|
+
|
29
|
+
module ObjectOverride
|
30
|
+
def extend(mod, *args)
|
31
|
+
result = super
|
32
|
+
Sorbet::Private::GemGeneratorTracepoint::Tracer.module_extended(mod, self)
|
33
|
+
result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Object.prepend(ObjectOverride)
|
37
|
+
|
38
|
+
module ClassOverride
|
39
|
+
def new(*)
|
40
|
+
result = super
|
41
|
+
Sorbet::Private::GemGeneratorTracepoint::Tracer.module_created(result)
|
42
|
+
result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
Class.prepend(ClassOverride)
|
46
|
+
|
47
|
+
def self.register_delegate_class(klass, delegate)
|
48
|
+
@delegate_classes[Sorbet::Private::RealStdlib.real_object_id(delegate)] = klass
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.module_created(mod)
|
52
|
+
add_to_context(type: :module, module: mod)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.module_included(included, includer)
|
56
|
+
add_to_context(type: :include, module: includer, include: included)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.module_extended(extended, extender)
|
60
|
+
add_to_context(type: :extend, module: extender, extend: extended)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.method_added(mod, method, singleton)
|
64
|
+
add_to_context(type: :method, module: mod, method: method, singleton: singleton)
|
65
|
+
end
|
66
|
+
|
67
|
+
T::Sig::WithoutRuntime.sig {returns({files: T::Hash, delegate_classes: T::Hash})}
|
68
|
+
def self.trace
|
69
|
+
start
|
70
|
+
yield
|
71
|
+
finish
|
72
|
+
trace_results
|
73
|
+
end
|
74
|
+
|
75
|
+
T::Sig::WithoutRuntime.sig {void}
|
76
|
+
def self.start
|
77
|
+
pre_cache_module_methods
|
78
|
+
install_tracepoints
|
79
|
+
end
|
80
|
+
|
81
|
+
T::Sig::WithoutRuntime.sig {void}
|
82
|
+
def self.finish
|
83
|
+
disable_tracepoints
|
84
|
+
end
|
85
|
+
|
86
|
+
T::Sig::WithoutRuntime.sig {returns({files: T::Hash, delegate_classes: T::Hash})}
|
87
|
+
def self.trace_results
|
88
|
+
{
|
89
|
+
files: @files,
|
90
|
+
delegate_classes: @delegate_classes
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
@modules = {}
|
97
|
+
@context_stack = [[]]
|
98
|
+
@files = {}
|
99
|
+
@delegate_classes = {}
|
100
|
+
|
101
|
+
def self.pre_cache_module_methods
|
102
|
+
ObjectSpace.each_object(Module) do |mod_|
|
103
|
+
mod = T.cast(mod_, Module)
|
104
|
+
@modules[Sorbet::Private::RealStdlib.real_object_id(mod)] = (mod.instance_methods(false) + mod.private_instance_methods(false)).to_set
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.add_to_context(item)
|
109
|
+
# The stack can be empty because we start the :c_return TracePoint inside a 'require' call.
|
110
|
+
# In this case, it's okay to simply add something to the stack; it will be popped off when
|
111
|
+
# the :c_return is traced.
|
112
|
+
@context_stack << [] if @context_stack.empty?
|
113
|
+
@context_stack.last << item
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.install_tracepoints
|
117
|
+
@class_tracepoint = TracePoint.new(:class) do |tp|
|
118
|
+
module_created(tp.self)
|
119
|
+
end
|
120
|
+
@c_call_tracepoint = TracePoint.new(:c_call) do |tp|
|
121
|
+
case tp.method_id
|
122
|
+
when :require, :require_relative
|
123
|
+
@context_stack << []
|
124
|
+
end
|
125
|
+
end
|
126
|
+
@c_return_tracepoint = TracePoint.new(:c_return) do |tp|
|
127
|
+
case tp.method_id
|
128
|
+
when :require, :require_relative
|
129
|
+
popped = @context_stack.pop
|
130
|
+
|
131
|
+
next if popped.empty?
|
132
|
+
|
133
|
+
path = $LOADED_FEATURES.last
|
134
|
+
if tp.return_value != true # intentional true check
|
135
|
+
next if popped.size == 1 && popped[0][:module].is_a?(LoadError)
|
136
|
+
# warn("Unexpected: constants or methods were defined when #{tp.method_id} didn't return true; adding to #{path} instead")
|
137
|
+
end
|
138
|
+
|
139
|
+
# raise 'Unexpected: constants or methods were defined without a file added to $LOADED_FEATURES' if path.nil?
|
140
|
+
# raise "Unexpected: #{path} is already defined in files" if files.key?(path)
|
141
|
+
|
142
|
+
@files[path] ||= []
|
143
|
+
@files[path] += popped
|
144
|
+
|
145
|
+
# popped.each { |item| item[:path] = path }
|
146
|
+
when :method_added, :singleton_method_added
|
147
|
+
begin
|
148
|
+
tp.disable
|
149
|
+
|
150
|
+
singleton = tp.method_id == :singleton_method_added
|
151
|
+
receiver = singleton ? Sorbet::Private::RealStdlib.real_singleton_class(tp.self) : tp.self
|
152
|
+
methods = Sorbet::Private::RealStdlib.real_instance_methods(receiver, false) + Sorbet::Private::RealStdlib.real_private_instance_methods(receiver, false)
|
153
|
+
set = @modules[Sorbet::Private::RealStdlib.real_object_id(receiver)] ||= Set.new
|
154
|
+
added = methods.find { |m| !set.include?(m) }
|
155
|
+
if added.nil?
|
156
|
+
# warn("Warning: could not find method added to #{tp.self} at #{tp.path}:#{tp.lineno}")
|
157
|
+
next
|
158
|
+
end
|
159
|
+
set << added
|
160
|
+
|
161
|
+
method_added(tp.self, added, singleton)
|
162
|
+
ensure
|
163
|
+
tp.enable
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
@class_tracepoint.enable
|
168
|
+
@c_call_tracepoint.enable
|
169
|
+
@c_return_tracepoint.enable
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.disable_tracepoints
|
173
|
+
@class_tracepoint.disable
|
174
|
+
@c_call_tracepoint.disable
|
175
|
+
@c_return_tracepoint.disable
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
data/lib/gem_loader.rb
ADDED
@@ -0,0 +1,579 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: ignore
|
3
|
+
|
4
|
+
class Sorbet::Private::GemLoader
|
5
|
+
NO_GEM = "_unknown"
|
6
|
+
|
7
|
+
# A map defining the code to load a gem. By default any gem mentioned by
|
8
|
+
# Gemfile is loaded by its name, here are either overrides or things that
|
9
|
+
# Bundler misses.
|
10
|
+
GEM_LOADER = {
|
11
|
+
'Ascii85' => proc do
|
12
|
+
my_require 'ascii85'
|
13
|
+
end,
|
14
|
+
'aws-sdk-v1' => proc do
|
15
|
+
my_require 'aws-sdk-v1'
|
16
|
+
AWS.eager_autoload!
|
17
|
+
[
|
18
|
+
AWS::DynamoDB::Errors::InternalServerError,
|
19
|
+
AWS::DynamoDB::Errors::ProvisionedThroughputExceededException,
|
20
|
+
AWS::DynamoDB::Errors::ResourceInUseException,
|
21
|
+
AWS::DynamoDB::Errors::ResourceNotFoundException,
|
22
|
+
AWS::EC2::Errors::RequestLimitExceeded,
|
23
|
+
AWS::S3::Errors::AccessDenied,
|
24
|
+
AWS::S3::Errors::NoSuchBucket,
|
25
|
+
AWS::S3::Errors::NotFound,
|
26
|
+
]
|
27
|
+
end,
|
28
|
+
'aws-sdk-core' => proc do
|
29
|
+
my_require 'aws-sdk'
|
30
|
+
[
|
31
|
+
Aws::AssumeRoleCredentials,
|
32
|
+
Aws::Athena,
|
33
|
+
Aws::AutoScaling::Client,
|
34
|
+
Aws::AutoScaling::Errors::AlreadyExists,
|
35
|
+
Aws::AutoScaling::Errors::Throttling,
|
36
|
+
Aws::AutoScaling::Errors::ValidationError,
|
37
|
+
Aws::CloudFormation::Client,
|
38
|
+
Aws::CloudFormation::Errors::ValidationError,
|
39
|
+
Aws::CloudWatchLogs::Client,
|
40
|
+
Aws::Credentials,
|
41
|
+
Aws::DynamoDB::Client,
|
42
|
+
Aws::DynamoDB::Errors::ProvisionedThroughputExceededException,
|
43
|
+
Aws::EC2::Errors::RequestLimitExceeded,
|
44
|
+
Aws::ElasticLoadBalancing::Client,
|
45
|
+
Aws::Errors::ServiceError,
|
46
|
+
Aws::IAM::Client,
|
47
|
+
Aws::IAM::Errors::NoSuchEntity,
|
48
|
+
Aws::IAM::Resource,
|
49
|
+
Aws::InstanceProfileCredentials,
|
50
|
+
Aws::Lambda::Client,
|
51
|
+
Aws::Query::ParamList,
|
52
|
+
Aws::S3::Bucket,
|
53
|
+
Aws::S3::Client,
|
54
|
+
Aws::S3::Encryption::Client,
|
55
|
+
Aws::S3::Errors::InvalidRange,
|
56
|
+
Aws::S3::Errors::NoSuchKey,
|
57
|
+
Aws::S3::Errors::NotFound,
|
58
|
+
Aws::S3::Object,
|
59
|
+
Aws::S3::Resource,
|
60
|
+
Aws::SES::Client,
|
61
|
+
Aws::SES::Errors,
|
62
|
+
Aws::SES::Errors::AccessDenied,
|
63
|
+
Aws::SES::Errors::MessageRejected,
|
64
|
+
Aws::SES::Errors::ServiceError,
|
65
|
+
Aws::SES::Types,
|
66
|
+
Aws::SES::Types::SendEmailResponse,
|
67
|
+
Aws::SNS::Client,
|
68
|
+
Aws::SNS::MessageVerifier,
|
69
|
+
Aws::SQS::QueuePoller,
|
70
|
+
Aws::STS::Client,
|
71
|
+
Aws::STS::Errors::AccessDenied,
|
72
|
+
Seahorse::Client::NetworkingError,
|
73
|
+
Seahorse::Client::Response,
|
74
|
+
]
|
75
|
+
end,
|
76
|
+
'bloomfilter-rb' => proc do
|
77
|
+
my_require 'bloomfilter-rb'
|
78
|
+
end,
|
79
|
+
'hashie' => proc do
|
80
|
+
my_require 'hashie'
|
81
|
+
[
|
82
|
+
Hashie::Mash,
|
83
|
+
]
|
84
|
+
end,
|
85
|
+
'hike' => proc do
|
86
|
+
my_require 'hike'
|
87
|
+
[
|
88
|
+
Hike::Trail,
|
89
|
+
]
|
90
|
+
end,
|
91
|
+
'http' => proc do
|
92
|
+
my_require 'http'
|
93
|
+
end,
|
94
|
+
'http-form_data' => proc do
|
95
|
+
my_require 'http/form_data'
|
96
|
+
end,
|
97
|
+
'http_parser.rb' => proc do
|
98
|
+
my_require 'http/parser'
|
99
|
+
end,
|
100
|
+
'minitest' => proc do
|
101
|
+
my_require 'minitest'
|
102
|
+
my_require 'minitest/mock'
|
103
|
+
my_require 'minitest/spec'
|
104
|
+
my_require 'minitest/reporters'
|
105
|
+
end,
|
106
|
+
'rack-test' => proc do
|
107
|
+
my_require 'rack/test'
|
108
|
+
end,
|
109
|
+
'pagerduty-full' => proc do
|
110
|
+
my_require 'pagerduty/full'
|
111
|
+
end,
|
112
|
+
'puma' => proc do
|
113
|
+
my_require 'puma'
|
114
|
+
my_require 'puma/configuration'
|
115
|
+
my_require 'puma/launcher'
|
116
|
+
my_require 'puma/server'
|
117
|
+
end,
|
118
|
+
'term-ansicolor' => proc do
|
119
|
+
my_require 'term/ansicolor'
|
120
|
+
end,
|
121
|
+
'rexml' => proc do
|
122
|
+
my_require "rexml/document"
|
123
|
+
my_require "rexml/streamlistener"
|
124
|
+
end,
|
125
|
+
'rubyzip' => proc do
|
126
|
+
my_require "zip"
|
127
|
+
my_require 'zip/filesystem'
|
128
|
+
end,
|
129
|
+
'nsq-ruby' => proc do
|
130
|
+
my_require 'nsq'
|
131
|
+
end,
|
132
|
+
'mongo-ruby-driver' => proc do
|
133
|
+
my_require 'mongo'
|
134
|
+
end,
|
135
|
+
'presto-client-ruby' => proc do
|
136
|
+
my_require 'presto-client'
|
137
|
+
end,
|
138
|
+
'bcrypt-ruby' => proc do
|
139
|
+
my_require 'bcrypt'
|
140
|
+
end,
|
141
|
+
'xml-simple' => proc do
|
142
|
+
my_require 'xmlsimple'
|
143
|
+
end,
|
144
|
+
'sinatra-contrib' => proc do
|
145
|
+
# We can't my_require all of 'sinatra/contrib' since we put `raise` in them
|
146
|
+
my_require 'sinatra/content_for'
|
147
|
+
my_require 'sinatra/capture'
|
148
|
+
my_require 'sinatra/multi_route'
|
149
|
+
my_require 'sinatra/contrib/version'
|
150
|
+
end,
|
151
|
+
'thin-attach_socket' => proc do
|
152
|
+
my_require 'thin'
|
153
|
+
my_require 'thin/attach_socket'
|
154
|
+
end,
|
155
|
+
'sinatra-partial' => proc do
|
156
|
+
my_require 'sinatra/partial'
|
157
|
+
end,
|
158
|
+
'rack_csrf' => proc do
|
159
|
+
my_require 'rack/csrf'
|
160
|
+
end,
|
161
|
+
'rack-flash3' => proc do
|
162
|
+
my_require 'rack-flash'
|
163
|
+
end,
|
164
|
+
'google-api-client' => proc do
|
165
|
+
# There are lots more but this is all we use for now
|
166
|
+
my_require 'google/apis/calendar_v3'
|
167
|
+
my_require 'google/apis/drive_v3'
|
168
|
+
my_require 'google/apis/gmail_v1'
|
169
|
+
end,
|
170
|
+
'concurrent-ruby' => proc do
|
171
|
+
my_require 'concurrent'
|
172
|
+
end,
|
173
|
+
'cld2' => proc do
|
174
|
+
my_require 'cld'
|
175
|
+
end,
|
176
|
+
'twitter_cldr' => proc do
|
177
|
+
my_require 'twitter_cldr'
|
178
|
+
[
|
179
|
+
TwitterCldr::Shared::Territories,
|
180
|
+
]
|
181
|
+
end,
|
182
|
+
'stackprof' => proc do
|
183
|
+
my_require 'stackprof'
|
184
|
+
[
|
185
|
+
StackProf::Report,
|
186
|
+
]
|
187
|
+
end,
|
188
|
+
'sprockets' => proc do
|
189
|
+
my_require 'sprockets'
|
190
|
+
[
|
191
|
+
Sprockets::Cache::FileStore,
|
192
|
+
Sprockets::Environment,
|
193
|
+
Sprockets::Manifest,
|
194
|
+
]
|
195
|
+
end,
|
196
|
+
'signet' => proc do
|
197
|
+
my_require 'signet'
|
198
|
+
my_require 'signet/oauth_2/client'
|
199
|
+
end,
|
200
|
+
'roo' => proc do
|
201
|
+
my_require 'roo'
|
202
|
+
[
|
203
|
+
Roo::Spreadsheet,
|
204
|
+
]
|
205
|
+
version = Bundler.load.specs['roo'][0].stub.version
|
206
|
+
if !Gem::Requirement.create('2.0.0').satisfied_by?(version)
|
207
|
+
[
|
208
|
+
Roo::Excel,
|
209
|
+
]
|
210
|
+
end
|
211
|
+
end,
|
212
|
+
'rack-protection' => proc do
|
213
|
+
my_require 'rack-protection'
|
214
|
+
[
|
215
|
+
Rack::Protection::FrameOptions,
|
216
|
+
]
|
217
|
+
end,
|
218
|
+
'rack' => proc do
|
219
|
+
my_require 'rack'
|
220
|
+
[
|
221
|
+
Rack::Auth::Basic::Request,
|
222
|
+
Rack::Builder,
|
223
|
+
Rack::Deflater,
|
224
|
+
Rack::File,
|
225
|
+
Rack::Mime,
|
226
|
+
Rack::MockRequest,
|
227
|
+
Rack::MockResponse,
|
228
|
+
Rack::Session::Cookie,
|
229
|
+
Rack::Static,
|
230
|
+
]
|
231
|
+
end,
|
232
|
+
'poncho' => proc do
|
233
|
+
[
|
234
|
+
Poncho::ClientError,
|
235
|
+
Poncho::JSONMethod,
|
236
|
+
Poncho::Resource,
|
237
|
+
Poncho::ValidationError,
|
238
|
+
]
|
239
|
+
end,
|
240
|
+
'parser' => proc do
|
241
|
+
my_require 'parser'
|
242
|
+
my_require 'parser/ruby24'
|
243
|
+
end,
|
244
|
+
'net' => proc do
|
245
|
+
my_require 'net/dns'
|
246
|
+
my_require 'net/ftp'
|
247
|
+
my_require 'net/http'
|
248
|
+
my_require 'net/http/digest_auth'
|
249
|
+
my_require 'net/http/persistent'
|
250
|
+
my_require 'net/imap'
|
251
|
+
my_require 'net/protocol'
|
252
|
+
my_require 'net/sftp'
|
253
|
+
my_require 'net/smtp'
|
254
|
+
my_require 'net/ssh'
|
255
|
+
my_require 'net/ssh/proxy/http'
|
256
|
+
my_require 'rubyntlm'
|
257
|
+
end,
|
258
|
+
'openssl' => proc do
|
259
|
+
my_require 'openssl'
|
260
|
+
[
|
261
|
+
OpenSSL::X509::Store,
|
262
|
+
]
|
263
|
+
end,
|
264
|
+
'mail' => proc do
|
265
|
+
my_require 'mail'
|
266
|
+
[
|
267
|
+
Mail::Address,
|
268
|
+
Mail::AddressList,
|
269
|
+
Mail::Parsers::AddressListsParser,
|
270
|
+
Mail::Parsers::ContentDispositionParser,
|
271
|
+
Mail::Parsers::ContentLocationParser,
|
272
|
+
Mail::Parsers::ContentTransferEncodingParser,
|
273
|
+
Mail::Parsers::ContentTypeParser,
|
274
|
+
Mail::Parsers::DateTimeParser,
|
275
|
+
Mail::Parsers::EnvelopeFromParser,
|
276
|
+
Mail::Parsers::MessageIdsParser,
|
277
|
+
Mail::Parsers::MimeVersionParser,
|
278
|
+
Mail::Parsers::PhraseListsParser,
|
279
|
+
Mail::Parsers::ReceivedParser,
|
280
|
+
]
|
281
|
+
end,
|
282
|
+
'kramdown' => proc do
|
283
|
+
my_require 'kramdown'
|
284
|
+
[
|
285
|
+
Kramdown::Converter::Html,
|
286
|
+
]
|
287
|
+
end,
|
288
|
+
'ice_cube' => proc do
|
289
|
+
my_require 'ice_cube'
|
290
|
+
[
|
291
|
+
IceCube::DailyRule,
|
292
|
+
IceCube::MonthlyRule,
|
293
|
+
IceCube::WeeklyRule,
|
294
|
+
IceCube::YearlyRule,
|
295
|
+
IceCube::Schedule,
|
296
|
+
]
|
297
|
+
end,
|
298
|
+
'i18n' => proc do
|
299
|
+
my_require 'i18n'
|
300
|
+
[
|
301
|
+
I18n::Locale::Tag::Rfc4646,
|
302
|
+
]
|
303
|
+
end,
|
304
|
+
'http-cookie' => proc do
|
305
|
+
my_require 'http-cookie'
|
306
|
+
my_require 'http/cookie_jar'
|
307
|
+
my_require 'mechanize'
|
308
|
+
[
|
309
|
+
HTTP::CookieJar::AbstractSaver,
|
310
|
+
]
|
311
|
+
end,
|
312
|
+
'faraday' => proc do
|
313
|
+
my_require 'faraday'
|
314
|
+
[
|
315
|
+
Faraday::Request::Multipart,
|
316
|
+
Faraday::Request::UrlEncoded,
|
317
|
+
Faraday::Response::RaiseError,
|
318
|
+
]
|
319
|
+
end,
|
320
|
+
'escort' => proc do
|
321
|
+
my_require 'escort'
|
322
|
+
[
|
323
|
+
Escort::App,
|
324
|
+
Escort::Setup::Dsl::Options,
|
325
|
+
Escort::Trollop::Parser,
|
326
|
+
]
|
327
|
+
end,
|
328
|
+
'digest' => proc do
|
329
|
+
my_require 'digest'
|
330
|
+
[
|
331
|
+
Digest::SHA2,
|
332
|
+
]
|
333
|
+
end,
|
334
|
+
'coderay' => proc do
|
335
|
+
my_require 'coderay'
|
336
|
+
[
|
337
|
+
CodeRay::PluginHost,
|
338
|
+
]
|
339
|
+
end,
|
340
|
+
'byebug' => proc do
|
341
|
+
my_require 'byebug'
|
342
|
+
my_require 'byebug/core'
|
343
|
+
end,
|
344
|
+
'racc' => proc do
|
345
|
+
my_require 'parser'
|
346
|
+
end,
|
347
|
+
'rbnacl' => proc do
|
348
|
+
my_require 'rbnacl/libsodium'
|
349
|
+
end,
|
350
|
+
'double-bag-ftps' => proc do
|
351
|
+
my_require 'double_bag_ftps'
|
352
|
+
end,
|
353
|
+
'livechat_client' => proc do
|
354
|
+
my_require 'livechat'
|
355
|
+
end,
|
356
|
+
'nio4r' => proc do
|
357
|
+
my_require 'nio'
|
358
|
+
end,
|
359
|
+
'rgl' => proc do
|
360
|
+
my_require 'rgl/adjacency'
|
361
|
+
my_require 'rgl/implicit'
|
362
|
+
my_require 'rgl/traversal'
|
363
|
+
my_require 'rgl/graph_iterator'
|
364
|
+
my_require 'rgl/edmonds_karp'
|
365
|
+
end,
|
366
|
+
'redcarpet' => proc do
|
367
|
+
my_require 'redcarpet'
|
368
|
+
my_require 'redcarpet/render_strip'
|
369
|
+
end,
|
370
|
+
'sequel' => proc do
|
371
|
+
my_require 'sequel'
|
372
|
+
my_require 'sequel/sql'
|
373
|
+
end,
|
374
|
+
'will_paginate' => proc do
|
375
|
+
my_require 'will_paginate'
|
376
|
+
my_require 'will_paginate/collection'
|
377
|
+
end,
|
378
|
+
'yard' => proc do
|
379
|
+
my_require 'yard'
|
380
|
+
[
|
381
|
+
YARD::CodeObjects::MethodObject,
|
382
|
+
YARD::Docstring,
|
383
|
+
YARD::Handlers::Ruby::Base,
|
384
|
+
YARD::Registry,
|
385
|
+
YARD::Tags::Library,
|
386
|
+
YARD::Tags::Tag,
|
387
|
+
]
|
388
|
+
end,
|
389
|
+
'mocha' => proc do
|
390
|
+
my_require 'minitest/spec' # mocha forces you to do this first
|
391
|
+
my_require 'mocha/setup'
|
392
|
+
end,
|
393
|
+
'bundler-audit' => proc do
|
394
|
+
my_require 'bundler/audit'
|
395
|
+
end,
|
396
|
+
'google-protobuf' => proc do
|
397
|
+
my_require 'google/protobuf'
|
398
|
+
end,
|
399
|
+
'multipart-post' => proc do
|
400
|
+
my_require 'net/http/post/multipart'
|
401
|
+
end,
|
402
|
+
'rdl' => proc do
|
403
|
+
# needed because this isn't required by default in the Gemfile
|
404
|
+
my_require 'rdl_disable'
|
405
|
+
end,
|
406
|
+
'rss' => proc do
|
407
|
+
# needed because this isn't required our Gemfile but some of our gems use it
|
408
|
+
my_require 'rss'
|
409
|
+
end,
|
410
|
+
'ruby-ole' => proc do
|
411
|
+
my_require 'ole/storage'
|
412
|
+
end,
|
413
|
+
'ruby-rc4' => proc do
|
414
|
+
my_require 'rc4'
|
415
|
+
end,
|
416
|
+
'ruby-prof' => proc do
|
417
|
+
my_require 'ruby-prof'
|
418
|
+
[
|
419
|
+
RubyProf::AbstractPrinter,
|
420
|
+
]
|
421
|
+
end,
|
422
|
+
'stylus-source' => proc do
|
423
|
+
my_require 'stylus'
|
424
|
+
end,
|
425
|
+
'time-utils' => proc do
|
426
|
+
my_require 'time/utils'
|
427
|
+
my_require 'date/utils'
|
428
|
+
end,
|
429
|
+
'thor' => proc do
|
430
|
+
my_require 'thor'
|
431
|
+
[
|
432
|
+
Thor::Actions,
|
433
|
+
Thor::Group,
|
434
|
+
]
|
435
|
+
end,
|
436
|
+
'unicode-display_width' => proc do
|
437
|
+
my_require 'unicode/display_width'
|
438
|
+
end,
|
439
|
+
'simplecov-html' => proc do
|
440
|
+
my_require 'simplecov'
|
441
|
+
end,
|
442
|
+
'thwait' => proc do
|
443
|
+
my_require 'thwait'
|
444
|
+
end,
|
445
|
+
'matrix' => proc do
|
446
|
+
my_require 'matrix'
|
447
|
+
end,
|
448
|
+
'zxcvbn-ruby' => proc do
|
449
|
+
my_require 'zxcvbn'
|
450
|
+
end,
|
451
|
+
'elasticsearch-transport' => proc do
|
452
|
+
my_require 'elasticsearch'
|
453
|
+
end,
|
454
|
+
'tzinfo' => proc do
|
455
|
+
my_require 'tzinfo'
|
456
|
+
my_require 'tzinfo/data'
|
457
|
+
TZInfo::Timezone.all.map(&:canonical_zone)
|
458
|
+
end,
|
459
|
+
'pry-doc' => proc do
|
460
|
+
my_require 'pry'
|
461
|
+
my_require 'pry-doc'
|
462
|
+
end,
|
463
|
+
'taxjar-ruby' => proc do
|
464
|
+
my_require 'taxjar'
|
465
|
+
end,
|
466
|
+
'nokogiri' => proc do
|
467
|
+
my_require 'nokogiri'
|
468
|
+
my_require 'webrobots'
|
469
|
+
my_require 'html_truncator'
|
470
|
+
end,
|
471
|
+
'actionpack' => proc do
|
472
|
+
my_require 'actionpack'
|
473
|
+
[
|
474
|
+
ActionController::Base,
|
475
|
+
ActionDispatch::SystemTestCase,
|
476
|
+
]
|
477
|
+
end,
|
478
|
+
'actionmailer' => proc do
|
479
|
+
my_require 'actionmailer'
|
480
|
+
[
|
481
|
+
ActionMailer::Base,
|
482
|
+
ActionMailer::MessageDelivery,
|
483
|
+
]
|
484
|
+
end,
|
485
|
+
'activejob' => proc do
|
486
|
+
my_require 'activejob'
|
487
|
+
[
|
488
|
+
ActiveJob::Base,
|
489
|
+
]
|
490
|
+
end,
|
491
|
+
'activerecord' => proc do
|
492
|
+
my_require 'activerecord'
|
493
|
+
[
|
494
|
+
ActiveRecord::Schema,
|
495
|
+
ActiveRecord::Migration::Current,
|
496
|
+
]
|
497
|
+
end,
|
498
|
+
'actionview' => proc do
|
499
|
+
my_require 'actionview'
|
500
|
+
[
|
501
|
+
ActionView::TestCase,
|
502
|
+
]
|
503
|
+
end,
|
504
|
+
'rdoc' => proc do
|
505
|
+
my_require 'rdoc'
|
506
|
+
[
|
507
|
+
RDoc::Options,
|
508
|
+
]
|
509
|
+
end,
|
510
|
+
'paul_revere' => proc do
|
511
|
+
my_require 'paul_revere'
|
512
|
+
[
|
513
|
+
Announcement,
|
514
|
+
]
|
515
|
+
end,
|
516
|
+
'clearance' => proc do
|
517
|
+
my_require 'clearance'
|
518
|
+
[
|
519
|
+
ClearanceMailer,
|
520
|
+
]
|
521
|
+
end,
|
522
|
+
'webmock' => proc do
|
523
|
+
my_require 'webmock'
|
524
|
+
WebMock.singleton_class.send(:define_method, :enable!) do
|
525
|
+
puts "\nWebMock.enable! is incompatible with Sorbet. Please don't unconditionally do it on requiring this file."
|
526
|
+
end
|
527
|
+
end,
|
528
|
+
'codecov' => proc do
|
529
|
+
my_require 'simplecov'
|
530
|
+
my_require 'codecov'
|
531
|
+
end,
|
532
|
+
}
|
533
|
+
|
534
|
+
# This is so that the autoloader doesn't treat these as manditory requires
|
535
|
+
# before loading this file
|
536
|
+
def self.my_require(gem)
|
537
|
+
require gem # rubocop:disable PrisonGuard/NoDynamicRequire
|
538
|
+
end
|
539
|
+
|
540
|
+
def self.require_gem(gem)
|
541
|
+
if gem == NO_GEM
|
542
|
+
require_all_gems
|
543
|
+
return
|
544
|
+
end
|
545
|
+
loader = GEM_LOADER[gem]
|
546
|
+
if loader
|
547
|
+
begin
|
548
|
+
loader.call
|
549
|
+
rescue NameError => e
|
550
|
+
puts "NameError: #{e}"
|
551
|
+
end
|
552
|
+
else
|
553
|
+
require gem # rubocop:disable PrisonGuard/NoDynamicRequire
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
def self.require_all_gems
|
558
|
+
require 'bundler/setup'
|
559
|
+
|
560
|
+
# Do not load gems in Gemfile where require is false
|
561
|
+
deps = Bundler.load.dependencies.reject { |dep| dep.autorequire && dep.autorequire.empty? }
|
562
|
+
specs = deps.flat_map do |dep|
|
563
|
+
begin
|
564
|
+
dep.to_specs
|
565
|
+
rescue Gem::MissingSpecError
|
566
|
+
[]
|
567
|
+
end
|
568
|
+
end.to_set
|
569
|
+
|
570
|
+
specs.sort_by(&:name).each do |gemspec|
|
571
|
+
begin
|
572
|
+
require_gem(gemspec.name)
|
573
|
+
rescue LoadError
|
574
|
+
end
|
575
|
+
end
|
576
|
+
Bundler.require
|
577
|
+
end
|
578
|
+
end
|
579
|
+
# rubocop:enable PrisonGuard/AutogenLoaderPreamble
|