orthoses-rails 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -0
  3. data/examples/rails/Rakefile +373 -0
  4. data/examples/rails/known_sig/action_cable/connection/test_cookie_jar.rbs +2 -0
  5. data/examples/rails/known_sig/action_controller/metal.rbs +4 -0
  6. data/examples/rails/known_sig/action_dispatch/cookies/cookie_jar.rbs +3 -0
  7. data/examples/rails/known_sig/action_dispatch/response.rbs +4 -0
  8. data/examples/rails/patch/drb/drb_undumped.rbs +2 -0
  9. data/examples/rails/patch/drb.rbs +2 -0
  10. data/examples/rails/patch/erubi/engine.rbs +4 -0
  11. data/examples/rails/patch/erubi.rbs +2 -0
  12. data/examples/rails/patch/minitest/kernel.rbs +44 -0
  13. data/examples/rails/patch/minitest/minitest/abstract_reporter.rbs +49 -0
  14. data/examples/rails/patch/minitest/minitest/assertion.rbs +16 -0
  15. data/examples/rails/patch/minitest/minitest/assertions.rbs +545 -0
  16. data/examples/rails/patch/minitest/minitest/backtrace_filter.rbs +16 -0
  17. data/examples/rails/patch/minitest/minitest/bench_spec.rbs +101 -0
  18. data/examples/rails/patch/minitest/minitest/benchmark.rbs +258 -0
  19. data/examples/rails/patch/minitest/minitest/composite_reporter.rbs +25 -0
  20. data/examples/rails/patch/minitest/minitest/expectations.rbs +21 -0
  21. data/examples/rails/patch/minitest/minitest/guard.rbs +64 -0
  22. data/examples/rails/patch/minitest/minitest/mock.rbs +60 -0
  23. data/examples/rails/patch/minitest/minitest/parallel/executor.rbs +42 -0
  24. data/examples/rails/patch/minitest/minitest/parallel/test/class_methods.rbs +6 -0
  25. data/examples/rails/patch/minitest/minitest/parallel/test.rbs +3 -0
  26. data/examples/rails/patch/minitest/minitest/parallel.rbs +2 -0
  27. data/examples/rails/patch/minitest/minitest/pride_io.rbs +54 -0
  28. data/examples/rails/patch/minitest/minitest/pride_lol.rbs +17 -0
  29. data/examples/rails/patch/minitest/minitest/progress_reporter.rbs +11 -0
  30. data/examples/rails/patch/minitest/minitest/reportable.rbs +51 -0
  31. data/examples/rails/patch/minitest/minitest/reporter.rbs +5 -0
  32. data/examples/rails/patch/minitest/minitest/result.rbs +28 -0
  33. data/examples/rails/patch/minitest/minitest/runnable.rbs +131 -0
  34. data/examples/rails/patch/minitest/minitest/skip.rbs +6 -0
  35. data/examples/rails/patch/minitest/minitest/spec/dsl/instance_methods.rbs +48 -0
  36. data/examples/rails/patch/minitest/minitest/spec/dsl.rbs +125 -0
  37. data/examples/rails/patch/minitest/minitest/spec.rbs +10 -0
  38. data/examples/rails/patch/minitest/minitest/statistics_reporter.rbs +76 -0
  39. data/examples/rails/patch/minitest/minitest/summary_reporter.rbs +26 -0
  40. data/examples/rails/patch/minitest/minitest/test/lifecycle_hooks.rbs +92 -0
  41. data/examples/rails/patch/minitest/minitest/test.rbs +76 -0
  42. data/examples/rails/patch/minitest/minitest/unexpected_error.rbs +10 -0
  43. data/examples/rails/patch/minitest/minitest/unit/test_case.rbs +3 -0
  44. data/examples/rails/patch/minitest/minitest/unit.rbs +5 -0
  45. data/examples/rails/patch/minitest/minitest.rbs +966 -0
  46. data/examples/rails/patch/pg/simple_decoder.rbs +4 -0
  47. data/examples/rails/patch/pg.rbs +2 -0
  48. data/examples/rails/patch/qc/queue.rbs +2 -0
  49. data/examples/rails/patch/qc.rbs +2 -0
  50. data/examples/rails/patch/que/job.rbs +2 -0
  51. data/examples/rails/patch/que.rbs +2 -0
  52. data/examples/rails/patch/rack/cache/entity_store.rbs +2 -0
  53. data/examples/rails/patch/rack/cache/meta_store.rbs +2 -0
  54. data/examples/rails/patch/rack/cache.rbs +2 -0
  55. data/examples/rails/patch/rack/session/dalli.rbs +2 -0
  56. data/examples/rails/patch/rack/session.rbs +2 -0
  57. data/examples/rails/patch/rboc.rbs +2 -0
  58. data/examples/rails/patch/rdoc/generator/sdoc.rbs +3 -0
  59. data/examples/rails/patch/rdoc/generator.rbs +2 -0
  60. data/examples/rails/patch/rdoc/task.rbs +2 -0
  61. data/examples/rails/patch/ripper.rbs +2 -0
  62. data/examples/rails/patch/sidekiq/worker.rbs +2 -0
  63. data/examples/rails/patch/sidekiq.rbs +2 -0
  64. data/examples/rails/patch/sneakers/worker.rbs +2 -0
  65. data/examples/rails/patch/sneakers.rbs +2 -0
  66. data/examples/rails/patch/sucker_punch/job.rbs +2 -0
  67. data/examples/rails/patch/sucker_punch.rbs +2 -0
  68. data/examples/rails/patch/thor/actions/create_file.rbs +2 -0
  69. data/examples/rails/patch/thor/actions.rbs +2 -0
  70. data/examples/rails/patch/thor/error.rbs +2 -0
  71. data/examples/rails/patch/thor/group.rbs +2 -0
  72. data/examples/rails/patch/thor.rbs +2 -0
  73. data/lib/orthoses/active_model/has_secure_password.rb +24 -13
  74. data/lib/orthoses/active_model/known_sig/7.0/serialization.rbs +4 -0
  75. data/lib/orthoses/active_model/known_sig/7.0/validations.rbs +4 -0
  76. data/lib/orthoses/active_model/known_sig.rb +21 -0
  77. data/lib/orthoses/active_model.rb +4 -0
  78. data/lib/orthoses/active_record/belongs_to.rb +10 -4
  79. data/lib/orthoses/active_record/generated_attribute_methods.rb +6 -4
  80. data/lib/orthoses/active_record/has_many.rb +6 -6
  81. data/lib/orthoses/active_record/has_one.rb +5 -4
  82. data/lib/orthoses/active_record/known_sig/6.0/result.rbs +5 -0
  83. data/lib/orthoses/active_record/known_sig/6.1/result.rbs +5 -0
  84. data/lib/orthoses/active_record/known_sig/7.0/encryption/context.rbs +9 -0
  85. data/lib/orthoses/active_record/known_sig/7.0/result.rbs +5 -0
  86. data/lib/orthoses/active_record/known_sig.rb +21 -0
  87. data/lib/orthoses/active_record/query_methods.rb +32 -0
  88. data/lib/orthoses/active_record.rb +8 -0
  89. data/lib/orthoses/active_support/class_attribute.rb +30 -17
  90. data/lib/orthoses/active_support/configurable.rb +36 -0
  91. data/lib/orthoses/active_support/delegation.rb +158 -0
  92. data/lib/orthoses/active_support/known_sig/7.0/active_support/callbacks/callback_chain.rbs +9 -0
  93. data/lib/orthoses/active_support/known_sig/7.0/active_support/hash_with_indifferent_access.rbs +6 -0
  94. data/lib/orthoses/active_support/known_sig/7.0/active_support/multibyte/chars.rbs +7 -0
  95. data/lib/orthoses/active_support/known_sig/7.0/hash_with_indifferent_access.rbs +2 -0
  96. data/lib/orthoses/active_support/known_sig/{time.rbs → 7.0/time.rbs} +4 -0
  97. data/lib/orthoses/active_support/known_sig.rb +21 -0
  98. data/lib/orthoses/active_support/mattr_accessor.rb +21 -14
  99. data/lib/orthoses/active_support/time_with_zone.rb +13 -15
  100. data/lib/orthoses/active_support.rb +24 -0
  101. data/lib/orthoses/rails/known_sig_helper.rb +22 -0
  102. data/lib/orthoses/rails/version.rb +1 -1
  103. data/lib/orthoses/rails.rb +4 -11
  104. data/orthoses-rails.gemspec +2 -2
  105. metadata +97 -9
  106. data/lib/orthoses/active_support/concern.rb +0 -22
  107. data/lib/orthoses/active_support/known_sig/active_support/time_with_zone.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76d6291b36d7d10e10f2d5b0898fa06a8a886375f9f91e91b2db718847c42eb2
