orthoses-rails 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -65
  3. data/lib/generators/orthoses/rails/install_generator.rb +18 -0
  4. data/lib/orthoses/active_record/belongs_to.rb +15 -4
  5. data/lib/orthoses/active_record/enum.rb +5 -0
  6. data/lib/orthoses/active_record/generated_attribute_methods.rb +47 -55
  7. data/lib/orthoses/active_record/has_many.rb +15 -4
  8. data/lib/orthoses/active_record/has_one.rb +12 -2
  9. data/lib/orthoses/active_record/relation.rb +56 -0
  10. data/lib/orthoses/active_record.rb +36 -0
  11. data/lib/orthoses/active_support/delegation.rb +20 -9
  12. data/lib/orthoses/active_support/time_with_zone.rb +35 -28
  13. data/lib/orthoses/rails/application.rb +33 -0
  14. data/lib/orthoses/rails/version.rb +1 -1
  15. data/lib/orthoses/rails.rb +3 -2
  16. metadata +10 -47
  17. data/examples/rails/Gemfile +0 -16
  18. data/examples/rails/Gemfile.lock +0 -179
  19. data/examples/rails/Rakefile +0 -328
  20. data/examples/rails/config/database.yml +0 -8
  21. data/examples/rails/config/storage.yml +0 -3
  22. data/examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs +0 -4
  23. data/examples/rails/known_sig/activemodel/7.0/active_model/serialization.rbs +0 -4
  24. data/examples/rails/known_sig/activemodel/7.0/active_model/validations.rbs +0 -4
  25. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs +0 -49
  26. data/examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs +0 -45
  27. data/examples/rails/known_sig/activerecord/6.0/active_record/result.rbs +0 -5
  28. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs +0 -49
  29. data/examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs +0 -45
  30. data/examples/rails/known_sig/activerecord/6.1/active_record/result.rbs +0 -5
  31. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs +0 -49
  32. data/examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs +0 -45
  33. data/examples/rails/known_sig/activerecord/7.0/active_record/encryption/context.rbs +0 -9
  34. data/examples/rails/known_sig/activerecord/7.0/active_record/result.rbs +0 -5
  35. data/examples/rails/known_sig/activesupport/7.0/active_support/callbacks/callback_chain.rbs +0 -9
  36. data/examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs +0 -4
  37. data/examples/rails/known_sig/activesupport/7.0/active_support/hash_with_indifferent_access.rbs +0 -6
  38. data/examples/rails/known_sig/activesupport/7.0/active_support/multibyte/chars.rbs +0 -7
  39. data/examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs +0 -5
  40. data/examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs +0 -3
  41. data/examples/rails/known_sig/activesupport/7.0/date.rbs +0 -6
  42. data/examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs +0 -4
  43. data/examples/rails/known_sig/activesupport/7.0/hash_with_indifferent_access.rbs +0 -2
  44. data/examples/rails/known_sig/activesupport/7.0/integer.rbs +0 -9
  45. data/examples/rails/known_sig/activesupport/7.0/numeric.rbs +0 -15
  46. data/examples/rails/known_sig/activesupport/7.0/string.rbs +0 -4
  47. data/examples/rails/known_sig/activesupport/7.0/time.rbs +0 -46
  48. data/examples/rails/tasks/action_pack.rake +0 -141
  49. data/examples/rails/tasks/action_view.rake +0 -77
  50. data/examples/rails/tasks/active_job.rake +0 -99
  51. data/examples/rails/tasks/active_model.rake +0 -46
  52. data/examples/rails/tasks/active_record.rake +0 -88
  53. data/examples/rails/tasks/active_storage.rake +0 -94
  54. data/examples/rails/tasks/active_support.rake +0 -99
  55. data/examples/rails/tasks/railties.rake +0 -34
  56. data/orthoses-rails.gemspec +0 -36
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ module Rails
5
+ class Application
6
+ def initialize(loader)
7
+ @loader = loader
8
+ end
9
+
10
+ def call
11
+ loader = @loader
12
+ Orthoses::Builder.new do
13
+ use Orthoses::ActiveModel::HasSecurePassword
14
+ use Orthoses::ActiveRecord::BelongsTo
15
+ use Orthoses::ActiveRecord::DelegatedType
16
+ use Orthoses::ActiveRecord::Enum
17
+ use Orthoses::ActiveRecord::GeneratedAttributeMethods
18
+ use Orthoses::ActiveRecord::HasMany
19
+ use Orthoses::ActiveRecord::HasOne
20
+ use Orthoses::ActiveRecord::Relation
21
+ use Orthoses::ActiveRecord::Scope
22
+
23
+ use Orthoses::ActiveSupport::ClassAttribute
24
+ use Orthoses::ActiveSupport::Concern
25
+ use Orthoses::ActiveSupport::Delegation
26
+ use Orthoses::ActiveSupport::Configurable
27
+ use Orthoses::ActiveSupport::MattrAccessor
28
+ reset_runner loader
29
+ end.call
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Orthoses
4
4
  module Rails
