orthoses-rails 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -23
  3. data/examples/rails/{gemfiles/Gemfile_6_0 → Gemfile} +4 -4
  4. data/examples/rails/{gemfiles/Gemfile_7_0.lock → Gemfile.lock} +83 -76
  5. data/examples/rails/Rakefile +64 -51
  6. data/examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs +4 -0
  7. data/examples/rails/known_sig/activemodel/7.0/active_model/serialization.rbs +4 -0
  8. data/examples/rails/known_sig/activemodel/7.0/active_model/validations.rbs +4 -0
  9. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs +49 -0
  10. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs +45 -0
  11. data/examples/rails/known_sig/activerecord/6.0/active_record/result.rbs +5 -0
  12. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs +49 -0
  13. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs +45 -0
  14. data/examples/rails/known_sig/activerecord/6.1/active_record/result.rbs +5 -0
  15. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs +49 -0
  16. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs +45 -0
  17. data/examples/rails/known_sig/activerecord/7.0/active_record/encryption/context.rbs +9 -0
  18. data/examples/rails/known_sig/activerecord/7.0/active_record/result.rbs +5 -0
  19. data/examples/rails/known_sig/activesupport/7.0/active_support/callbacks/callback_chain.rbs +9 -0
  20. data/examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs +4 -0
  21. data/examples/rails/known_sig/activesupport/7.0/active_support/hash_with_indifferent_access.rbs +6 -0
  22. data/examples/rails/known_sig/activesupport/7.0/active_support/multibyte/chars.rbs +7 -0
  23. data/examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs +5 -0
  24. data/examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs +3 -0
  25. data/examples/rails/known_sig/activesupport/7.0/date.rbs +6 -0
  26. data/examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs +4 -0
  27. data/examples/rails/known_sig/activesupport/7.0/hash_with_indifferent_access.rbs +2 -0
  28. data/examples/rails/known_sig/activesupport/7.0/integer.rbs +9 -0
  29. data/examples/rails/known_sig/activesupport/7.0/numeric.rbs +15 -0
  30. data/examples/rails/known_sig/activesupport/7.0/string.rbs +4 -0
  31. data/examples/rails/known_sig/activesupport/7.0/time.rbs +46 -0
  32. data/examples/rails/tasks/action_pack.rake +141 -0
  33. data/examples/rails/tasks/action_view.rake +77 -0
  34. data/examples/rails/tasks/active_job.rake +5 -1
  35. data/examples/rails/tasks/active_model.rake +1 -1
  36. data/examples/rails/tasks/active_record.rake +7 -2
  37. data/examples/rails/tasks/active_storage.rake +1 -1
  38. data/examples/rails/tasks/active_support.rake +7 -0
  39. data/examples/rails/tasks/railties.rake +34 -0
  40. data/lib/orthoses/active_model/has_secure_password.rb +2 -10
  41. data/lib/orthoses/active_record/delegated_type.rb +2 -8
  42. data/lib/orthoses/active_record/enum.rb +2 -2
  43. data/lib/orthoses/active_record/generated_attribute_methods.rb +1 -0
  44. data/lib/orthoses/active_record/scope.rb +2 -2
  45. data/lib/orthoses/active_support/class_attribute.rb +3 -10
  46. data/lib/orthoses/active_support/concern.rb +46 -0
  47. data/lib/orthoses/active_support/configurable.rb +3 -2
  48. data/lib/orthoses/active_support/delegation.rb +6 -14
  49. data/lib/orthoses/active_support/mattr_accessor.rb +4 -12
  50. data/lib/orthoses/active_support.rb +1 -15
  51. data/lib/orthoses/rails/version.rb +1 -1
  52. data/lib/orthoses/rails.rb +1 -0
  53. data/lib/orthoses/railties/mixin.rb +107 -0
  54. data/lib/orthoses/railties.rb +3 -0
  55. data/orthoses-rails.gemspec +1 -1
  56. metadata +40 -12
  57. data/examples/rails/gemfiles/Gemfile_6_0.lock +0 -172
  58. data/examples/rails/gemfiles/Gemfile_6_1 +0 -15
  59. data/examples/rails/gemfiles/Gemfile_6_1.lock +0 -173
  60. data/examples/rails/gemfiles/Gemfile_7_0 +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46bcd93481527f23bfe512d336313721f7cf17fe67bb124e51e016f59cff14c2