4
- data.tar.gz: 9d33694af285fdc0a214af35c26e143990689bca720429ca7029ccb48f0e531b
3
+ metadata.gz: f98262e6c8d3c7f75039f41d1a14b991de17171702663d111b7dc6e9d8cac2bb
4
+ data.tar.gz: 28db8b6a6bdee762946bb2c7287233804543a1e5f7f735e56ac1c2d8875dc457
5
5
  SHA512:
6
- metadata.gz: a00f874e057a7515e2427bef047c25fc4a5bfe5f698e177b4e3919b4acc2df4cd4093b8fd407c7c493a1b548bbed0340f916af6f43bb37b0bd01e128f3ca3f8f
7
- data.tar.gz: 77d8183eafa99f69864d37eae0dea091f0a2d0cf57530d10d524c61cb2ababdd8478ba6a2aad19e3be76119af7a6ee7be8e7fcd3bb8d1a7c06487c54aef3ebf3
6
+ metadata.gz: 13f1a9891b7a526aeed309854ed14bf6ee3e2b712ede4e7d0c63c33f8358f641061b6e81ad12773eff3e91043051f7ab16bb8aa349fb0c3ff38e4a7ce6b2654c
7
+ data.tar.gz: f3dd8dfea66c1b0477a9d17f736161e34b3a7a7c4fdaef3fc3948f84c60a6ac79fcfe1678392b8ca32746db4dc1b8f43a66e25b6d0dd4a6904440c1d0bc70cc0
data/README.md CHANGED
@@ -3,6 +3,45 @@
3
3
  [Orthoses](https://github.com/ksss/orthoses) extension for Ruby on Rails.
4
4
  Orthoses::Rails automatically generates RBS for methods added by Rails.
5
5
 
6
+ ## Features
7
+
8
+ ### Orthoses::ActiveModel::HasSecurePassword
9
+
10
+ Add signatures that generated form `ActiveModel::SecurePassword::ClassMethods#has_secure_password`.
11
+
12
+ ### Orthoses::ActiveRecord::BelongsTo
13
+
14
+ Add signatures that generated form `ActiveRecord::Associations::ClassMethods#belongs_to`.
15
+
16
+ ### Orthoses::ActiveRecord::GeneratedAttributeMethods
17
+
18
+ Add signatures that generated from DB schema columns.
19
+
20
+ ### Orthoses::ActiveRecord::HasMany
21
+
22
+ Add signatures that generated form `ActiveRecord::Associations::ClassMethods#has_many`.
23
+
24
+ ### Orthoses::ActiveRecord::HasOne
25
+
26
+ Add signatures that generated form `ActiveRecord::Associations::ClassMethods#has_one`.
27
+
28
+ ### Orthoses::ActiveSupport::ClassAttribute
29
+
30
+ Add signatures that generated form `Class#class_attribute`.
31
+
32
+ ### Orthoses::ActiveSupport::Concern
33
+
34
+ Add signature `extend ActiveSupport::Concern` only.
35
+
36
+ ### Orthoses::ActiveSupport::MattrAccessor
37
+
38
+ Add signatures that generated form `Module#mattr_accessor`, `Module#mattr_reader` and `Module#mattr_writer`.
39
+
40
+ ### Orthoses::ActiveSupport::TimeWithZone
41
+
42
+ Add signatures `Time` and `ActiveSupport::TimeWithZone`.
43
+ Methods and mixin delegated from `Time` are added to `ActiveSupport::TimeWithZone`.
44
+
6
45
  ## Installation
7
46
 
8
47
  Install the gem and add to the application's Gemfile by executing:
@@ -0,0 +1,373 @@
1
+ REPO_ROOT = "#{File.dirname(__FILE__)}/src"
2
+ $:.unshift("#{REPO_ROOT}/actioncable/lib")
3
+ $:.unshift("#{REPO_ROOT}/actionmailbox/lib")
4
+ $:.unshift("#{REPO_ROOT}/actionmailer/lib")
5
+ $:.unshift("#{REPO_ROOT}/actionpack/lib")
6
+ $:.unshift("#{REPO_ROOT}/actiontext/lib")
7
+ $:.unshift("#{REPO_ROOT}/actionview/lib")
8
+ $:.unshift("#{REPO_ROOT}/activejob/lib")
9
+ $:.unshift("#{REPO_ROOT}/activemodel/lib")
10
+ $:.unshift("#{REPO_ROOT}/activerecord/lib")
11
+ $:.unshift("#{REPO_ROOT}/activestorage/lib")
12
+ $:.unshift("#{REPO_ROOT}/activesupport/lib")
13
+ $:.unshift("#{REPO_ROOT}/railties/lib")
14
+
15
+ require 'orthoses'
16
+ require 'orthoses-rails'
17
+ require 'openssl'
18
+ require 'cgi'
19
+ require 'uri'
20
+
21
+ Orthoses.logger.level = :error
22
+
23
+ Orthoses::Utils.unautoload!
24
+
25
+ def run_child_process
26
+ pid = fork do
27
+ yield
28
+ end
29
+ Process.wait(pid)
30
+ end
31
+
32
+ def switch_branch(name)
33
+ cd "src" do
34
+ sh "git switch #{name}"
35
+ end
36
+ end
37
+
38
+ def generate(out_dir, version)
39
+ loader = -> () {
40
+ # require "rails/all"
41
+ require "rails/app_updater"
42
+ require "active_support/all"
43
+ require "active_record"
44
+ require "active_job"
45
+ require "active_model"
46
+ require "active_storage"
47
+ require "action_dispatch"
48
+ require "action_mailbox"
49
+ require "action_mailer"
50
+ require "action_pack"
51
+ require "action_text"
52
+ require "action_view"
53
+
54
+ [
55
+ ActiveSupport,
56
+ ActiveModel,
57
+ ActiveJob,
58
+ ActiveRecord,
59
+ ActiveStorage,
60
+ ActionDispatch,
61
+ ActionMailbox,
62
+ ActionMailer,
63
+ ActionText,
64
+ ActionView,
65
+ ].each do |rails_mod|
66
+ rails_mod.eager_load!
67
+ Orthoses::Utils.each_const_recursive(rails_mod, on_error: -> (e) {
68
+ Orthoses.logger.warn "skip load const by [#{e.root}][#{e.const}](#{e.error.class})#{e.error.message}"
69
+ })
70
+ v = rails_mod.respond_to?(:version) ? rails_mod.version : nil
71
+ puts "loaded #{rails_mod}: v#{v}"
72
+ end
73
+ Orthoses::Utils.unautoload!
74
+ }
75
+ Orthoses::Builder.new do
76
+ use Orthoses::CreateFileByName,
77
+ base_dir: "#{out_dir}/#{version}",
78
+ header: "# !!! GENERATED CODE !!!"
79
+ use Orthoses::AvoidRecursiveAncestorError
80
+ use Orthoses::Filter,
81
+ if: -> (name, content) {
82
+ # OMG, both ERB and Erb are exist...
83
+ return false if name.start_with?("Erb")
84
+
85
+ # ArgumentError
86
+ return false if name.start_with?("I18n::Tests")
87
+
88
+ # FIXME: too hard
89
+ return false if name.include?("::Generators")
90
+
91
+ # Ignore known sig
92
+ return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
93
+
94
+ true
95
+ }
96
+ use Orthoses::Constant,
97
+ strict: false,
98
+ if: -> (current, const, _val, _rbs) {
99
+ !Orthoses::Utils.rbs_defined_const?("#{current}::#{const}", collection: true)
100
+ },
101
+ on_error: -> (e) {
102
+ Orthoses.logger.warn "[Orthoses::Constant] skip load const by #{e.root}[::#{e.const}] (#{e.error.class}) #{e.error.message}"
103
+ }
104
+ Orthoses::ActiveSupport.each do |middleware, **args|
105
+ use middleware, **args
106
+ end
107
+ use Orthoses::ActiveRecord::QueryMethods
108
+ use Orthoses::ActiveRecord::KnownSig
109
+ use Orthoses::ActiveModel::KnownSig
110
+ use Orthoses::ObjectSpaceAll
111
+ use Orthoses::LoadRBS,
112
+ paths: Dir.glob('patch/**/*.rbs')
113
+ use Orthoses::LoadRBS,
114
+ paths: Dir.glob('known_sig/**/*.rbs')
115
+ # require in method
116
+ use Orthoses::Tap do |store|
117
+ store.delete("DummyERB")
118
+ store.delete("DummyCompiler")
119
+ end
120
+ # see activerecord/lib/active_record/migration/compatibility.rb
121
+ use Orthoses::Tap do |store|
122
+ # TODO: make middleware
123
+ if defined?(ActiveRecord::Migration::Compatibility::V7_0)
124
+ store["ActiveRecord::Migration::Compatibility::V6_1"].header = nil
125
+ store["ActiveRecord::Migration::Compatibility::V7_0"].header = "class ActiveRecord::Migration::Compatibility::V7_0 < ActiveRecord::Migration::Current"
126
+ elsif defined?(ActiveRecord::Migration::Compatibility::V6_1)
127
+ store["ActiveRecord::Migration::Compatibility::V6_0"].header = nil
128
+ store["ActiveRecord::Migration::Compatibility::V6_1"].header = "class ActiveRecord::Migration::Compatibility::V6_1 < ActiveRecord::Migration::Current"
129
+ elsif defined?(ActiveRecord::Migration::Compatibility::V6_0)
130
+ store["ActiveRecord::Migration::Compatibility::V5_2"].header = nil
131
+ store["ActiveRecord::Migration::Compatibility::V6_0"].header = "class ActiveRecord::Migration::Compatibility::V6_0 < ActiveRecord::Migration::Current"
132
+ end
133
+ end
134
+ # class_eval in #each
135
+ # see activerecord/lib/active_record/migration/command_recorder.rb
136
+ use Orthoses::Tap do |store|
137
+ content = store["ActiveRecord::Migration::CommandRecorder"]
138
+ ActiveRecord::Migration::CommandRecorder::ReversibleAndIrreversibleMethods.each do |method|
139
+ content << "def #{method}: (*untyped args) ?{ () -> void } -> untyped"
140
+ end
141
+ end
142
+ # class_eval in #each
143
+ # see activerecord/lib/active_record/migration/command_recorder.rb
144
+ use Orthoses::Tap do |store|
145
+ content = store["ActiveRecord::Migration::CommandRecorder::StraightReversions"]
146
+ {
147
+ execute_block: :execute_block,
148
+ create_table: :drop_table,
149
+ create_join_table: :drop_join_table,
150
+ add_column: :remove_column,
151
+ add_index: :remove_index,
152
+ add_timestamps: :remove_timestamps,
153
+ add_reference: :remove_reference,
154
+ add_foreign_key: :remove_foreign_key,
155
+ add_check_constraint: :remove_check_constraint,
156
+ enable_extension: :disable_extension
157
+ }.each do |cmd, inv|
158
+ [[inv, cmd], [cmd, inv]].uniq.each do |method, inverse|
159
+ content << "def invert_#{method}: (untyped args) ?{ () -> void } -> [Symbol, untyped, Proc]"
160
+ end
161
+ end
162
+ end
163
+ # singleton_class.class_eval in included
164
+ use Orthoses::Tap do |store|
165
+ store["ActiveRecord::ModelSchema"].body.tap do |body|
166
+ body.delete("alias _inheritance_column= inheritance_column=")
167
+ body.delete("alias inheritance_column= real_inheritance_column=")
168
+ end
169
+ end
170
+ # alias in included block
171
+ use Orthoses::Tap do |store|
172
+ store["ActiveRecord::ConnectionAdapters::ColumnMethods"].body.tap do |body|
173
+ body.delete("alias blob binary")
174
+ body.delete("alias numeric decimal")
175
+ end
176
+ end
177
+ # > Use async_exec instead of exec_params on pg versions before 1.1
178
+ use Orthoses::Tap do |store|
179
+ store["PG::Connection"].body.clear
180
+ end
181
+ # Entrust to auto super class
182
+ use Orthoses::Tap do |store|
183
+ store.each do |_, content|
184
+ if content.header&.include?(" < Type::")
185
+ content.header.sub!(/ < Type::(.*)/, " < ::ActiveModel::Type::\\1")
186
+ end
187
+ # delegate to auto_header
188
+ if content.header&.start_with?("class Arel")
189
+ content.header = nil
190
+ end
191
+ end
192
+ store["ActionView::Helpers::Tags::CollectionRadioButtons::RadioButtonBuilder"].header = nil
193
+ store["ActionView::Helpers::Tags::CollectionCheckBoxes::CheckBoxBuilder"].header = nil
194
+ store["ActionView::SyntaxErrorInTemplate"].header = nil
195
+ # MigrationProxy cannot resolve name since class alias.
196
+ store["ActiveRecord::NullMigration"].header = nil
197
+ end
198
+ use Orthoses::DelegateClass
199
+ use Orthoses::Attribute
200
+ use Orthoses::Mixin,
201
+ if: -> (base_mod, how, mod) {
202
+ mod != Enumerable # TODO
203
+ }
204
+ use Orthoses::RBSPrototypeRB,
205
+ paths: Dir.glob('src/{railties,action{cable,mailbox,mailer,pack,text,view},active{job,model,record,storage,support}}/lib/**/*.rb'),
206
+ constant_filter: -> (member) { false },
207
+ mixin_filter: -> (member) { false }
208
+ run loader
209
+ end.call
210
+
211
+ # $ cat out/7.0/**/*.rbs | wc
212
+ # 68367 333370 2555378
213
+ end
214
+
215
+ versions = %w[
216
+ 6.0
217
+ 6.1
218
+ 7.0
219
+ ]
220
+
221
+ task :clean do
222
+ FileUtils.rm_rf("out")
223
+ FileUtils.rm_rf("export")
224
+ end
225
+
226
+ namespace :generate do
227
+ versions.each do |version|
228
+ task version do
229
+ switch_branch("#{version.tr('.', '-')}-stable")
230
+ run_child_process { generate("out", version) }
231
+ end
232
+ end
233
+
234
+ desc "generate all library"
235
+ task :all => versions
236
+ end
237
+
238
+ namespace :export do
239
+ versions.each do |version|
240
+ task version do |t|
241
+ export = "export/activesupport/#{version}"
242
+
243
+ sh "rm -fr #{export}"
244
+ sh "mkdir -p #{export}"
245
+
246
+ # minimum
247
+ sh "cp -a out/#{version}/active_support.rbs #{export}"
248
+ sh "cp -a out/#{version}/active_support #{export}"
249
+ sh "rm #{export}/active_support/railtie.rbs"
250
+
251
+ # core_ext
252
+ %w[
253
+ array benchmark big_decimal class date date_and_time date_time digest
254
+ enumerable file hash integer kernel load_error marshal module name_error numeric
255
+ object pathname range regexp securerandom string symbol time uri
256
+ ].each do |lib|
257
+ out = "out/#{version}/#{lib}"
258
+ sh "cp -a #{out} #{export}" if File.exist?(out)
259
+ sh "cp -a #{out}.rbs #{export}" if File.exist?("#{out}.rbs")
260
+ end
261
+
262
+ Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
263
+ module Minitest
264
+ class Test
265
+ def name: () -> untyped
266
+ def assert_raises: () -> untyped
267
+ def refute_empty: () -> untyped
268
+ def refute_equal: () -> untyped
269
+ def refute_in_delta: () -> untyped
270
+ def refute_in_epsilon: () -> untyped
271
+ def refute_includes: () -> untyped
272
+ def refute_instance_of: () -> untyped
273
+ def refute_kind_of: () -> untyped
274
+ def refute_match: () -> untyped
275
+ def refute_nil: () -> untyped
276
+ def refute_operator: () -> untyped
277
+ def refute_predicate: () -> untyped
278
+ def refute_respond_to: () -> untyped
279
+ def refute_same: () -> untyped
280
+ end
281
+ end
282
+ module DRb
283
+ module DRbUndumped
284
+ end
285
+ end
286
+ module Concurrent
287
+ class Map
288
+ end
289
+ end
290
+ RBS
291
+
292
+ case version
293
+ when "6.0", "6.1"
294
+ sh "rm -fr #{export}/uri"
295
+ when "7.0"
296
+ # deprecated
297
+ sh "rm -fr #{export}/uri{,.rbs}"
298
+ end
299
+
300
+ Pathname(export).join('_scripts').tap(&:mkdir).join('test').write(<<~'RUBY')
301
+ #!/usr/bin/env bash
302
+
303
+ # set -eou => Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
304
+ set -eou pipefail
305
+ # Internal Field Separator - Linux shell variable
306
+ IFS=$'\n\t'
307
+ # Print shell input lines
308
+ set -v
309
+
310
+ # Set RBS_DIR variable to change directory to execute type checks using `steep check`
311
+ RBS_DIR=$(cd $(dirname $0)/..; pwd)
312
+ # Set REPO_DIR variable to validate RBS files added to the corresponding folder
313
+ REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
314
+ # Validate RBS files, using the bundler environment present
315
+ bundle exec rbs --repo=$REPO_DIR \
316
+ -r digest -r benchmark -r time -r monitor -r date -r singleton \
317
+ -r logger -r mutex_m -r pathname -r json \
318
+ -r nokogiri \
319
+ -r activesupport validate --silent
320
+
321
+ cd ${RBS_DIR}/_test
322
+ # Run type checks
323
+ bundle exec steep check
324
+ RUBY
325
+ sh "chmod +x #{Pathname(export).join('_scripts').join('test')}"
326
+ Pathname(export).join('_test').tap(&:mkdir).join('Steepfile').write(<<~RUBY)
327
+ D = Steep::Diagnostic
328
+
329
+ target :test do
330
+ signature "."
331
+ check "."
332
+
333
+ repo_path "../../../"
334
+
335
+ library "benchmark"
336
+ library "date"
337
+ library "digest"
338
+ library "json"
339
+ library "logger"
340
+ library "monitor"
341
+ library "mutex_m"
342
+ library "pathname"
343
+ library "singleton"
344
+ library "time"
345
+
346
+ library "nokogiri"
347
+
348
+ library "activesupport:#{version}"
349
+
350
+ configure_code_diagnostics(D::Ruby.all_error)
351
+ end
352
+ RUBY
353
+ Pathname(export).join('_test').join('test.rb').write(<<~'RUBY')
354
+ require 'active_support/all'
355
+
356
+ # Test ActiveSupport::NumericWithFormat
357
+ 42.to_s
358
+ 42.to_s(:phone)
359
+ RUBY
360
+
361
+ sh "rbs --collection ../../rbs_collection.yaml -I #{export} validate --silent"
362
+ end
363
+ end
364
+
365
+ desc "export all library"
366
+ task :all => versions
367
+ end
368
+
369
+ task default: [
370
+ :clean,
371
+ 'generate:all',
372
+ 'export:all',
373
+ ]
@@ -0,0 +1,2 @@
1
+ class ActionCable::Connection::TestCookieJar < ActiveSupport::HashWithIndifferentAccess[untyped, untyped]
2
+ end
@@ -0,0 +1,4 @@
1
+ class ActionController::Metal < ::AbstractController::Base
2
+ @_request: ::ActionDispatch::Request
3
+ @_response: ::ActionDispatch::Response
4
+ end
@@ -0,0 +1,3 @@
1
+ class ActionDispatch::Cookies::CookieJar
2
+ def to_h: () -> Hash[untyped, untyped]
3
+ end
@@ -0,0 +1,4 @@
1
+ class ActionDispatch::Response
2
+ # The HTTP status code.
3
+ attr_reader status: Integer
4
+ end
@@ -0,0 +1,2 @@
1
+ module DRb::DRbUndumped
2
+ end
@@ -0,0 +1,2 @@
1
+ module DRb
2
+ end
@@ -0,0 +1,4 @@
1
+ module Erubi
2
+ class Engine
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module Erubi
2
+ end
@@ -0,0 +1,44 @@
1
+ %a{annotate:rdoc:skip}
2
+ module Kernel : ::BasicObject
3
+ private
4
+
5
+ # <!--
6
+ # rdoc-file=lib/minitest/spec.rb
7
+ # - describe(desc, *additional_desc, &block)
8
+ # -->
9
+ # Describe a series of expectations for a given target `desc`.
10
+ #
11
+ # Defines a test class subclassing from either Minitest::Spec or from the
12
+ # surrounding describe's class. The surrounding class may subclass
13
+ # Minitest::Spec manually in order to easily share code:
14
+ #
15
+ # class MySpec < Minitest::Spec
16
+ # # ... shared code ...
17
+ # end
18
+ #
19
+ # class TestStuff < MySpec
20
+ # it "does stuff" do
21
+ # # shared code available here
22
+ # end
23
+ # describe "inner stuff" do
24
+ # it "still does stuff" do
25
+ # # ...and here
26
+ # end
27
+ # end
28
+ # end
29
+ #
30
+ # For more information on getting started with writing specs, see:
31
+ #
32
+ # http://www.rubyinside.com/a-minitestspec-tutorial-elegant-spec-style-testing-t
33
+ # hat-comes-with-ruby-5354.html
34
+ #
35
+ # For some suggestions on how to improve your specs, try:
36
+ #
37
+ # http://betterspecs.org
38
+ #
39
+ # but do note that several items there are debatable or specific to rspec.
40
+ #
41
+ # For more information about expectations, see Minitest::Expectations.
42
+ #
43
+ def describe: (untyped desc, *untyped additional_desc) { () -> untyped } -> untyped
44
+ end
@@ -0,0 +1,49 @@
1
+ # <!-- rdoc-file=lib/minitest.rb -->
2
+ # Defines the API for Reporters. Subclass this and override whatever you want.
3
+ # Go nuts.
4
+ #
5
+ class Minitest::AbstractReporter
6
+ # <!--
7
+ # rdoc-file=lib/minitest.rb
8
+ # - start()
9
+ # -->
10
+ # Starts reporting on the run.
11
+ #
12
+ def start: () -> nil
13
+
14
+ # <!--
15
+ # rdoc-file=lib/minitest.rb
16
+ # - prerecord(klass, name)
17
+ # -->
18
+ # About to start running a test. This allows a reporter to show that it is
19
+ # starting or that we are in the middle of a test run.
20
+ #
21
+ def prerecord: (untyped klass, untyped name) -> nil
22
+
23
+ # <!--
24
+ # rdoc-file=lib/minitest.rb
25
+ # - record(result)
26
+ # -->
27
+ # Output and record the result of the test. Call
28
+ # [result#result_code](rdoc-ref:Runnable#result_code) to get the result
29
+ # character string. Stores the result of the run if the run did not pass.
30
+ #
31
+ def record: (untyped result) -> nil
32
+
33
+ # <!--
34
+ # rdoc-file=lib/minitest.rb
35
+ # - report()
36
+ # -->
37
+ # Outputs the summary of the run.
38
+ #
39
+ def report: () -> nil
40
+
41
+ # <!--
42
+ # rdoc-file=lib/minitest.rb
43
+ # - passed?()
44
+ # -->
45
+ # Did this run pass?
46
+ #
47
+ def passed?: () -> true
48
+ include Mutex_m
49
+ end
@@ -0,0 +1,16 @@
1
+ # <!-- rdoc-file=lib/minitest.rb -->
2
+ # Represents run failures.
3
+ #
4
+ class Minitest::Assertion < ::Exception
5
+ def error: () -> self
6
+
7
+ # <!--
8
+ # rdoc-file=lib/minitest.rb
9
+ # - location()
10
+ # -->
11
+ # Where was this run before an assertion was raised?
12
+ #
13
+ def location: () -> untyped
14
+ def result_code: () -> untyped
15
+ def result_label: () -> "Failure"
16
+ end