5
- VERSION = "0.8.0"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
@@ -2,9 +2,10 @@
2
2
 
3
3
  require 'orthoses'
4
4
 
5
- require_relative "rails/version"
6
-
7
5
  require_relative 'active_model'
8
6
  require_relative 'active_record'
9
7
  require_relative 'active_support'
10
8
  require_relative 'railties'
9
+
10
+ require_relative "rails/application"
11
+ require_relative "rails/version"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthoses-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orthoses
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.8'
27
27
  description: Orthoses middleware collection for Ruby on Rails
28
28
  email:
29
29
  - co000ri@gmail.com
@@ -34,45 +34,7 @@ files:
34
34
  - CODE_OF_CONDUCT.md
35
35
  - LICENSE.txt
36
36
  - README.md
37
- - examples/rails/Gemfile
38
- - examples/rails/Gemfile.lock
39
- - examples/rails/Rakefile
40
- - examples/rails/config/database.yml
41
- - examples/rails/config/storage.yml
42
- - examples/rails/known_sig/actionpack/7.0/action_controller/metal.rbs
43
- - examples/rails/known_sig/activemodel/7.0/active_model/serialization.rbs
44
- - examples/rails/known_sig/activemodel/7.0/active_model/validations.rbs
45
- - examples/rails/known_sig/activerecord/6.0/_active_record_relation.rbs
46
- - examples/rails/known_sig/activerecord/6.0/_active_record_relation_class_methods.rbs
47
- - examples/rails/known_sig/activerecord/6.0/active_record/result.rbs
48
- - examples/rails/known_sig/activerecord/6.1/_active_record_relation.rbs
49
- - examples/rails/known_sig/activerecord/6.1/_active_record_relation_class_methods.rbs
50
- - examples/rails/known_sig/activerecord/6.1/active_record/result.rbs
51
- - examples/rails/known_sig/activerecord/7.0/_active_record_relation.rbs
52
- - examples/rails/known_sig/activerecord/7.0/_active_record_relation_class_methods.rbs
53
- - examples/rails/known_sig/activerecord/7.0/active_record/encryption/context.rbs
54
- - examples/rails/known_sig/activerecord/7.0/active_record/result.rbs
55
- - examples/rails/known_sig/activesupport/7.0/active_support/callbacks/callback_chain.rbs
56
- - examples/rails/known_sig/activesupport/7.0/active_support/duration.rbs
57
- - examples/rails/known_sig/activesupport/7.0/active_support/hash_with_indifferent_access.rbs
58
- - examples/rails/known_sig/activesupport/7.0/active_support/multibyte/chars.rbs
59
- - examples/rails/known_sig/activesupport/7.0/active_support/time_with_zone.rbs
60
- - examples/rails/known_sig/activesupport/7.0/active_support/time_zone.rbs
61
- - examples/rails/known_sig/activesupport/7.0/date.rbs
62
- - examples/rails/known_sig/activesupport/7.0/date_and_time/zones.rbs
63
- - examples/rails/known_sig/activesupport/7.0/hash_with_indifferent_access.rbs
64
- - examples/rails/known_sig/activesupport/7.0/integer.rbs
65
- - examples/rails/known_sig/activesupport/7.0/numeric.rbs
66
- - examples/rails/known_sig/activesupport/7.0/string.rbs
67
- - examples/rails/known_sig/activesupport/7.0/time.rbs
68
- - examples/rails/tasks/action_pack.rake
69
- - examples/rails/tasks/action_view.rake
70
- - examples/rails/tasks/active_job.rake
71
- - examples/rails/tasks/active_model.rake
72
- - examples/rails/tasks/active_record.rake
73
- - examples/rails/tasks/active_storage.rake
74
- - examples/rails/tasks/active_support.rake
75
- - examples/rails/tasks/railties.rake
37
+ - lib/generators/orthoses/rails/install_generator.rb
76
38
  - lib/orthoses-rails.rb
