orthoses-rails 0.9.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -65
  3. data/lib/generators/orthoses/rails/install_generator.rb +18 -0
  4. data/lib/generators/orthoses/rails/templates/rails.rake +31 -0
  5. data/lib/orthoses/active_record/belongs_to.rb +15 -4
  6. data/lib/orthoses/active_record/enum.rb +5 -0
  7. data/lib/orthoses/active_record/generated_attribute_methods.rb +47 -55
  8. data/lib/orthoses/active_record/has_many.rb +15 -4
  9. data/lib/orthoses/active_record/has_one.rb +12 -2
  10. data/lib/orthoses/active_record/relation.rb +56 -0
  11. data/lib/orthoses/active_record/secure_token.rb +28 -0
  12. data/lib/orthoses/active_record.rb +37 -0
  13. data/lib/orthoses/active_storage/attached/model.rb +47 -0
  14. data/lib/orthoses/active_storage.rb +3 -0
  15. data/lib/orthoses/active_support/aliasing.rb +34 -0
  16. data/lib/orthoses/active_support/delegation.rb +17 -6
  17. data/lib/orthoses/active_support/time_with_zone.rb +30 -21
  18. data/lib/orthoses/active_support.rb +1 -0
  19. data/lib/orthoses/rails/application.rb +47 -0
  20. data/lib/orthoses/rails/version.rb +1 -1
  21. data/lib/orthoses/rails.rb +4 -2
  22. metadata +13 -45
  23. data/examples/rails/Gemfile +0 -16
  24. data/examples/rails/Gemfile.lock +0 -179
  25. data/examples/rails/Rakefile +0 -328
  26. data/examples/rails/config/database.yml +0 -8
  27. data/examples/rails/config/storage.yml +0 -3
  28. data/examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs +0 -4
  29. data/examples/rails/known_sig/activemodel/7.0/active_model/serialization.rbs +0 -4
  30. data/examples/rails/known_sig/activemodel/7.0/active_model/validations.rbs +0 -4
  31. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs +0 -49
  32. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs +0 -45
  33. data/examples/rails/known_sig/activerecord/6.0/active_record/result.rbs +0 -5
  34. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs +0 -49
  35. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs +0 -45
  36. data/examples/rails/known_sig/activerecord/6.1/active_record/result.rbs +0 -5
  37. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs +0 -49
  38. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs +0 -45
  39. data/examples/rails/known_sig/activerecord/7.0/active_record/encryption/context.rbs +0 -9
  40. data/examples/rails/known_sig/activerecord/7.0/active_record/result.rbs +0 -5
  41. data/examples/rails/known_sig/activesupport/7.0/active_support/callbacks/callback_chain.rbs +0 -9
  42. data/examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs +0 -4
  43. data/examples/rails/known_sig/activesupport/7.0/active_support/hash_with_indifferent_access.rbs +0 -6
  44. data/examples/rails/known_sig/activesupport/7.0/active_support/multibyte/chars.rbs +0 -7
  45. data/examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs +0 -5
  46. data/examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs +0 -3
  47. data/examples/rails/known_sig/activesupport/7.0/date.rbs +0 -6
  48. data/examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs +0 -4
  49. data/examples/rails/known_sig/activesupport/7.0/hash_with_indifferent_access.rbs +0 -2
  50. data/examples/rails/known_sig/activesupport/7.0/integer.rbs +0 -9
  51. data/examples/rails/known_sig/activesupport/7.0/numeric.rbs +0 -15
  52. data/examples/rails/known_sig/activesupport/7.0/string.rbs +0 -4
  53. data/examples/rails/known_sig/activesupport/7.0/time.rbs +0 -46
  54. data/examples/rails/tasks/action_pack.rake +0 -141
  55. data/examples/rails/tasks/action_view.rake +0 -77
  56. data/examples/rails/tasks/active_job.rake +0 -99
  57. data/examples/rails/tasks/active_model.rake +0 -46
  58. data/examples/rails/tasks/active_record.rake +0 -88
  59. data/examples/rails/tasks/active_storage.rake +0 -94
  60. data/examples/rails/tasks/active_support.rake +0 -99
  61. data/examples/rails/tasks/railties.rake +0 -34
  62. data/orthoses-rails.gemspec +0 -36
