orthoses-rails 0.4.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -39
  3. data/examples/rails/Gemfile +16 -0
  4. data/examples/rails/Gemfile.lock +178 -0
  5. data/examples/rails/Rakefile +149 -193
  6. data/examples/rails/config/database.yml +8 -0
  7. data/examples/rails/config/storage.yml +3 -0
  8. data/examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs +4 -0
  9. data/{lib/orthoses/active_model/known_sig/7.0 → examples/rails/known_sig/activemodel/7.0/active_model}/serialization.rbs +0 -0
  10. data/{lib/orthoses/active_model/known_sig/7.0 → examples/rails/known_sig/activemodel/7.0/active_model}/validations.rbs +0 -0
  11. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs +49 -0
  12. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs +45 -0
  13. data/{lib/orthoses/active_record/known_sig/6.0 → examples/rails/known_sig/activerecord/6.0/active_record}/result.rbs +0 -0
  14. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs +49 -0
  15. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs +45 -0
  16. data/{lib/orthoses/active_record/known_sig/6.1 → examples/rails/known_sig/activerecord/6.1/active_record}/result.rbs +0 -0
  17. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs +49 -0
  18. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs +45 -0
  19. data/{lib/orthoses/active_record/known_sig/7.0 → examples/rails/known_sig/activerecord/7.0/active_record}/encryption/context.rbs +0 -0
  20. data/{lib/orthoses/active_record/known_sig/7.0 → examples/rails/known_sig/activerecord/7.0/active_record}/result.rbs +0 -0
  21. data/{lib/orthoses/active_support/known_sig → examples/rails/known_sig/activesupport}/7.0/active_support/callbacks/callback_chain.rbs +0 -0
  22. data/examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs +4 -0
  23. data/{lib/orthoses/active_support/known_sig → examples/rails/known_sig/activesupport}/7.0/active_support/hash_with_indifferent_access.rbs +0 -0
  24. data/{lib/orthoses/active_support/known_sig → examples/rails/known_sig/activesupport}/7.0/active_support/multibyte/chars.rbs +0 -0
  25. data/examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs +5 -0
  26. data/examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs +3 -0
  27. data/examples/rails/known_sig/activesupport/7.0/date.rbs +6 -0
  28. data/examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs +4 -0
  29. data/{lib/orthoses/active_support/known_sig → examples/rails/known_sig/activesupport}/7.0/hash_with_indifferent_access.rbs +0 -0
  30. data/examples/rails/known_sig/activesupport/7.0/integer.rbs +9 -0
  31. data/examples/rails/known_sig/activesupport/7.0/numeric.rbs +15 -0
  32. data/examples/rails/known_sig/activesupport/7.0/string.rbs +4 -0
  33. data/{lib/orthoses/active_support/known_sig → examples/rails/known_sig/activesupport}/7.0/time.rbs +8 -0
  34. data/examples/rails/tasks/action_pack.rake +141 -0
  35. data/examples/rails/tasks/action_view.rake +77 -0
  36. data/examples/rails/tasks/active_job.rake +99 -0
  37. data/examples/rails/tasks/active_model.rake +46 -0
  38. data/examples/rails/tasks/active_record.rake +88 -0
  39. data/examples/rails/tasks/active_storage.rake +94 -0
  40. data/examples/rails/tasks/active_support.rake +99 -0
  41. data/examples/rails/tasks/railties.rake +37 -0
  42. data/lib/orthoses/active_model/has_secure_password.rb +2 -10
  43. data/lib/orthoses/active_model.rb +0 -1
  44. data/lib/orthoses/active_record/delegated_type.rb +44 -0
  45. data/lib/orthoses/active_record/enum.rb +77 -0
  46. data/lib/orthoses/active_record/generated_attribute_methods.rb +1 -0
  47. data/lib/orthoses/active_record/scope.rb +63 -0
  48. data/lib/orthoses/active_record.rb +3 -1
  49. data/lib/orthoses/active_support/class_attribute.rb +3 -10
  50. data/lib/orthoses/active_support/configurable.rb +3 -2
  51. data/lib/orthoses/active_support/delegation.rb +11 -19
  52. data/lib/orthoses/active_support/mattr_accessor.rb +4 -12
  53. data/lib/orthoses/active_support/time_with_zone.rb +21 -3
  54. data/lib/orthoses/active_support.rb +0 -17
  55. data/lib/orthoses/rails/version.rb +1 -1
  56. data/lib/orthoses/rails.rb +1 -1
  57. data/lib/orthoses/railties/mixin.rb +107 -0
  58. data/lib/orthoses/railties.rb +3 -0
  59. data/orthoses-rails.gemspec +1 -1
  60. metadata +48 -89
  61. data/examples/rails/known_sig/action_cable/connection/test_cookie_jar.rbs +0 -2
  62. data/examples/rails/known_sig/action_controller/metal.rbs +0 -4
  63. data/examples/rails/known_sig/action_dispatch/cookies/cookie_jar.rbs +0 -3
  64. data/examples/rails/known_sig/action_dispatch/response.rbs +0 -4
  65. data/examples/rails/patch/drb/drb_undumped.rbs +0 -2
  66. data/examples/rails/patch/drb.rbs +0 -2
  67. data/examples/rails/patch/erubi/engine.rbs +0 -4
  68. data/examples/rails/patch/erubi.rbs +0 -2
  69. data/examples/rails/patch/minitest/kernel.rbs +0 -44
  70. data/examples/rails/patch/minitest/minitest/abstract_reporter.rbs +0 -49
  71. data/examples/rails/patch/minitest/minitest/assertion.rbs +0 -16
  72. data/examples/rails/patch/minitest/minitest/assertions.rbs +0 -545
  73. data/examples/rails/patch/minitest/minitest/backtrace_filter.rbs +0 -16
  74. data/examples/rails/patch/minitest/minitest/bench_spec.rbs +0 -101
  75. data/examples/rails/patch/minitest/minitest/benchmark.rbs +0 -258
  76. data/examples/rails/patch/minitest/minitest/composite_reporter.rbs +0 -25
  77. data/examples/rails/patch/minitest/minitest/expectations.rbs +0 -21
  78. data/examples/rails/patch/minitest/minitest/guard.rbs +0 -64
  79. data/examples/rails/patch/minitest/minitest/mock.rbs +0 -60
  80. data/examples/rails/patch/minitest/minitest/parallel/executor.rbs +0 -42
  81. data/examples/rails/patch/minitest/minitest/parallel/test/class_methods.rbs +0 -6
  82. data/examples/rails/patch/minitest/minitest/parallel/test.rbs +0 -3
  83. data/examples/rails/patch/minitest/minitest/parallel.rbs +0 -2
  84. data/examples/rails/patch/minitest/minitest/pride_io.rbs +0 -54
  85. data/examples/rails/patch/minitest/minitest/pride_lol.rbs +0 -17
  86. data/examples/rails/patch/minitest/minitest/progress_reporter.rbs +0 -11
  87. data/examples/rails/patch/minitest/minitest/reportable.rbs +0 -51
  88. data/examples/rails/patch/minitest/minitest/reporter.rbs +0 -5
  89. data/examples/rails/patch/minitest/minitest/result.rbs +0 -28
  90. data/examples/rails/patch/minitest/minitest/runnable.rbs +0 -131
  91. data/examples/rails/patch/minitest/minitest/skip.rbs +0 -6
  92. data/examples/rails/patch/minitest/minitest/spec/dsl/instance_methods.rbs +0 -48
  93. data/examples/rails/patch/minitest/minitest/spec/dsl.rbs +0 -125
  94. data/examples/rails/patch/minitest/minitest/spec.rbs +0 -10
  95. data/examples/rails/patch/minitest/minitest/statistics_reporter.rbs +0 -76
  96. data/examples/rails/patch/minitest/minitest/summary_reporter.rbs +0 -26
  97. data/examples/rails/patch/minitest/minitest/test/lifecycle_hooks.rbs +0 -92
  98. data/examples/rails/patch/minitest/minitest/test.rbs +0 -76
  99. data/examples/rails/patch/minitest/minitest/unexpected_error.rbs +0 -10
  100. data/examples/rails/patch/minitest/minitest/unit/test_case.rbs +0 -3
  101. data/examples/rails/patch/minitest/minitest/unit.rbs +0 -5
  102. data/examples/rails/patch/minitest/minitest.rbs +0 -966
  103. data/examples/rails/patch/pg/simple_decoder.rbs +0 -4
  104. data/examples/rails/patch/pg.rbs +0 -2
  105. data/examples/rails/patch/qc/queue.rbs +0 -2
  106. data/examples/rails/patch/qc.rbs +0 -2
  107. data/examples/rails/patch/que/job.rbs +0 -2
  108. data/examples/rails/patch/que.rbs +0 -2
  109. data/examples/rails/patch/rack/cache/entity_store.rbs +0 -2
  110. data/examples/rails/patch/rack/cache/meta_store.rbs +0 -2
  111. data/examples/rails/patch/rack/cache.rbs +0 -2
  112. data/examples/rails/patch/rack/session/dalli.rbs +0 -2
  113. data/examples/rails/patch/rack/session.rbs +0 -2
  114. data/examples/rails/patch/rboc.rbs +0 -2
  115. data/examples/rails/patch/rdoc/generator/sdoc.rbs +0 -3
  116. data/examples/rails/patch/rdoc/generator.rbs +0 -2
  117. data/examples/rails/patch/rdoc/task.rbs +0 -2
  118. data/examples/rails/patch/ripper.rbs +0 -2
  119. data/examples/rails/patch/sidekiq/worker.rbs +0 -2
  120. data/examples/rails/patch/sidekiq.rbs +0 -2
  121. data/examples/rails/patch/sneakers/worker.rbs +0 -2
  122. data/examples/rails/patch/sneakers.rbs +0 -2
  123. data/examples/rails/patch/sucker_punch/job.rbs +0 -2
  124. data/examples/rails/patch/sucker_punch.rbs +0 -2
  125. data/examples/rails/patch/thor/actions/create_file.rbs +0 -2
  126. data/examples/rails/patch/thor/actions.rbs +0 -2
  127. data/examples/rails/patch/thor/error.rbs +0 -2
  128. data/examples/rails/patch/thor/group.rbs +0 -2
  129. data/examples/rails/patch/thor.rbs +0 -2
  130. data/lib/orthoses/active_model/known_sig.rb +0 -21
  131. data/lib/orthoses/active_record/known_sig.rb +0 -21
  132. data/lib/orthoses/active_support/known_sig.rb +0 -21
  133. data/lib/orthoses/rails/known_sig_helper.rb +0 -22