4
- data.tar.gz: 7a783be26aeeb877069e4c0e431765e274bb07dd25438669ca8dbb58c6417405
3
+ metadata.gz: 70f9def2ba0ccd5b1537ee8aa3ee68c2700e99d0f134d313069939cc1db3277d
4
+ data.tar.gz: 922e2e304b3aa7f5cd34cb215ea3656c6a4c79c34875b7fd7ed691743230ea10
5
5
  SHA512:
6
- metadata.gz: ef3237aa508e90177b76dd160456404cf37dfcd1907b18ad299b1cd2f95e1abd4971762de5a0679850943b220348b7f7528689eef31be84651a30cbb29eb2601
7
- data.tar.gz: 353ee63dc4a5bd7fa82fa59f571766b842690c09bd98d14e4f3f1defbb77ec14870f361149b3ac0ab6b46cad9b933f02ecaf8190a5824a4e3739b088ba14bea4
6
+ metadata.gz: 42f23b91ba796e225541f7da52cc74916a53ef584f1711d95457b0cc239441146678c4ebbb5a271a52710d928f55edba2d5032bec56a4fe9f9b0e47bf7e44c6a
7
+ data.tar.gz: 1f9c63c9d2b9b8f11d820a27ef660d61cb727d3a3b3b644afa93fb3b7bdb48dbd150ca7ab96f636d02fb330e2de27c902862e04b89a514f20d5e3d51d5172dc8
data/README.md CHANGED
@@ -48,34 +48,35 @@ If bundler is not being used to manage dependencies, install the gem by executin
48
48
 
49
49
  ## Usage
50
50
 
51
+ Build your Rake task for RBS generation.
52
+
51
53
  ```rb
52
- Orthoses::Builder.new do
53
- use Orthoses::CreateFileByName
54
- base_dir: Rails.root.join("sig/out"),
55
- header: "# !!! GENERATED CODE !!!"
56
- use Orthoses::Filter,
57
- if: -> (name, _content) {
54
+ task :rbs_generate => :environment do
55
+ Orthoses::Builder.new do
56
+ use Orthoses::CreateFileByName
57
+ base_dir: Rails.root.join("sig/out"),
58
+ header: "# !!! GENERATED CODE !!!"
59
+ use Orthoses::Filter do |name, _content|
58
60
  path, _lineno = Object.const_source_location(name)
59
61
  return false unless path
60
62
  %r{app/models}.match?(path)
63
+ end
64
+ use YourCustom::Middleware
65
+ use Orthoses::ActiveModel::HasSecurePassword
66
+ use Orthoses::ActiveRecord::BelongsTo
67
+ use Orthoses::ActiveRecord::HasMany
68
+ use Orthoses::ActiveRecord::HasOne
69
+ use Orthoses::ActiveSupport::ClassAttribute
70
+ use Orthoses::ActiveSupport::MattrAccessor
71
+ use Orthoses::Mixin
72
+ use Orthoses::Constant, strict: false
73
+ use Orthoses::ObjectSpaceAll
74
+ use Orthoses::Autoload
75
+ run -> {
76
+ Rails.application.eager_load!
61
77
  }
62
- use YourCustom::Middleware
63
- use Orthoses::ActiveModel::HasSecurePassword
64
- use Orthoses::ActiveRecord::BelongsTo
65
- use Orthoses::ActiveRecord::HasMany
66
- use Orthoses::ActiveRecord::HasOne
67
- use Orthoses::ActiveSupport::ClassAttribute
68
- use Orthoses::ActiveSupport::MattrAccessor
69
- use Orthoses::Mixin
70
- use Orthoses::Constant, strict: false
71
- use Orthoses::ObjectSpaceAll
72
- use Orthoses::Autoload
73
- run -> () {
74
- Rake::Task[:environment].invoke
75
- Rails.application.eager_load!
76
- Orthoses::Utils.unautoload!
77
- }
78
- end.call
78
+ end.call
79
+ end
79
80
  ```