@@ -1,9 +0,0 @@
1
- module ActiveSupport
2
- module Callbacks
3
- class CallbackChain
4
- include Enumerable[::ActiveSupport::Callbacks::Callback]
5
- def each: () -> Enumerator[::ActiveSupport::Callbacks::Callback, Array[::ActiveSupport::Callbacks::Callback]]
6
- | () { (::ActiveSupport::Callbacks::Callback) -> void } -> Array[::ActiveSupport::Callbacks::Callback]
7
- end
8
- end
9
- end
@@ -1,4 +0,0 @@
1
- class ActiveSupport::Duration
2
- def since: (?untyped time) -> ::ActiveSupport::TimeWithZone
3
- def ago: (?untyped time) -> ::ActiveSupport::TimeWithZone
4
- end
@@ -1,6 +0,0 @@
1
- module ActiveSupport
2
- class HashWithIndifferentAccess[K, V] < ::Hash[K, V]
3
- def []=: (K key, V value) -> untyped
4
- def []: (K key) -> V
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module ActiveSupport
2
- module Multibyte
3
- class Chars
4
- attr_reader wrapped_string: ::String
5
- end
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- class ActiveSupport::TimeWithZone
2
- def +: (ActiveSupport::Duration other) -> self
3
- def -: (self other) -> Float
4
- | (ActiveSupport::Duration other) -> self
5
- end
@@ -1,3 +0,0 @@
1
- class ActiveSupport::TimeZone
2
- def now: () -> ActiveSupport::TimeWithZone
3
- end
@@ -1,6 +0,0 @@
1
- class Date
2
- def +: (ActiveSupport::Duration other) -> self
3
- | ...
4
- def -: (ActiveSupport::Duration other) -> self
5
- | ...
6
- end
@@ -1,4 +0,0 @@
1
- module DateAndTime::Zones
2
- def in_time_zone: (?(ActiveSupport::TimeZone | String) zone) -> ::ActiveSupport::TimeWithZone
3
- | (false? zone) -> ::Time
4
- end
@@ -1,2 +0,0 @@
1
- class HashWithIndifferentAccess[K, V] < ActiveSupport::HashWithIndifferentAccess[K, V]
2
- end
@@ -1,9 +0,0 @@
1
- class Integer < ::Numeric
2
- # 2.months # => 2 months
3
- def months: () -> ActiveSupport::Duration
4
-
5
- # Returns a Duration instance matching the number of years provided.
6
- #
7
- # 2.years # => 2 years
8
- def years: () -> ActiveSupport::Duration
9
- end
@@ -1,15 +0,0 @@
1
- class Numeric
2
- def kilobytes: () -> self
3
- def megabytes: () -> self
4
- def gigabytes: () -> self
5
- def terabytes: () -> self
6
- def petabytes: () -> self
7
- def exabytes: () -> self
8
- def seconds: () -> ActiveSupport::Duration
9
- def minutes: () -> ActiveSupport::Duration
10
- def hours: () -> ActiveSupport::Duration
11
- def days: () -> ActiveSupport::Duration
12
- def weeks: () -> ActiveSupport::Duration
13
- def fortnights: () -> ActiveSupport::Duration
14
- def in_milliseconds: () -> self
15
- end
@@ -1,4 +0,0 @@
1
- class String
2
- def in_time_zone: (?(ActiveSupport::TimeZone | String) zone) -> ::ActiveSupport::TimeWithZone
3
- | (false? zone) -> ::Time
4
- end
@@ -1,46 +0,0 @@
1
- class Time
2
- # Returns <tt>Time.zone.now</tt> when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns <tt>Time.now</tt>.
3
- def self.current: () -> ActiveSupport::TimeWithZone # strictly `(ActiveSupport::TimeWithZone | Time)` but it's inconvenient
4
- def self.zone: () -> ActiveSupport::TimeZone # strictly `ActiveSupport::TimeWithZone?` but it's inconvenient
5
-
6
- def ago: (untyped other) -> self
7
- def advance: (untyped options) -> self
8
- def change: (untyped options) -> self
9
- def in_time_zone: (?(ActiveSupport::TimeZone | String) new_zone) -> ::ActiveSupport::TimeWithZone
10
- | (false? zone) -> ::Time
11
- def +: (ActiveSupport::Duration other) -> self
12
- | ...
13
- def -: (ActiveSupport::Duration other) -> self
14
- | ...
15
- def beginning_of_day: () -> self
16
- def beginning_of_hour: () -> self
17
- def beginning_of_minute: () -> self
18
- def compare_with_coercion: (untyped other) -> (-1 | 0 | 1 | nil)
19
- def compare_without_coercion: (untyped other) -> (-1 | 0 | 1 | nil)
20
- def end_of_day: () -> self
21
- def end_of_hour: () -> self
22
- def end_of_minute: () -> self
23
- def eql_with_coercion: (untyped other) -> bool
24
- def eql_without_coercion: (untyped other) -> bool
25
- def middle_of_day: () -> self
26
- def minus_with_coercion: (Time | self arg0) -> Float
27
- | (Numeric arg0) -> self
28
- def minus_with_duration: (Time | self arg0) -> Float
29
- | (Numeric arg0) -> self
30
- def minus_without_coercion: (Time | self arg0) -> Float
31
- | (Numeric arg0) -> self
32
- def minus_without_duration: (Time | self arg0) -> Float
33
- | (Numeric arg0) -> self
34
- def next_day: () -> self
35
- def next_month: () -> self
36
- def next_year: () -> self
37
- def plus_without_duration: (Time | self arg0) -> Float
38
- | (Numeric arg0) -> self
39
- def prev_day: () -> self
40
- def prev_month: () -> self
41
- def prev_year: () -> self
42
- def seconds_since_midnight: () -> Float
43
- def seconds_until_end_of_day: () -> Integer
44
- def sec_fraction: () -> (Integer | Rational)
45
- def to_default_s: () -> String
46
- end
@@ -1,141 +0,0 @@
1
- stdlib_dependencies = %w[benchmark date digest json logger monitor mutex_m pathname singleton time minitest securerandom ipaddr did_you_mean]
2
- gem_dependencies = %w[nokogiri i18n rack rails-dom-testing]
3
- rails_dependencies = %w[activesupport actionview]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :action_pack do
8
- export = "export/actionpack/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/action_pack.rbs #{export}"
16
- sh "cp -a out/#{version}/action_pack #{export}"
17
- sh "cp -a out/#{version}/action_controller.rbs #{export}"
18
- sh "cp -a out/#{version}/action_controller #{export}"
19
- sh "cp -a out/#{version}/action_dispatch.rbs #{export}"
20
- sh "cp -a out/#{version}/action_dispatch #{export}"
21
- sh "cp -a out/#{version}/abstract_controller.rbs #{export}"
22
- sh "cp -a out/#{version}/abstract_controller #{export}"
23
- sh "cp -a out/#{version}/mime.rbs #{export}"
24
- sh "cp -a out/#{version}/mime #{export}"
25
-
26
- sh "rm #{export}/action_controller/railtie.rbs"
27
- sh "rm #{export}/action_dispatch/railtie.rbs"
28
-
29
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
30
- # !!! GENERATED CODE !!!
31
- # Please see generators/rails-generator
32
-
33
- class Ripper
34
- end
35
-
36
- class Delegator
37
- end
38
-
39
- class SimpleDelegator < ::Delegator
40
- end
41
-
42
- class ActionDispatch::Cookies::CookieJar
43
- def to_h: () -> Hash[untyped, untyped]
44
- end
45
-
46
- module Rack
47
- module Cache
48
- class EntityStore
49
- end
50
- class MetaStore
51
- end
52
- end
53
- module Session
54
- class Dalli
55
- end
56
- end
57
- module Test
58
- class UploadedFile
59
- end
60
- end
61
- end
62
-
63
- module Rails
64
- module Dom
65
- module Testing
66
- module Assertions
67
- include Rails::Dom::Testing::Assertions::SelectorAssertions
68
-
69
- include Rails::Dom::Testing::Assertions::DomAssertions
70
-
71
- extend ActiveSupport::Concern
72
-
73
- module DomAssertions
74
- public
75
-
76
- def assert_dom_equal: (untyped expected, untyped actual, ?untyped message) -> untyped
77
-
78
- def assert_dom_not_equal: (untyped expected, untyped actual, ?untyped message) -> untyped
79
-
80
- private
81
-
82
- def fragment: (untyped text) -> untyped
83
- end
84
-
85
- module SelectorAssertions
86
- include Rails::Dom::Testing::Assertions::SelectorAssertions::CountDescribable
87
-
88
- public
89
-
90
- def assert_select: (*untyped args) { (*untyped) -> untyped } -> untyped
91
-
92
- def assert_select_email: () { (*untyped) -> untyped } -> untyped
93
-
94
- def assert_select_encoded: (?untyped element) { (*untyped) -> untyped } -> untyped
95
-
96
- def css_select: (*untyped args) -> untyped
97
-
98
- private
99
-
100
- def assert_size_match!: (untyped size, untyped equals, untyped css_selector, ?untyped message) -> untyped
101
-
102
- def document_root_element: () -> untyped
103
-
104
- def nest_selection: (untyped selection) { (untyped) -> untyped } -> untyped
105
-
106
- def nodeset: (untyped node) -> untyped
107
-
108
- module CountDescribable
109
- extend ActiveSupport::Concern
110
-
111
- private
112
-
113
- def count_description: (untyped min, untyped max, untyped count) -> untyped
114
-
115
- def pluralize_element: (untyped quantity) -> untyped
116
- end
117
- end
118
- end
119
- end
120
- end
121
- end
122
- RBS
123
- end
124
-
125
- desc "validate version=#{version} gem=action_pack"
126
- task :validate do
127
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
128
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
129
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
130
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
131
- end
132
-
133
- desc "install to ../../../gems/actionpack/#{version}"
134
- task :install do
135
- install_to = File.expand_path("../../../gems/actionpack/#{version}", __dir__)
136
- sh "rm -fr #{install_to}"
137
- sh "cp -a #{export} #{install_to}"
138
- end
139
- end
140
- end
141
- end
@@ -1,77 +0,0 @@
1
- stdlib_dependencies = %w[benchmark date digest json logger monitor mutex_m pathname singleton time minitest did_you_mean]
2
- gem_dependencies = %w[nokogiri i18n rack]
3
- rails_dependencies = %w[activesupport]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :action_view do
8
- export = "export/actionview/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/action_view.rbs #{export}"
16
- sh "cp -a out/#{version}/action_view #{export}"
17
- sh "cp -a out/#{version}/erubi.rbs #{export}"
18
- sh "cp -a out/#{version}/erubi #{export}"
19
- sh "rm #{export}/action_view/railtie.rbs"
20
- sh "rm -fr #{export}/action_view/test_case"
21
- sh "rm #{export}/action_view/test_case.rbs"
22
-
23
- File.open("out/#{version}/action_view/partial_renderer.rbs") do |r|
24
- File.open("#{export}/action_view/partial_renderer.rbs", "w+") do |w|
25
- outs = r.each_line.select do |line|
26
- !line.include?("prepend ActiveRecord::Railties::CollectionCacheAssociationLoading")
27
- end
28
- w.puts(outs)
29
- end
30
- end
31
-
32
- File.open("out/#{version}/action_view/routing_url_for.rbs") do |r|
33
- File.open("#{export}/action_view/routing_url_for.rbs", "w+") do |w|
34
- outs = r.each_line.select do |line|
35
- !line.include?("include ActionDispatch::Routing::UrlFor")
36
- end
37
- w.puts(outs)
38
- end
39
- end
40
-
41
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
42
- # !!! GENERATED CODE !!!
43
- # Please see generators/rails-generator
44
-
45
- class Ripper
46
- end
47
-
48
- class Delegator
49
- end
50
-
51
- class SimpleDelegator < ::Delegator
52
- end
53
-
54
- module ERB
55
- module Util
56
- end
57
- end
58
- RBS
59
- end
60
-
61
- desc "validate version=#{version} gem=action_view"
62
- task :validate do
63
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
64
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
65
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
66
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
67
- end
68
-
69
- desc "install to ../../../gems/actionview/#{version}"
70
- task :install do
71
- install_to = File.expand_path("../../../gems/actionview/#{version}", __dir__)
72
- sh "rm -fr #{install_to}"
73
- sh "cp -a #{export} #{install_to}"
74
- end
75
- end
76
- end
77
- end
@@ -1,99 +0,0 @@
1
- stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest minitest]
2
- gem_dependencies = %w[nokogiri]
3
- rails_dependencies = %w[activesupport]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :active_job do
8
- export = "export/activejob/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/active_job.rbs #{export}"
16
- sh "cp -a out/#{version}/active_job #{export}"
17
- sh "rm #{export}/active_job/railtie.rbs"
18
-
19
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
20
- # !!! GENERATED CODE !!!
21
- # Please see generators/rails-generator
22
-
23
- module Que
24
- class Job
25
- end
26
- end
27
- module Qu
28
- class Job
29
- end
30
- end
31
- RBS
32
-
33
- generate_test_script(
34
- gem: :activejob,
35
- version: version,
36
- export: export,
37
- stdlib_dependencies: stdlib_dependencies,
38
- gem_dependencies: gem_dependencies,
39
- rails_dependencies: rails_dependencies,
40
- )
41
-
42
- Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
43
- # !!! GENERATED CODE !!!
44
- # Please see generators/rails-generator
45
-
46
- class SendMessageJob < ActiveJob::Base
47
- queue_as :default
48
- self.queue_adapter = :sidekiq
49
-
50
- before_enqueue do |job|
51
- # before enqueued
52
- end
53
-
54
- around_perform :around_task
55
-
56
- def perform(*args)
57
- # Do something later
58
- end
59
-
60
- private
61
-
62
- def around_task
63
- # Do something before
64
- # yield
65
- # Do something after
66
- end
67
- end
68
-
69
- SendMessageJob.perform_now
70
- SendMessageJob.set(queue: :another_queue).perform_later(flag: false)
71
- RUBY
72
-
73
- Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
74
- # !!! GENERATED CODE !!!
75
- # Please see generators/rails-generator
76
-
77
- class SendMessageJob < ActiveJob::Base
78
- def perform: (*untyped) -> void
79
- end
80
- RBS
81
- end
82
-
83
- desc "validate version=#{version} gem=active_job"
84
- task :validate do
85
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
86
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
87
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
88
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
89
- end
90
-
91
- desc "install to ../../../gems/activejob/#{version}"
92
- task :install do
93
- install_to = File.expand_path("../../../gems/activejob/#{version}", __dir__)
94
- sh "rm -fr #{install_to}"
95
- sh "cp -a #{export} #{install_to}"
96
- end
97
- end
98
- end
99
- end
@@ -1,46 +0,0 @@
1
- stdlib_dependencies = %w[benchmark date digest forwardable json logger monitor mutex_m singleton time minitest]
2
- gem_dependencies = %w[nokogiri]
3
- rails_dependencies = %w[activesupport]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :active_model do
8
- export = "export/activemodel/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/active_model.rbs #{export}"
16
- sh "cp -a out/#{version}/active_model #{export}"
17
- sh "rm #{export}/active_model/railtie.rbs"
18
-
19
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
20
- # !!! GENERATED CODE !!!
21
- # Please see generators/rails-generator
22
-
23
- class Delegator
24
- end
25
- class SimpleDelegator < Delegator
26
- end
27
- RBS
28
- end
29
-
30
- desc "validate version=#{version} gem=active_model"
31
- task :validate do
32
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
33
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
34
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
35
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
36
- end
37
-
38
- desc "install to ../../../gems/activemodel/#{version}"
39
- task :install do
40
- install_to = File.expand_path("../../../gems/activemodel/#{version}", __dir__)
41
- sh "rm -fr #{install_to}"
42
- sh "cp -a #{export} #{install_to}"
43
- end
44
- end
45
- end
46
- end
@@ -1,88 +0,0 @@
1
- stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest forwardable did_you_mean openssl socket minitest]
2
- gem_dependencies = %w[nokogiri]
3
- rails_dependencies = %w[activesupport activemodel]
4
-
5
- VERSIONS.each do |version|
6
- namespace version do
7
- namespace :active_record do
8
- export = "export/activerecord/#{version}"
9
-
10
- desc "export to #{export}"
11
- task :export do
12
- sh "rm -fr #{export}"
13
- sh "mkdir -p #{export}"
14
-
15
- sh "cp -a out/#{version}/active_record.rbs #{export}"
16
- sh "cp -a out/#{version}/active_record #{export}"
17
- sh "cp -a out/#{version}/arel #{export}"
18
- sh "cp -a out/#{version}/arel.rbs #{export}"
19
- sh "cp -a out/#{version}/_active_record_relation.rbs #{export}"
20
-
21
- sh "rm #{export}/active_record/railtie.rbs"
22
- sh "rm -fr #{export}/active_record/connection_adapters" # FIXME
23
- sh "rm -fr #{export}/active_record/migration/compatibility" # FIXME
24
- sh "rm -f #{export}/active_record/destroy_association_async_job.rbs" # move to railties
25
-
26
- sh "cat out/#{version}/active_record/base.rbs | grep -v ActiveStorage > #{export}/active_record/base.rbs"
27
-
28
- Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
29
- # !!! GENERATED CODE !!!
30
- # Please see generators/rails-generator
31
-
32
- module PG
33
- class SimpleDecoder
34
- end
35
- end
36
- module GlobalID
37
- module Identification
38
- end
39
- module FixtureSet
40
- end
41
- end
42
- RBS
43
-
44
- generate_test_script(
45
- gem: :activerecord,
46
- version: version,
47
- export: export,
48
- stdlib_dependencies: stdlib_dependencies,
49
- gem_dependencies: gem_dependencies,
50
- rails_dependencies: rails_dependencies,
51
- )
52
-
53
- Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
54
- # !!! GENERATED CODE !!!
55
- # Please see generators/rails-generator
56
-
57
- class User < ActiveRecord::Base
58
- end
59
-
60
- user = User.new
61
- RUBY
62
-
63
- Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
64
- # !!! GENERATED CODE !!!
65
- # Please see generators/rails-generator
66
-
67
- class User < ActiveRecord::Base
68
- end
69
- RBS
70
- end
71
-
72
- desc "validate version=#{version} gem=active_record"
73
- task :validate do
74
- stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
75
- gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
76
- rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
77
- sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
78
- end
79
-
80
- desc "install to ../../../gems/activerecord/#{version}"
81
- task :install do
82
- install_to = File.expand_path("../../../gems/activerecord/#{version}", __dir__)
83
- sh "rm -fr #{install_to}"
84
- sh "cp -a #{export} #{install_to}"
85
- end
86
- end
87
- end
88
- end