@@ -1,68 +1,50 @@
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
1
+ ## run `$ rake`
31
2
 
32
3
  def switch_branch(name)
33
- cd "src" do
4
+ cd "_src" do
34
5
  sh "git switch #{name}"
35
6
  end
36
7
  end
37
8
 
38
9
  def generate(out_dir, version)
10
+ require 'orthoses'
11
+ require 'orthoses-rails'
12
+ require 'openssl'
13
+ require 'cgi'
14
+ require 'uri'
15
+
16
+ Orthoses.logger.level = :error
17
+
39
18
  loader = -> () {
40
- # require "rails/all"
41
- require "rails/app_updater"
42
19
  require "active_support/all"
43
20
  require "active_record"
44
21
  require "active_job"
45
22
  require "active_model"
46
- require "active_storage"
23
+ require "active_storage/engine"
47
24
  require "action_dispatch"
48
- require "action_mailbox"
25
+ begin
26
+ require "action_mailbox"
27
+ require "action_text"
28
+ rescue LoadError
29
+ end
49
30
  require "action_mailer"
50
31
  require "action_pack"
51
- require "action_text"
52
32
  require "action_view"
53
33
 
54
- [
34
+ roots = [
55
35
  ActiveSupport,
56
36
  ActiveModel,
57
37
  ActiveJob,
58
38
  ActiveRecord,
59
39
  ActiveStorage,
60
40
  ActionDispatch,
61
- ActionMailbox,
62
41
  ActionMailer,
63
- ActionText,
64
42
  ActionView,
65
- ].each do |rails_mod|
43
+ ]
44
+ roots << ActionMailbox if defined?(ActionMailbox)
45
+ roots << ActionText if defined?(ActionText)
46
+
47
+ roots.each do |rails_mod|
66
48
  rails_mod.eager_load!
67
49
  Orthoses::Utils.each_const_recursive(rails_mod, on_error: -> (e) {
68
50
  Orthoses.logger.warn "skip load const by [#{e.root}][#{e.const}](#{e.error.class})#{e.error.message}"
@@ -70,13 +52,21 @@ def generate(out_dir, version)
70
52
  v = rails_mod.respond_to?(:version) ? rails_mod.version : nil
71
53
  puts "loaded #{rails_mod}: v#{v}"
72
54
  end
73
- Orthoses::Utils.unautoload!
55
+ eval(<<~RUBY)
56
+ module Dummy
57
+ class Application < Rails::Application
58
+ config.load_defaults #{version.to_s}
59
+ config.active_storage.service = :local
60
+ end
61
+ end
62
+ RUBY
63
+ ENV['RAILS_ENV'] = 'development'
64
+ Rails.application.initialize!
74
65
  }
75
66
  Orthoses::Builder.new do
76
67
  use Orthoses::CreateFileByName,
77
68
  base_dir: "#{out_dir}/#{version}",
78
- header: "# !!! GENERATED CODE !!!"
79
- use Orthoses::AvoidRecursiveAncestorError
69
+ header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
80
70
  use Orthoses::Filter,
81
71
  if: -> (name, content) {
82
72
  # OMG, both ERB and Erb are exist...
@@ -101,18 +91,18 @@ def generate(out_dir, version)
101
91
  on_error: -> (e) {
102
92
  Orthoses.logger.warn "[Orthoses::Constant] skip load const by #{e.root}[::#{e.const}] (#{e.error.class}) #{e.error.message}"
103
93
  }
104
- Orthoses::ActiveSupport.each do |middleware, **args|
105
- use middleware, **args
106
- end
94
+ use Orthoses::ActiveSupport::ClassAttribute
95
+ use Orthoses::ActiveSupport::Delegation
96
+ use Orthoses::ActiveSupport::MattrAccessor
97
+ use Orthoses::ActiveSupport::TimeWithZone
107
98
  use Orthoses::ActiveRecord::QueryMethods
108
- use Orthoses::ActiveRecord::KnownSig
109
- use Orthoses::ActiveModel::KnownSig
110
- use Orthoses::ObjectSpaceAll
111
99
  use Orthoses::LoadRBS,
112
- paths: Dir.glob('patch/**/*.rbs')
100
+ paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveRecord::VERSION::STRING, "known_sig/activerecord") }
113
101
  use Orthoses::LoadRBS,
114
- paths: Dir.glob('known_sig/**/*.rbs')
115
- # require in method
102
+ paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveModel::VERSION::STRING, "known_sig/activemodel") }
103
+ use Orthoses::LoadRBS,
104
+ paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveSupport::VERSION::STRING, "known_sig/activesupport") }
105
+ # # require in method
116
106
  use Orthoses::Tap do |store|