77
39
  - lib/orthoses/active_model.rb
78
40
  - lib/orthoses/active_model/has_secure_password.rb
@@ -84,6 +46,7 @@ files:
84
46
  - lib/orthoses/active_record/has_many.rb
85
47
  - lib/orthoses/active_record/has_one.rb
86
48
  - lib/orthoses/active_record/query_methods.rb
49
+ - lib/orthoses/active_record/relation.rb
87
50
  - lib/orthoses/active_record/scope.rb
88
51
  - lib/orthoses/active_support.rb
89
52
  - lib/orthoses/active_support/class_attribute.rb
@@ -93,10 +56,10 @@ files:
93
56
  - lib/orthoses/active_support/mattr_accessor.rb
94
57
  - lib/orthoses/active_support/time_with_zone.rb
95
58
  - lib/orthoses/rails.rb
59
+ - lib/orthoses/rails/application.rb
96
60
  - lib/orthoses/rails/version.rb
97
61
  - lib/orthoses/railties.rb
98
62
  - lib/orthoses/railties/mixin.rb
99
- - orthoses-rails.gemspec
100
63
  - sig/orthoses/rails.rbs
101
64
  homepage: https://github.com/ksss/orthoses-rails
102
65
  licenses:
@@ -120,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
83
  - !ruby/object:Gem::Version
121
84
  version: '0'
122
85
  requirements: []
123
- rubygems_version: 3.3.16
86
+ rubygems_version: 3.4.10
124
87
  signing_key:
125
88
  specification_version: 4
126
89
  summary: Orthoses middleware collection for Ruby on Rails