80
81
 
81
82
  ## Development
@@ -1,12 +1,12 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- ruby "~> 3.1.0"
3
+ ruby ">= 3.1.0"
4
4
 
5
- gemspec path: '../../../'
5
+ gemspec path: '../../'
6
6
 
7
- gem "rails", ">= 6.0", "< 6.1"
7
+ gem "rails", path: "_src"
8
8
  gem "sqlite3"
9
- # gem "orthoses", path: "../../../../orthoses"
9
+ # gem "orthoses", path: "../../../orthoses"
10
10
 
11
11
  if RUBY_VERSION >= "3.1"
12
12
  gem "net-smtp", require: false
@@ -1,85 +1,110 @@
1
1
  PATH
2
- remote: ../../..
2
+ remote: ../..
3
3
  specs:
4
- orthoses-rails (0.4.0)
5
- orthoses (>= 0.10)
4
+ orthoses-rails (0.7.0)
5
+ orthoses (~> 1.0)
6
6
 
7
- GEM
8
- remote: https://rubygems.org/
7
+ PATH
8
+ remote: _src
9
9
  specs:
10
- actioncable (7.0.3)
11
- actionpack (= 7.0.3)
12
- activesupport (= 7.0.3)
10
+ actioncable (7.0.3.1)
11
+ actionpack (= 7.0.3.1)
12
+ activesupport (= 7.0.3.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (7.0.3)
16
- actionpack (= 7.0.3)
17
- activejob (= 7.0.3)
18
- activerecord (= 7.0.3)
19
- activestorage (= 7.0.3)
20
- activesupport (= 7.0.3)
15
+ actionmailbox (7.0.3.1)
16
+ actionpack (= 7.0.3.1)
17
+ activejob (= 7.0.3.1)
18
+ activerecord (= 7.0.3.1)
19
+ activestorage (= 7.0.3.1)
20
+ activesupport (= 7.0.3.1)
21
21
  mail (>= 2.7.1)
22
22
  net-imap
23
23
  net-pop
24
24
  net-smtp
25
- actionmailer (7.0.3)
26
- actionpack (= 7.0.3)
27
- actionview (= 7.0.3)
28
- activejob (= 7.0.3)
29
- activesupport (= 7.0.3)
25
+ actionmailer (7.0.3.1)
26
+ actionpack (= 7.0.3.1)
27
+ actionview (= 7.0.3.1)
28
+ activejob (= 7.0.3.1)
29
+ activesupport (= 7.0.3.1)
30
30
  mail (~> 2.5, >= 2.5.4)
31
31
  net-imap
32
32
  net-pop
33
33
  net-smtp
34
34
  rails-dom-testing (~> 2.0)
35
- actionpack (7.0.3)
36
- actionview (= 7.0.3)
37
- activesupport (= 7.0.3)
35
+ actionpack (7.0.3.1)
36
+ actionview (= 7.0.3.1)
37
+ activesupport (= 7.0.3.1)
38
38
  rack (~> 2.0, >= 2.2.0)
39
39
  rack-test (>= 0.6.3)
40
40
  rails-dom-testing (~> 2.0)
41
41
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
- actiontext (7.0.3)
43
- actionpack (= 7.0.3)
44
- activerecord (= 7.0.3)
45
- activestorage (= 7.0.3)
46
- activesupport (= 7.0.3)
42
+ actiontext (7.0.3.1)
43
+ actionpack (= 7.0.3.1)
44
+ activerecord (= 7.0.3.1)
45
+ activestorage (= 7.0.3.1)
46
+ activesupport (= 7.0.3.1)
47
47
  globalid (>= 0.6.0)
48
48
  nokogiri (>= 1.8.5)
49
- actionview (7.0.3)
50
- activesupport (= 7.0.3)
49
+ actionview (7.0.3.1)
50
+ activesupport (= 7.0.3.1)
51
51
  builder (~> 3.1)
52
52
  erubi (~> 1.4)
53
53
  rails-dom-testing (~> 2.0)
54
54
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
- activejob (7.0.3)
56
- activesupport (= 7.0.3)
55
+ activejob (7.0.3.1)
56
+ activesupport (= 7.0.3.1)
57
57
  globalid (>= 0.3.6)
58
- activemodel (7.0.3)
59
- activesupport (= 7.0.3)
60
- activerecord (7.0.3)
61
- activemodel (= 7.0.3)
62
- activesupport (= 7.0.3)
63
- activestorage (7.0.3)
64
- actionpack (= 7.0.3)
65
- activejob (= 7.0.3)
66
- activerecord (= 7.0.3)
67
- activesupport (= 7.0.3)
58
+ activemodel (7.0.3.1)
59
+ activesupport (= 7.0.3.1)
60
+ activerecord (7.0.3.1)
61
+ activemodel (= 7.0.3.1)
62
+ activesupport (= 7.0.3.1)
63
+ activestorage (7.0.3.1)
64
+ actionpack (= 7.0.3.1)
65
+ activejob (= 7.0.3.1)
66
+ activerecord (= 7.0.3.1)
67
+ activesupport (= 7.0.3.1)
68
68
  marcel (~> 1.0)
69
69
  mini_mime (>= 1.1.0)
70
- activesupport (7.0.3)
70
+ activesupport (7.0.3.1)
71
71
  concurrent-ruby (~> 1.0, >= 1.0.2)
72
72
  i18n (>= 1.6, < 2)
73
73
  minitest (>= 5.1)
74
74
  tzinfo (~> 2.0)
75
+ rails (7.0.3.1)
76
+ actioncable (= 7.0.3.1)
77
+ actionmailbox (= 7.0.3.1)
78
+ actionmailer (= 7.0.3.1)
79
+ actionpack (= 7.0.3.1)
80
+ actiontext (= 7.0.3.1)
81
+ actionview (= 7.0.3.1)
82
+ activejob (= 7.0.3.1)
83
+ activemodel (= 7.0.3.1)
84
+ activerecord (= 7.0.3.1)
85
+ activestorage (= 7.0.3.1)
86
+ activesupport (= 7.0.3.1)
87
+ bundler (>= 1.15.0)
88
+ railties (= 7.0.3.1)
89
+ railties (7.0.3.1)
90
+ actionpack (= 7.0.3.1)
91
+ activesupport (= 7.0.3.1)
92
+ method_source
93
+ rake (>= 12.2)
94
+ thor (~> 1.0)
95
+ zeitwerk (~> 2.5)
96
+
97
+ GEM
98
+ remote: https://rubygems.org/
99
+ specs:
75
100
  builder (3.2.4)
76
101
  concurrent-ruby (1.1.10)
77
102
  crass (1.0.6)
78
103
  digest (3.1.0)
79
- erubi (1.10.0)
104
+ erubi (1.11.0)
80
105
  globalid (1.0.0)
81
106
  activesupport (>= 5.0)
82
- i18n (1.10.0)
107
+ i18n (1.12.0)
83
108
  concurrent-ruby (~> 1.0)
84
109
  loofah (2.18.0)
85
110
  crass (~> 1.0.2)
@@ -90,7 +115,7 @@ GEM
90
115
  method_source (1.0.0)
91
116
  mini_mime (1.1.2)
92
117
  mini_portile2 (2.8.0)
93
- minitest (5.16.1)
118
+ minitest (5.16.3)
94
119
  net-imap (0.2.3)
95
120
  digest
96
121
  net-protocol
@@ -106,48 +131,29 @@ GEM
106
131
  net-protocol
107
132
  timeout
108
133
  nio4r (2.5.8)
109
- nokogiri (1.13.6)
134
+ nokogiri (1.13.8)
110
135
  mini_portile2 (~> 2.8.0)
111
136
  racc (~> 1.4)
112
- orthoses (0.10.0)
137
+ orthoses (1.0.0)
113
138
  rbs (~> 2.0)
139
+ psych (3.3.3)
114
140
  racc (1.6.0)
115
- rack (2.2.3.1)
116
- rack-test (2.0.0)
141
+ rack (2.2.4)
142
+ rack-test (2.0.2)
117
143
  rack (>= 1.3)
118
- rails (7.0.3)
119
- actioncable (= 7.0.3)
120
- actionmailbox (= 7.0.3)
121
- actionmailer (= 7.0.3)
122
- actionpack (= 7.0.3)
123
- actiontext (= 7.0.3)
124
- actionview (= 7.0.3)
125
- activejob (= 7.0.3)
126
- activemodel (= 7.0.3)
127
- activerecord (= 7.0.3)
128
- activestorage (= 7.0.3)
129
- activesupport (= 7.0.3)
130
- bundler (>= 1.15.0)
131
- railties (= 7.0.3)
132
144
  rails-dom-testing (2.0.3)
133
145
  activesupport (>= 4.2.0)
134
146
  nokogiri (>= 1.6)
135
147
  rails-html-sanitizer (1.4.3)
136
148
  loofah (~> 2.3)
137
- railties (7.0.3)
138
- actionpack (= 7.0.3)
139
- activesupport (= 7.0.3)
140
- method_source
141
- rake (>= 12.2)
142
- thor (~> 1.0)
143
- zeitwerk (~> 2.5)
144
149
  rake (13.0.6)
145
150
  rbs (2.6.0)
146
- sqlite3 (1.4.4)
147
- strscan (3.0.3)
151
+ sqlite3 (1.5.0)
152
+ mini_portile2 (~> 2.8.0)
153
+ strscan (3.0.4)
148
154
  thor (1.2.1)
149
155
  timeout (0.3.0)
150
- tzinfo (2.0.4)
156
+ tzinfo (2.0.5)
151
157
  concurrent-ruby (~> 1.0)
152
158
  websocket-driver (0.7.5)
153
159
  websocket-extensions (>= 0.1.0)
@@ -155,18 +161,19 @@ GEM
155
161
  zeitwerk (2.6.0)
156
162
 
157
163
  PLATFORMS
158
- ruby
164
+ arm64-darwin-21
159
165
 
160
166
  DEPENDENCIES
161
167
  net-imap
162
168
  net-pop
163
169
  net-smtp
164
170
  orthoses-rails!
165
- rails (>= 7.0, < 7.1)
171
+ psych (~> 3)
172
+ rails!
166
173
  sqlite3
167
174
 
168
175
  RUBY VERSION
169
176
  ruby 3.1.1p18
170
177
 
171
178
  BUNDLED WITH
172
- 2.3.9
179
+ 2.3.16
@@ -22,24 +22,29 @@ def generate(out_dir, version)
22
22
  require "active_model"
23
23
  require "active_storage/engine"
24
24
  require "action_dispatch"
25
- require "action_mailbox"
25
+ begin
26
+ require "action_mailbox"
27
+ require "action_text"
28
+ rescue LoadError
29
+ end
26
30
  require "action_mailer"
27
31
  require "action_pack"
28
- require "action_text"
29
32
  require "action_view"
30
33
 
31
- [
34
+ roots = [
32
35
  ActiveSupport,
33
36
  ActiveModel,
34
37
  ActiveJob,
35
38
  ActiveRecord,
36
39
  ActiveStorage,
37
40
  ActionDispatch,
38
- ActionMailbox,
39
41
  ActionMailer,
40
- ActionText,
41
42
  ActionView,
42
- ].each do |rails_mod|
43
+ ]
44
+ roots << ActionMailbox if defined?(ActionMailbox)
45
+ roots << ActionText if defined?(ActionText)
46
+
47
+ roots.each do |rails_mod|
43
48
  rails_mod.eager_load!
44
49
  Orthoses::Utils.each_const_recursive(rails_mod, on_error: -> (e) {
45
50
  Orthoses.logger.warn "skip load const by [#{e.root}][#{e.const}](#{e.error.class})#{e.error.message}"
@@ -62,23 +67,21 @@ def generate(out_dir, version)
62
67
  use Orthoses::CreateFileByName,
63
68
  base_dir: "#{out_dir}/#{version}",
64
69
  header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
65
- use Orthoses::AvoidRecursiveAncestorError
66
- use Orthoses::Filter,
67
- if: -> (name, content) {
68
- # OMG, both ERB and Erb are exist...
69
- return false if name.start_with?("Erb")
70
+ use Orthoses::Filter do |name, content|
71
+ # OMG, both ERB and Erb are exist...
72
+ return false if name.start_with?("Erb")
70
73
 
71
- # ArgumentError
72
- return false if name.start_with?("I18n::Tests")
74
+ # ArgumentError
75
+ return false if name.start_with?("I18n::Tests")
73
76
 
74
- # FIXME: too hard
75
- return false if name.include?("::Generators")
77
+ # FIXME: too hard
78
+ return false if name.include?("::Generators")
76
79
 
77
- # Ignore known sig
78
- return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
80
+ # Ignore known sig
81
+ return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
79
82
 
80
- true
81
- }
83
+ true
84
+ end
82
85
  use Orthoses::Constant,
83
86
  strict: false,
84
87
  if: -> (current, const, _val, _rbs) {
@@ -87,9 +90,10 @@ def generate(out_dir, version)
87
90
  on_error: -> (e) {
88
91
  Orthoses.logger.warn "[Orthoses::Constant] skip load const by #{e.root}[::#{e.const}] (#{e.error.class}) #{e.error.message}"
89
92
  }
90
- Orthoses::ActiveSupport.each do |middleware, **args|
91
- use middleware, **args
92
- end
93
+ use Orthoses::ActiveSupport::ClassAttribute
94
+ use Orthoses::ActiveSupport::Delegation
95
+ use Orthoses::ActiveSupport::MattrAccessor
96
+ use Orthoses::ActiveSupport::TimeWithZone
93
97
  use Orthoses::ActiveRecord::QueryMethods
94
98
  use Orthoses::LoadRBS,
95
99
  paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveRecord::VERSION::STRING, "known_sig/activerecord") }
@@ -114,6 +118,9 @@ def generate(out_dir, version)
114
118
  elsif defined?(ActiveRecord::Migration::Compatibility::V6_0)
115
119
  store["ActiveRecord::Migration::Compatibility::V5_2"].header = nil
116
120
  store["ActiveRecord::Migration::Compatibility::V6_0"].header = "class ActiveRecord::Migration::Compatibility::V6_0 < ActiveRecord::Migration::Current"
121
+ elsif defined?(ActiveRecord::Migration::Compatibility::V5_2)
122
+ store["ActiveRecord::Migration::Compatibility::V5_1"].header = nil
123
+ store["ActiveRecord::Migration::Compatibility::V5_2"].header = "class ActiveRecord::Migration::Compatibility::V5_2 < ActiveRecord::Migration::Current"
117
124
  end
118
125
  end
119
126
  # class_eval in #each
@@ -182,6 +189,13 @@ def generate(out_dir, version)
182
189
  end
183
190
  use Orthoses::DelegateClass
184
191
  use Orthoses::Attribute
192
+ use Orthoses::Railties::Mixin, callback: -> (railties_mixin) {
193
+ Orthoses::CreateFileByName.new(
194
+ ->{ railties_mixin },
195
+ base_dir: "#{out_dir}/#{version}/railties_mixin",
196
+ header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
197
+ ).call
198
+ }
185
199
  use Orthoses::Mixin,
186
200
  if: -> (base_mod, how, mod) {
187
201
  mod != Enumerable # TODO
@@ -251,6 +265,13 @@ def generate_test_script(gem:, version:, export:, stdlib_dependencies:, gem_depe
251
265
  RUBY
252
266
  end
253
267
 
268
+ def generate_manifest(export:, stdlib_dependencies:)
269
+ Pathname(export).join('manifest.yaml').write(<<~YAML)
270
+ dependencies:
271
+ #{stdlib_dependencies.map{"- name: #{_1}"}.join("\n ")}
272
+ YAML
273
+ end
274
+
254
275
  VERSIONS = %w[
255
276
  6.0
256
277
  6.1
@@ -258,57 +279,49 @@ VERSIONS = %w[
258
279
  ]
259
280
  Object.private_constant :VERSIONS
260
281
 
261
- GEMS = %w[
262
- active_support
263
- active_model
264
- active_record
265
- active_job
266
- active_storage
267
- ]
282
+ tasks = Dir["tasks/*"]
283
+ tasks.each do |task|
284
+ load task
285
+ end
286
+ GEMS = tasks.map { File.basename(_1).sub(/\.rake/, '') }
268
287
  Object.private_constant :GEMS
269
288
 
270
289
  task :clean do
271
290
  FileUtils.rm_rf("out")
272
291
  end
273
292
 
274
- namespace :bundle do
275
- task :update do
276
- VERSIONS.each do |version|
277
- sh "BUNDLE_GEMFILE=gemfiles/Gemfile_#{version.tr('.', '_')} bundle update"
278
- end
279
- end
280
- end
281
-
282
293
  VERSIONS.each do |version|
283
294
  namespace version do
284
295
  desc "run all version=#{version}"
285
296
  task :all => [
286
- "#{version}:generate",
287
- *(GEMS.map{"#{version}:#{_1}:export"}),
288
- # *(GEMS.map{"#{version}:#{_1}:validate"}),
289
- # *(GEMS.map{"#{version}:#{_1}:install"})
297
+ :generate,
298
+ :export,
299
+ :validate,
300
+ # :install,
290
301
  ]
291
302
 
303
+ desc "run export version=#{version}"
304
+ task :export => GEMS.map{"#{version}:#{_1}:export"}
305
+
306
+ desc "run validate version=#{version}"
307
+ task :validate => GEMS.map{"#{version}:#{_1}:validate"}
308
+
309
+ desc "run install version=#{version}"
310
+ task :install => GEMS.map{"#{version}:#{_1}:install"}
311
+
292
312
  desc "generate version=#{version}"
293
313
  task :generate do |t|
294
- gemfile = File.expand_path("gemfiles/Gemfile_#{version.tr('.', '_')}")
295
- sh "BUNDLE_GEMFILE=#{gemfile} bundle install"
296
- sh "BUNDLE_GEMFILE=#{gemfile} bundle exec rake #{t.name}_exec"
314
+ switch_branch("#{version.tr('.', '-')}-stable")
315
+ sh "bundle install"
316
+ sh "bundle exec rake #{t.name}_exec"
297
317
  end
298
318
 
299
319
  task :generate_exec do
300
- switch_branch("#{version.tr('.', '-')}-stable")
301
320
  generate("out", version)
302
321
  end
303
322
  end
304
323
  end
305
324
 
306
- load 'tasks/active_job.rake'
307
- load 'tasks/active_model.rake'
308
- load 'tasks/active_record.rake'
309
- load 'tasks/active_storage.rake'
310
- load 'tasks/active_support.rake'
311
-
312
325
  task default: [
313
326
  :clean,
314
327
  *(VERSIONS.map {"#{_1}:all"})
@@ -0,0 +1,4 @@
1
+ module ActionController
2
+ class Metal < AbstractController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveModel::Serialization
2
+ # https://github.com/ruby/rbs/issues/1008
3
+ def send: (Object::name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
4
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveModel::Validations
2
+ # https://github.com/ruby/rbs/issues/1008
3
+ def send: (Object::name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
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,5 @@
1
+ class ActiveRecord::Result
2
+ include Enumerable[Hash[String, untyped]]
3
+ def each: () -> Enumerator[Hash[String, untyped], Array[Hash[String, untyped]]]
4
+ | () { (Hash[String, untyped]) -> void } -> Array[Hash[String, untyped]]
5
+ end