117
107
  store.delete("DummyERB")
118
108
  store.delete("DummyCompiler")
@@ -129,6 +119,9 @@ def generate(out_dir, version)
129
119
  elsif defined?(ActiveRecord::Migration::Compatibility::V6_0)
130
120
  store["ActiveRecord::Migration::Compatibility::V5_2"].header = nil
131
121
  store["ActiveRecord::Migration::Compatibility::V6_0"].header = "class ActiveRecord::Migration::Compatibility::V6_0 < ActiveRecord::Migration::Current"
122
+ elsif defined?(ActiveRecord::Migration::Compatibility::V5_2)
123
+ store["ActiveRecord::Migration::Compatibility::V5_1"].header = nil
124
+ store["ActiveRecord::Migration::Compatibility::V5_2"].header = "class ActiveRecord::Migration::Compatibility::V5_2 < ActiveRecord::Migration::Current"
132
125
  end
133
126
  end
134
127
  # class_eval in #each
@@ -197,177 +190,140 @@ def generate(out_dir, version)
197
190
  end
198
191
  use Orthoses::DelegateClass
199
192
  use Orthoses::Attribute
193
+ use Orthoses::Railties::Mixin, callback: -> (railties_mixin) {
194
+ Orthoses::CreateFileByName.new(
195
+ ->{ railties_mixin },
196
+ base_dir: "#{out_dir}/#{version}/railties_mixin",
197
+ header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
198
+ ).call
199
+ }
200
200
  use Orthoses::Mixin,