@@ -1,16 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- ruby ">= 3.1.0"
4
-
5
- gemspec path: '../../'
6
-
7
- gem "rails", path: "_src"
8
- gem "sqlite3"
9
- # gem "orthoses", path: "../../../orthoses"
10
-
11
- if RUBY_VERSION >= "3.1"
12
- gem "net-smtp", require: false
13
- gem "net-imap", require: false
14
- gem "net-pop", require: false
15
- gem "psych", "~> 3"
16
- end
@@ -1,179 +0,0 @@
1
- PATH
2
- remote: ../..
3
- specs:
4
- orthoses-rails (0.7.0)
5
- orthoses (~> 1.0)
6
-
7
- PATH
8
- remote: _src
9
- specs:
10
- actioncable (7.0.3.1)
11
- actionpack (= 7.0.3.1)
12
- activesupport (= 7.0.3.1)
13
- nio4r (~> 2.0)
14
- websocket-driver (>= 0.6.1)
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
- mail (>= 2.7.1)
22
- net-imap
23
- net-pop
24
- net-smtp
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
- mail (~> 2.5, >= 2.5.4)
31
- net-imap
32
- net-pop
33
- net-smtp
34
- rails-dom-testing (~> 2.0)
35
- actionpack (7.0.3.1)
36
- actionview (= 7.0.3.1)
37
- activesupport (= 7.0.3.1)
38
- rack (~> 2.0, >= 2.2.0)
39
- rack-test (>= 0.6.3)
40
- rails-dom-testing (~> 2.0)
41
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
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
- globalid (>= 0.6.0)
48
- nokogiri (>= 1.8.5)
49
- actionview (7.0.3.1)
50
- activesupport (= 7.0.3.1)
51
- builder (~> 3.1)
52
- erubi (~> 1.4)
53
- rails-dom-testing (~> 2.0)
54
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
- activejob (7.0.3.1)
56
- activesupport (= 7.0.3.1)
57
- globalid (>= 0.3.6)
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
- marcel (~> 1.0)
69
- mini_mime (>= 1.1.0)
70
- activesupport (7.0.3.1)
71
- concurrent-ruby (~> 1.0, >= 1.0.2)
72
- i18n (>= 1.6, < 2)
73
- minitest (>= 5.1)
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:
100
- builder (3.2.4)
101
- concurrent-ruby (1.1.10)
102
- crass (1.0.6)
103
- digest (3.1.0)
104
- erubi (1.11.0)
105
- globalid (1.0.0)
106
- activesupport (>= 5.0)
107
- i18n (1.12.0)
108
- concurrent-ruby (~> 1.0)
109
- loofah (2.18.0)
110
- crass (~> 1.0.2)
111
- nokogiri (>= 1.5.9)
112
- mail (2.7.1)
113
- mini_mime (>= 0.1.1)
114
- marcel (1.0.2)
115
- method_source (1.0.0)
116
- mini_mime (1.1.2)
117
- mini_portile2 (2.8.0)
118
- minitest (5.16.3)
119
- net-imap (0.2.3)
120
- digest
121
- net-protocol
122
- strscan
123
- net-pop (0.1.1)
124
- digest
125
- net-protocol
126
- timeout
127
- net-protocol (0.1.3)
128
- timeout
129
- net-smtp (0.3.1)
130
- digest
131
- net-protocol
132
- timeout
133
- nio4r (2.5.8)
134
- nokogiri (1.13.8)
135
- mini_portile2 (~> 2.8.0)
136
- racc (~> 1.4)
137
- orthoses (1.0.0)
138
- rbs (~> 2.0)
139
- psych (3.3.3)
140
- racc (1.6.0)
141
- rack (2.2.4)
142
- rack-test (2.0.2)
143
- rack (>= 1.3)
144
- rails-dom-testing (2.0.3)
145
- activesupport (>= 4.2.0)
146
- nokogiri (>= 1.6)
147
- rails-html-sanitizer (1.4.3)
148
- loofah (~> 2.3)
149
- rake (13.0.6)
150
- rbs (2.6.0)
151
- sqlite3 (1.5.0)
152
- mini_portile2 (~> 2.8.0)
153
- strscan (3.0.4)
154
- thor (1.2.1)
155
- timeout (0.3.0)
156
- tzinfo (2.0.5)
157
- concurrent-ruby (~> 1.0)
158
- websocket-driver (0.7.5)
159
- websocket-extensions (>= 0.1.0)
160
- websocket-extensions (0.1.5)
161
- zeitwerk (2.6.0)
162
-
163
- PLATFORMS
164
- arm64-darwin-21
165
-
166
- DEPENDENCIES
167
- net-imap
168
- net-pop
169
- net-smtp
170
- orthoses-rails!
171
- psych (~> 3)
172
- rails!
173
- sqlite3
174
-
175
- RUBY VERSION
176
- ruby 3.1.1p18
177
-
178
- BUNDLED WITH
179
- 2.3.16
@@ -1,328 +0,0 @@
1
- ## run `$ rake`
2
-
3
- def switch_branch(name)
4
- cd "_src" do
5
- sh "git switch #{name}"
6
- end
7
- end
8
-
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
-
18
- loader = -> () {
19
- require "active_support/all"
20
- require "active_record"
21
- require "active_job"
22
- require "active_model"
23
- require "active_storage/engine"
24
- require "action_dispatch"
25
- begin
26
- require "action_mailbox"
27
- require "action_text"
28
- rescue LoadError
29
- end
30
- require "action_mailer"
31
- require "action_pack"
32
- require "action_view"
33
-
34
- roots = [
35
- ActiveSupport,
36
- ActiveModel,
37
- ActiveJob,
38
- ActiveRecord,
39
- ActiveStorage,
40
- ActionDispatch,
41
- ActionMailer,
42
- ActionView,
43
- ]
44
- roots << ActionMailbox if defined?(ActionMailbox)
45
- roots << ActionText if defined?(ActionText)
46
-
47
- roots.each do |rails_mod|
48
- rails_mod.eager_load!
49
- Orthoses::Utils.each_const_recursive(rails_mod, on_error: -> (e) {
50
- Orthoses.logger.warn "skip load const by [#{e.root}][#{e.const}](#{e.error.class})#{e.error.message}"
51
- })
52
- v = rails_mod.respond_to?(:version) ? rails_mod.version : nil
53
- puts "loaded #{rails_mod}: v#{v}"
54
- end
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!
65
- }
66
- Orthoses::Builder.new do
67
- use Orthoses::CreateFileByName,
68
- base_dir: "#{out_dir}/#{version}",
69
- header: "# !!! GENERATED CODE !!!\n# Please see generators/rails-generator"
70
- use Orthoses::Filter do |name, content|
71
- # OMG, both ERB and Erb are exist...
72
- return false if name.start_with?("Erb")
73
-
74
- # ArgumentError
75
- return false if name.start_with?("I18n::Tests")
76
-
77
- # FIXME: too hard
78
- return false if name.include?("::Generators")
79
-
80
- # Ignore known sig
81
- return false if Orthoses::Utils.rbs_defined_class?(name, collection: true) && content.body.empty?
82
-
83
- true
84
- end
85
- use Orthoses::Constant,
86
- strict: false,
87
- if: -> (current, const, _val, _rbs) {
88
- !Orthoses::Utils.rbs_defined_const?("#{current}::#{const}", collection: true)
89
- },
90
- on_error: -> (e) {
91
- Orthoses.logger.warn "[Orthoses::Constant] skip load const by #{e.root}[::#{e.const}] (#{e.error.class}) #{e.error.message}"
92
- }
93
- use Orthoses::ActiveSupport::ClassAttribute
94
- use Orthoses::ActiveSupport::Delegation
95
- use Orthoses::ActiveSupport::MattrAccessor
96
- use Orthoses::ActiveSupport::TimeWithZone
97
- use Orthoses::ActiveRecord::QueryMethods
98
- use Orthoses::LoadRBS,
99
- paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveRecord::VERSION::STRING, "known_sig/activerecord") }
100
- use Orthoses::LoadRBS,
101
- paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveModel::VERSION::STRING, "known_sig/activemodel") }
102
- use Orthoses::LoadRBS,
103
- paths: -> { Orthoses::PathHelper.best_version_paths(::ActiveSupport::VERSION::STRING, "known_sig/activesupport") }
104
- # # require in method
105
- use Orthoses::Tap do |store|
106
- store.delete("DummyERB")
107
- store.delete("DummyCompiler")
108
- end
109
- # see activerecord/lib/active_record/migration/compatibility.rb
110
- use Orthoses::Tap do |store|
111
- # TODO: make middleware
112
- if defined?(ActiveRecord::Migration::Compatibility::V7_0)
113
- store["ActiveRecord::Migration::Compatibility::V6_1"].header = nil
114
- store["ActiveRecord::Migration::Compatibility::V7_0"].header = "class ActiveRecord::Migration::Compatibility::V7_0 < ActiveRecord::Migration::Current"
115
- elsif defined?(ActiveRecord::Migration::Compatibility::V6_1)
116
- store["ActiveRecord::Migration::Compatibility::V6_0"].header = nil
117
- store["ActiveRecord::Migration::Compatibility::V6_1"].header = "class ActiveRecord::Migration::Compatibility::V6_1 < ActiveRecord::Migration::Current"
118
- elsif defined?(ActiveRecord::Migration::Compatibility::V6_0)
119
- store["ActiveRecord::Migration::Compatibility::V5_2"].header = nil
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"
124
- end
125
- end
126
- # class_eval in #each
127
- # see activerecord/lib/active_record/migration/command_recorder.rb
128
- use Orthoses::Tap do |store|
129
- content = store["ActiveRecord::Migration::CommandRecorder"]
130
- ActiveRecord::Migration::CommandRecorder::ReversibleAndIrreversibleMethods.each do |method|
131
- content << "def #{method}: (*untyped args) ?{ () -> void } -> untyped"
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::StraightReversions"]
138
- {
139
- execute_block: :execute_block,
140
- create_table: :drop_table,
141
- create_join_table: :drop_join_table,
142
- add_column: :remove_column,
143
- add_index: :remove_index,
144
- add_timestamps: :remove_timestamps,
145
- add_reference: :remove_reference,
146
- add_foreign_key: :remove_foreign_key,
147
- add_check_constraint: :remove_check_constraint,
148
- enable_extension: :disable_extension
149
- }.each do |cmd, inv|
150
- [[inv, cmd], [cmd, inv]].uniq.each do |method, inverse|
151
- content << "def invert_#{method}: (untyped args) ?{ () -> void } -> [Symbol, untyped, Proc]"
152
- end
153
- end
154
- end
155
- # singleton_class.class_eval in included
156
- use Orthoses::Tap do |store|
157
- store["ActiveRecord::ModelSchema"].body.tap do |body|
158
- body.delete("alias _inheritance_column= inheritance_column=")
159
- body.delete("alias inheritance_column= real_inheritance_column=")
160
- end
161
- end
162
- # alias in included block
163
- use Orthoses::Tap do |store|
164
- store["ActiveRecord::ConnectionAdapters::ColumnMethods"].body.tap do |body|
165
- body.delete("alias blob binary")
166
- body.delete("alias numeric decimal")
167
- end
168
- end
169
- # > Use async_exec instead of exec_params on pg versions before 1.1
170
- use Orthoses::Tap do |store|
171
- store["PG::Connection"].body.clear
172
- end
173
- # Entrust to auto super class
174
- use Orthoses::Tap do |store|
175
- store.each do |_, content|
176
- if content.header&.include?(" < Type::")
177
- content.header.sub!(/ < Type::(.*)/, " < ::ActiveModel::Type::\\1")
178
- end
179
- # delegate to auto_header
180
- if content.header&.start_with?("class Arel")
181
- content.header = nil
182
- end
183
- end
184
- store["ActionView::Helpers::Tags::CollectionRadioButtons::RadioButtonBuilder"].header = nil
185
- store["ActionView::Helpers::Tags::CollectionCheckBoxes::CheckBoxBuilder"].header = nil
186
- store["ActionView::SyntaxErrorInTemplate"].header = nil
187
- # MigrationProxy cannot resolve name since class alias.
188
- store["ActiveRecord::NullMigration"].header = nil
189
- end
190
- use Orthoses::DelegateClass
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
- }
199
- use Orthoses::Mixin,
200
- if: -> (base_mod, how, mod) {
201
- mod != Enumerable # TODO
202
- }
203
- use Orthoses::RBSPrototypeRB,
204
- paths: Dir.glob('_src/{railties,action{cable,mailbox,mailer,pack,text,view},active{job,model,record,storage,support}}/{app,lib}/**/*.rb'),
205
- constant_filter: -> (member) { false },
206
- mixin_filter: -> (member) { false },
207
- attribute_filter: -> (member) { false }
208
- use Orthoses::Autoload
209
- run loader
210
- end.call
211
-
212
- # $ cat out/7.0/**/*.rbs | wc
213
- # 69763 339342 2606899
214
- end
215
-
216
- def generate_test_script(gem:, version:, export:, stdlib_dependencies:, gem_dependencies:, rails_dependencies:)
217
- Pathname(export).join('_scripts').tap(&:mkdir).join('test').write(<<~SHELL)
218
- #!/usr/bin/env bash
219
-
220
- # !!! GENERATED CODE !!!
221
- # Please see generators/rails-generator
222
-
223
- # set -eou => Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
224
- set -eou pipefail
225
- # Internal Field Separator - Linux shell variable
226
- IFS=$'\n\t'
227
- # Print shell input lines
228
- set -v
229
-
230
- # Set RBS_DIR variable to change directory to execute type checks using `steep check`
231
- RBS_DIR=$(cd $(dirname $0)/..; pwd)
232
- # Set REPO_DIR variable to validate RBS files added to the corresponding folder
233
- REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
234
- # Validate RBS files, using the bundler environment present
235
- bundle exec rbs --repo=$REPO_DIR #{stdlib_dependencies.map{"-r #{_1}"}.join(" ")} \\
236
- #{gem_dependencies.map{"-r #{_1}"}.join(" ")} \\
237
- -r #{gem} validate --silent
238
-
239
- cd ${RBS_DIR}/_test
240
- # Run type checks
241
- bundle exec steep check
242
- SHELL
243
-
244
- sh "chmod +x #{Pathname(export).join('_scripts').join('test')}"
245
-
246
- Pathname(export).join('_test').tap(&:mkdir).join('Steepfile').write(<<~RUBY)
247
- # !!! GENERATED CODE !!!
248
- # Please see generators/rails-generator
249
-
250
- D = Steep::Diagnostic
251
-
252
- target :test do
253
- signature "."
254
- check "."
255
-
256
- repo_path "../../../"
257
-
258
- #{stdlib_dependencies.map{" library \"#{_1}\""}.join("\n")}
259
- #{gem_dependencies.map{" library \"#{_1}\""}.join("\n")}
260
-
261
- library "#{gem}:#{version}"
262
-
263
- configure_code_diagnostics(D::Ruby.all_error)
264
- end
265
- RUBY
266
- end
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
-
275
- VERSIONS = %w[
276
- 6.0
277
- 6.1
278
- 7.0
279
- ]
280
- Object.private_constant :VERSIONS
281
-
282
- tasks = Dir["tasks/*"]
283
- tasks.each do |task|
284
- load task
285
- end
286
- GEMS = tasks.map { File.basename(_1).sub(/\.rake/, '') }
287
- Object.private_constant :GEMS
288
-
289
- task :clean do
290
- FileUtils.rm_rf("out")
291
- end
292
-
293
- VERSIONS.each do |version|
294
- namespace version do
295
- desc "run all version=#{version}"
296
- task :all => [
297
- :generate,
298
- :export,
299
- :validate,
300
- # :install,
301
- ]
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
-
312
- desc "generate version=#{version}"
313
- task :generate do |t|
314
- switch_branch("#{version.tr('.', '-')}-stable")
315
- sh "bundle install"
316
- sh "bundle exec rake #{t.name}_exec"
317
- end
318
-
319
- task :generate_exec do
320
- generate("out", version)
321
- end
322
- end
323
- end
324
-
325
- task default: [
326
- :clean,
327
- *(VERSIONS.map {"#{_1}:all"})
328
- ]
@@ -1,8 +0,0 @@
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