201
201
  if: -> (base_mod, how, mod) {
202
202
  mod != Enumerable # TODO
203
203
  }
204
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'),
205
+ paths: Dir.glob('_src/{railties,action{cable,mailbox,mailer,pack,text,view},active{job,model,record,storage,support}}/{app,lib}/**/*.rb'),
206
206
  constant_filter: -> (member) { false },
207
- mixin_filter: -> (member) { false }
207
+ mixin_filter: -> (member) { false },
208
+ attribute_filter: -> (member) { false }
209
+ use Orthoses::Autoload
208
210
  run loader
209
211
  end.call
210
212
 
211
213
  # $ cat out/7.0/**/*.rbs | wc
212
- # 68367 333370 2555378
214
+ # 69763 339342 2606899
213
215
  end
214
216
 
215
- versions = %w[
217
+ def generate_test_script(gem:, version:, export:, stdlib_dependencies:, gem_dependencies:, rails_dependencies:)
218
+ Pathname(export).join('_scripts').tap(&:mkdir).join('test').write(<<~SHELL)
219
+ #!/usr/bin/env bash
220
+
221
+ # !!! GENERATED CODE !!!
222
+ # Please see generators/rails-generator
223
+
224
+ # set -eou => Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
225
+ set -eou pipefail
226
+ # Internal Field Separator - Linux shell variable
227
+ IFS=$'\n\t'
228
+ # Print shell input lines
229
+ set -v
230
+
231
+ # Set RBS_DIR variable to change directory to execute type checks using `steep check`
232
+ RBS_DIR=$(cd $(dirname $0)/..; pwd)
233
+ # Set REPO_DIR variable to validate RBS files added to the corresponding folder
234
+ REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
235
+ # Validate RBS files, using the bundler environment present
236
+ bundle exec rbs --repo=$REPO_DIR #{stdlib_dependencies.map{"-r #{_1}"}.join(" ")} \\
237
+ #{gem_dependencies.map{"-r #{_1}"}.join(" ")} \\
238
+ -r #{gem} validate --silent
239
+
240
+ cd ${RBS_DIR}/_test
241
+ # Run type checks
242
+ bundle exec steep check
243
+ SHELL
244
+
245
+ sh "chmod +x #{Pathname(export).join('_scripts').join('test')}"
246
+
247
+ Pathname(export).join('_test').tap(&:mkdir).join('Steepfile').write(<<~RUBY)
248
+ # !!! GENERATED CODE !!!
249
+ # Please see generators/rails-generator
250
+
251
+ D = Steep::Diagnostic
252
+
253
+ target :test do
254
+ signature "."
255
+ check "."
256
+
257
+ repo_path "../../../"
258
+
259
+ #{stdlib_dependencies.map{" library \"#{_1}\""}.join("\n")}
260
+ #{gem_dependencies.map{" library \"#{_1}\""}.join("\n")}
261
+
262
+ library "#{gem}:#{version}"
263
+
264
+ configure_code_diagnostics(D::Ruby.all_error)
265
+ end
266
+ RUBY
267
+ end
268
+
269
+ def generate_manifest(export:, stdlib_dependencies:)
270
+ Pathname(export).join('manifest.yaml').write(<<~YAML)
271
+ dependencies:
272
+ #{stdlib_dependencies.map{"- name: #{_1}"}.join("\n ")}
273
+ YAML
274
+ end
275
+
276
+ VERSIONS = %w[
216
277
  6.0
217
278
  6.1
218
279
  7.0
219
280
  ]
281
+ Object.private_constant :VERSIONS
282
+
283
+ tasks = Dir["tasks/*"]
284
+ tasks.each do |task|
285
+ load task
286
+ end
287
+ GEMS = tasks.map { File.basename(_1).sub(/\.rake/, '') }
288
+ Object.private_constant :GEMS
220
289
 
221
290
  task :clean do
222
291
  FileUtils.rm_rf("out")
223
- FileUtils.rm_rf("export")
224
292
  end
225
293
 
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
294
+ VERSIONS.each do |version|
295
+ namespace version do
296
+ desc "run all version=#{version}"
297
+ task :all => [
298
+ :generate,
299
+ :export,
300
+ :validate,
301
+ # :install,
302
+ ]
233
303
 
234
- desc "generate all library"
235
- task :all => versions
236
- end
304
+ desc "run export version=#{version}"
305
+ task :export => GEMS.map{"#{version}:#{_1}:export"}
237
306
 
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
307
+ desc "run validate version=#{version}"
308
+ task :validate => GEMS.map{"#{version}:#{_1}:validate"}
299
309
 
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'
310
+ desc "run install version=#{version}"
311
+ task :install => GEMS.map{"#{version}:#{_1}:install"}
355
312
 
356
- # Test ActiveSupport::NumericWithFormat
357
- 42.to_s
358
- 42.to_s(:phone)
359
- RUBY
313
+ desc "generate version=#{version}"
314
+ task :generate do |t|
315
+ switch_branch("#{version.tr('.', '-')}-stable")
316
+ sh "bundle install"
317
+ sh "bundle exec rake #{t.name}_exec"
318
+ end
360
319
 
361
- sh "rbs --collection ../../rbs_collection.yaml -I #{export} validate --silent"
320
+ task :generate_exec do
321
+ generate("out", version)
362
322
  end
363
323
  end
364
-
365
- desc "export all library"
366
- task :all => versions
367
324
  end
368
325
 
369
326
  task default: [
370
327
  :clean,
371
- 'generate:all',
372
- 'export:all',
328
+ *(VERSIONS.map {"#{_1}:all"})
373
329
  ]
@@ -0,0 +1,8 @@
1
+ development:
2
+ primary: &primary
3
+ adapter: sqlite3
4
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
5
+ timeout: 5000
6
+ database: ':memory:'
7
+ replica:
8
+ <<: *primary
@@ -0,0 +1,3 @@
1
+ local:
2
+ service: Disk
3
+ root: <%= Rails.root.join("storage") %>
@@ -0,0 +1,4 @@
1
+ module ActionController
2
+ class Metal < AbstractController::Base
3
+ end
4
+ end
@@ -0,0 +1,49 @@
1
+ interface _ActiveRecord_Relation[Model, PrimaryKey]
2
+ def all: () -> self
3
+ def ids: () -> Array[PrimaryKey]
4
+ def none: () -> self
5
+ def pluck: (Symbol | String column) -> Array[untyped]
6
+ | (*Symbol | String columns) -> Array[Array[untyped]]
7
+ def where: (*untyped) -> self
8
+ def not: (*untyped) -> self
9
+ def exists?: (*untyped) -> bool
10
+ def order: (*untyped) -> self
11
+ def group: (*Symbol | String) -> untyped
12
+ def distinct: () -> self
13
+ def or: (self) -> self
14
+ def merge: (self) -> self
15
+ def joins: (*String | Symbol) -> self
16
+ | (Hash[untyped, untyped]) -> self
17
+ def left_joins: (*String | Symbol) -> self
18
+ | (Hash[untyped, untyped]) -> self
19
+ def left_outer_joins: (*String | Symbol) -> self
20
+ | (Hash[untyped, untyped]) -> self
21
+ def includes: (*String | Symbol) -> self
22
+ | (Hash[untyped, untyped]) -> self
23
+ def eager_load: (*String | Symbol) -> self
24
+ | (Hash[untyped, untyped]) -> self
25
+ def preload: (*String | Symbol) -> self
26
+ | (Hash[untyped, untyped]) -> self
27
+ def find_by: (*untyped) -> Model?
28
+ def find_by!: (*untyped) -> Model
29
+ def find: (PrimaryKey id) -> Model
30
+ | (Array[PrimaryKey]) -> Array[Model]
31
+ | (*PrimaryKey) -> Array[Model]
32
+ | () { (Model) -> boolish } -> Model?
33
+ def first: () -> Model?
34
+ | (Integer count) -> Array[Model]
35
+ def first!: () -> Model
36
+ def last: () -> Model?
37
+ | (Integer count) -> Array[Model]
38
+ def last!: () -> Model
39
+ def limit: (Integer | Arel::Nodes::SqlLiteral | nil) -> self
40
+ def limit!: (Integer | Arel::Nodes::SqlLiteral | nil) -> self
41
+ def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
42
+ def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
43
+ def destroy_all: () -> untyped
44
+ def delete_all: () -> untyped
45
+ def update_all: (*untyped) -> untyped
46
+ def each: () { (Model) -> void } -> self
47
+ def select: (*Symbol | String) -> self
48
+ | () { (Model) -> boolish } -> Array[Model]
49
+ end
@@ -0,0 +1,45 @@
1
+ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
2
+ def all: () -> Relation
3
+ def ids: () -> Array[PrimaryKey]
4
+ def none: () -> Relation
5
+ def pluck: (Symbol | String column) -> Array[untyped]
6
+ | (*Symbol | String columns) -> Array[Array[untyped]]
7
+ def where: (*untyped) -> Relation
8
+ def exists?: (*untyped) -> bool
9
+ def order: (*untyped) -> Relation
10
+ def group: (*Symbol | String) -> untyped
11
+ def distinct: () -> self
12
+ def or: (Relation) -> Relation
13
+ def merge: (Relation) -> Relation
14
+ def joins: (*String | Symbol) -> self
15
+ | (Hash[untyped, untyped]) -> self
16
+ def left_joins: (*String | Symbol) -> self
17
+ | (Hash[untyped, untyped]) -> self
18
+ def left_outer_joins: (*String | Symbol) -> self
19
+ | (Hash[untyped, untyped]) -> self
20
+ def includes: (*String | Symbol) -> self
21
+ | (Hash[untyped, untyped]) -> self
22
+ def eager_load: (*String | Symbol) -> self
23
+ | (Hash[untyped, untyped]) -> self
24
+ def preload: (*String | Symbol) -> self
25
+ | (Hash[untyped, untyped]) -> self
26
+ def find_by: (*untyped) -> Model?
27
+ def find_by!: (*untyped) -> Model
28
+ def find: (PrimaryKey id) -> Model
29
+ | (Array[PrimaryKey]) -> Array[Model]
30
+ | (*PrimaryKey) -> Array[Model]
31
+ def first: () -> Model?
32
+ | (Integer count) -> Array[Model]
33
+ def first!: () -> Model
34
+ def last: () -> Model?
35
+ | (Integer count) -> Array[Model]
36
+ def last!: () -> Model
37
+ def limit: (Integer | Arel::Nodes::SqlLiteral | nil) -> Relation
38
+ def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
39
+ def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
40
+ def destroy_all: () -> untyped
41
+ def delete_all: () -> untyped
42
+ def update_all: (*untyped) -> untyped
43
+ def select: (*Symbol | String) -> Relation
44
+ | () { (Model) -> boolish } -> Array[Model]
45
+ end
@@ -0,0 +1,49 @@
1
+ interface _ActiveRecord_Relation[Model, PrimaryKey]
2
+ def all: () -> self
3
+ def ids: () -> Array[PrimaryKey]
4
+ def none: () -> self
5
+ def pluck: (Symbol | String column) -> Array[untyped]
6
+ | (*Symbol | String columns) -> Array[Array[untyped]]
7
+ def where: (*untyped) -> self
8
+ def not: (*untyped) -> self
9
+ def exists?: (*untyped) -> bool
10
+ def order: (*untyped) -> self
11
+ def group: (*Symbol | String) -> untyped
12
+ def distinct: () -> self
13
+ def or: (self) -> self
14
+ def merge: (self) -> self
15
+ def joins: (*String | Symbol) -> self
16
+ | (Hash[untyped, untyped]) -> self
17
+ def left_joins: (*String | Symbol) -> self
18
+ | (Hash[untyped, untyped]) -> self
19
+ def left_outer_joins: (*String | Symbol) -> self
20
+ | (Hash[untyped, untyped]) -> self
21
+ def includes: (*String | Symbol) -> self
22
+ | (Hash[untyped, untyped]) -> self
23
+ def eager_load: (*String | Symbol) -> self
24
+ | (Hash[untyped, untyped]) -> self
25
+ def preload: (*String | Symbol) -> self
26
+ | (Hash[untyped, untyped]) -> self
27
+ def find_by: (*untyped) -> Model?
28
+ def find_by!: (*untyped) -> Model
29
+ def find: (PrimaryKey id) -> Model
30
+ | (Array[PrimaryKey]) -> Array[Model]
31
+ | (*PrimaryKey) -> Array[Model]
32
+ | () { (Model) -> boolish } -> Model?
33
+ def first: () -> Model?
34
+ | (Integer count) -> Array[Model]
35
+ def first!: () -> Model
36
+ def last: () -> Model?
37
+ | (Integer count) -> Array[Model]
38
+ def last!: () -> Model
39
+ def limit: (Integer | Arel::Nodes::SqlLiteral | nil) -> self
40
+ def limit!: (Integer | Arel::Nodes::SqlLiteral | nil) -> self
41
+ def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
42
+ def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
43
+ def destroy_all: () -> untyped
44
+ def delete_all: () -> untyped
45
+ def update_all: (*untyped) -> untyped
46
+ def each: () { (Model) -> void } -> self
47
+ def select: (*Symbol | String) -> self
48
+ | () { (Model) -> boolish } -> Array[Model]
49
+ end
@@ -0,0 +1,45 @@
1
+ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
2
+ def all: () -> Relation
3
+ def ids: () -> Array[PrimaryKey]
4
+ def none: () -> Relation
5
+ def pluck: (Symbol | String column) -> Array[untyped]
6
+ | (*Symbol | String columns) -> Array[Array[untyped]]
7
+ def where: (*untyped) -> Relation
8
+ def exists?: (*untyped) -> bool
9
+ def order: (*untyped) -> Relation
10
+ def group: (*Symbol | String) -> untyped
11
+ def distinct: () -> self
12
+ def or: (Relation) -> Relation
13
+ def merge: (Relation) -> Relation
14
+ def joins: (*String | Symbol) -> self
15
+ | (Hash[untyped, untyped]) -> self
16
+ def left_joins: (*String | Symbol) -> self
17
+ | (Hash[untyped, untyped]) -> self
18
+ def left_outer_joins: (*String | Symbol) -> self
19
+ | (Hash[untyped, untyped]) -> self
20
+ def includes: (*String | Symbol) -> self
21
+ | (Hash[untyped, untyped]) -> self
22
+ def eager_load: (*String | Symbol) -> self
23
+ | (Hash[untyped, untyped]) -> self
24
+ def preload: (*String | Symbol) -> self
25
+ | (Hash[untyped, untyped]) -> self
26
+ def find_by: (*untyped) -> Model?
27
+ def find_by!: (*untyped) -> Model
28
+ def find: (PrimaryKey id) -> Model
29
+ | (Array[PrimaryKey]) -> Array[Model]
30
+ | (*PrimaryKey) -> Array[Model]
31
+ def first: () -> Model?
32
+ | (Integer count) -> Array[Model]
33
+ def first!: () -> Model
34
+ def last: () -> Model?
35
+ | (Integer count) -> Array[Model]
36
+ def last!: () -> Model
37
+ def limit: (Integer | Arel::Nodes::SqlLiteral | nil) -> Relation
38
+ def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
39
+ def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
40
+ def destroy_all: () -> untyped
41
+ def delete_all: () -> untyped
42
+ def update_all: (*untyped) -> untyped
43
+ def select: (*Symbol | String) -> Relation
44
+ | () { (Model) -> boolish } -> Array[Model]
45
+ end