orthoses-rails 0.2.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/examples/rails/Rakefile +315 -0
  3. data/examples/rails/config/database.yml +8 -0
  4. data/examples/rails/config/storage.yml +3 -0
  5. data/examples/rails/gemfiles/Gemfile_6_0 +16 -0
  6. data/examples/rails/gemfiles/Gemfile_6_0.lock +172 -0
  7. data/examples/rails/gemfiles/Gemfile_6_1 +15 -0
  8. data/examples/rails/gemfiles/Gemfile_6_1.lock +173 -0
  9. data/examples/rails/gemfiles/Gemfile_7_0 +15 -0
  10. data/examples/rails/gemfiles/Gemfile_7_0.lock +172 -0
  11. data/examples/rails/tasks/active_job.rake +95 -0
  12. data/examples/rails/tasks/active_model.rake +46 -0
  13. data/examples/rails/tasks/active_record.rake +83 -0
  14. data/examples/rails/tasks/active_storage.rake +94 -0
  15. data/examples/rails/tasks/active_support.rake +92 -0
  16. data/lib/orthoses/active_model/has_secure_password.rb +12 -5
  17. data/lib/orthoses/active_model.rb +3 -0
  18. data/lib/orthoses/active_record/query_methods.rb +32 -0
  19. data/lib/orthoses/active_record.rb +7 -0
  20. data/lib/orthoses/active_support/class_attribute.rb +25 -14
  21. data/lib/orthoses/active_support/configurable.rb +36 -0
  22. data/lib/orthoses/active_support/delegation.rb +158 -0
  23. data/lib/orthoses/active_support/mattr_accessor.rb +18 -10
  24. data/lib/orthoses/active_support/time_with_zone.rb +34 -18
  25. data/lib/orthoses/active_support.rb +22 -0
  26. data/lib/orthoses/rails/version.rb +1 -1
  27. data/lib/orthoses/rails.rb +3 -11
  28. data/orthoses-rails.gemspec +1 -1
  29. metadata +25 -8
  30. data/lib/orthoses/active_support/concern.rb +0 -24
  31. data/lib/orthoses/active_support/known_sig/active_support/time_with_zone.rbs +0 -4
  32. data/lib/orthoses/active_support/known_sig/time.rbs +0 -64
@@ -0,0 +1,173 @@
1
+ PATH
2
+ remote: ../../..
3
+ specs:
4
+ orthoses-rails (0.4.0)
5
+ orthoses (>= 0.10)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.6)
11
+ actionpack (= 6.1.6)
12
+ activesupport (= 6.1.6)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.6)
16
+ actionpack (= 6.1.6)
17
+ activejob (= 6.1.6)
18
+ activerecord (= 6.1.6)
19
+ activestorage (= 6.1.6)
20
+ activesupport (= 6.1.6)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.6)
23
+ actionpack (= 6.1.6)
24
+ actionview (= 6.1.6)
25
+ activejob (= 6.1.6)
26
+ activesupport (= 6.1.6)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.6)
30
+ actionview (= 6.1.6)
31
+ activesupport (= 6.1.6)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.6)
37
+ actionpack (= 6.1.6)
38
+ activerecord (= 6.1.6)
39
+ activestorage (= 6.1.6)
40
+ activesupport (= 6.1.6)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.6)
43
+ activesupport (= 6.1.6)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.6)
49
+ activesupport (= 6.1.6)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.6)
52
+ activesupport (= 6.1.6)
53
+ activerecord (6.1.6)
54
+ activemodel (= 6.1.6)
55
+ activesupport (= 6.1.6)
56
+ activestorage (6.1.6)
57
+ actionpack (= 6.1.6)
58
+ activejob (= 6.1.6)
59
+ activerecord (= 6.1.6)
60
+ activesupport (= 6.1.6)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.6)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ builder (3.2.4)
70
+ concurrent-ruby (1.1.10)
71
+ crass (1.0.6)
72
+ digest (3.1.0)
73
+ erubi (1.10.0)
74
+ globalid (1.0.0)
75
+ activesupport (>= 5.0)
76
+ i18n (1.10.0)
77
+ concurrent-ruby (~> 1.0)
78
+ loofah (2.18.0)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (1.0.2)
84
+ method_source (1.0.0)
85
+ mini_mime (1.1.2)
86
+ mini_portile2 (2.8.0)
87
+ minitest (5.16.1)
88
+ net-imap (0.2.3)
89
+ digest
90
+ net-protocol
91
+ strscan
92
+ net-pop (0.1.1)
93
+ digest
94
+ net-protocol
95
+ timeout
96
+ net-protocol (0.1.3)
97
+ timeout
98
+ net-smtp (0.3.1)
99
+ digest
100
+ net-protocol
101
+ timeout
102
+ nio4r (2.5.8)
103
+ nokogiri (1.13.6)
104
+ mini_portile2 (~> 2.8.0)
105
+ racc (~> 1.4)
106
+ orthoses (0.10.0)
107
+ rbs (~> 2.0)
108
+ racc (1.6.0)
109
+ rack (2.2.3.1)
110
+ rack-test (2.0.0)
111
+ rack (>= 1.3)
112
+ rails (6.1.6)
113
+ actioncable (= 6.1.6)
114
+ actionmailbox (= 6.1.6)
115
+ actionmailer (= 6.1.6)
116
+ actionpack (= 6.1.6)
117
+ actiontext (= 6.1.6)
118
+ actionview (= 6.1.6)
119
+ activejob (= 6.1.6)
120
+ activemodel (= 6.1.6)
121
+ activerecord (= 6.1.6)
122
+ activestorage (= 6.1.6)
123
+ activesupport (= 6.1.6)
124
+ bundler (>= 1.15.0)
125
+ railties (= 6.1.6)
126
+ sprockets-rails (>= 2.0.0)
127
+ rails-dom-testing (2.0.3)
128
+ activesupport (>= 4.2.0)
129
+ nokogiri (>= 1.6)
130
+ rails-html-sanitizer (1.4.3)
131
+ loofah (~> 2.3)
132
+ railties (6.1.6)
133
+ actionpack (= 6.1.6)
134
+ activesupport (= 6.1.6)
135
+ method_source
136
+ rake (>= 12.2)
137
+ thor (~> 1.0)
138
+ rake (13.0.6)
139
+ rbs (2.6.0)
140
+ sprockets (4.1.0)
141
+ concurrent-ruby (~> 1.0)
142
+ rack (> 1, < 3)
143
+ sprockets-rails (3.4.2)
144
+ actionpack (>= 5.2)
145
+ activesupport (>= 5.2)
146
+ sprockets (>= 3.0.0)
147
+ sqlite3 (1.4.4)
148
+ strscan (3.0.3)
149
+ thor (1.2.1)
150
+ timeout (0.3.0)
151
+ tzinfo (2.0.4)
152
+ concurrent-ruby (~> 1.0)
153
+ websocket-driver (0.7.5)
154
+ websocket-extensions (>= 0.1.0)
155
+ websocket-extensions (0.1.5)
156
+ zeitwerk (2.6.0)
157
+
158
+ PLATFORMS
159
+ ruby
160
+
161
+ DEPENDENCIES
162
+ net-imap
163
+ net-pop
164
+ net-smtp
165
+ orthoses-rails!
166
+ rails (>= 6.1, < 7)
167
+ sqlite3
168
+
169
+ RUBY VERSION
170
+ ruby 3.1.1p18
171
+
172
+ BUNDLED WITH
173
+ 2.3.9
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "~> 3.1.0"
4
+
5
+ gemspec path: '../../../'
6
+
7
+ gem "rails", ">= 7.0", "< 7.1"
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
+ end
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: ../../..
3
+ specs:
4
+ orthoses-rails (0.4.0)
5
+ orthoses (>= 0.10)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.3)
11
+ actionpack (= 7.0.3)
12
+ activesupport (= 7.0.3)
13
+ nio4r (~> 2.0)
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)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
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)
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)
36
+ actionview (= 7.0.3)
37
+ activesupport (= 7.0.3)
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)
43
+ actionpack (= 7.0.3)
44
+ activerecord (= 7.0.3)
45
+ activestorage (= 7.0.3)
46
+ activesupport (= 7.0.3)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.3)
50
+ activesupport (= 7.0.3)
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)
56
+ activesupport (= 7.0.3)
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)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.3)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ builder (3.2.4)
76
+ concurrent-ruby (1.1.10)
77
+ crass (1.0.6)
78
+ digest (3.1.0)
79
+ erubi (1.10.0)
80
+ globalid (1.0.0)
81
+ activesupport (>= 5.0)
82
+ i18n (1.10.0)
83
+ concurrent-ruby (~> 1.0)
84
+ loofah (2.18.0)
85
+ crass (~> 1.0.2)
86
+ nokogiri (>= 1.5.9)
87
+ mail (2.7.1)
88
+ mini_mime (>= 0.1.1)
89
+ marcel (1.0.2)
90
+ method_source (1.0.0)
91
+ mini_mime (1.1.2)
92
+ mini_portile2 (2.8.0)
93
+ minitest (5.16.1)
94
+ net-imap (0.2.3)
95
+ digest
96
+ net-protocol
97
+ strscan
98
+ net-pop (0.1.1)
99
+ digest
100
+ net-protocol
101
+ timeout
102
+ net-protocol (0.1.3)
103
+ timeout
104
+ net-smtp (0.3.1)
105
+ digest
106
+ net-protocol
107
+ timeout
108
+ nio4r (2.5.8)
109
+ nokogiri (1.13.6)
110
+ mini_portile2 (~> 2.8.0)
111
+ racc (~> 1.4)
112
+ orthoses (0.10.0)
113
+ rbs (~> 2.0)
114
+ racc (1.6.0)
115
+ rack (2.2.3.1)
116
+ rack-test (2.0.0)
117
+ 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
+ rails-dom-testing (2.0.3)
133
+ activesupport (>= 4.2.0)
134
+ nokogiri (>= 1.6)
135
+ rails-html-sanitizer (1.4.3)
136
+ 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
+ rake (13.0.6)
145
+ rbs (2.6.0)
146
+ sqlite3 (1.4.4)
147
+ strscan (3.0.3)
148
+ thor (1.2.1)
149
+ timeout (0.3.0)
150
+ tzinfo (2.0.4)
151
+ concurrent-ruby (~> 1.0)
152
+ websocket-driver (0.7.5)
153
+ websocket-extensions (>= 0.1.0)
154
+ websocket-extensions (0.1.5)
155
+ zeitwerk (2.6.0)
156
+
157
+ PLATFORMS
158
+ ruby
159
+
160
+ DEPENDENCIES
161
+ net-imap
162
+ net-pop
163
+ net-smtp
164
+ orthoses-rails!
165
+ rails (>= 7.0, < 7.1)
166
+ sqlite3
167
+
168
+ RUBY VERSION
169
+ ruby 3.1.1p18
170
+
171
+ BUNDLED WITH
172
+ 2.3.9
@@ -0,0 +1,95 @@
1
+ stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest]
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
+ RBS
28
+
29
+ generate_test_script(
30
+ gem: :activejob,
31
+ version: version,
32
+ export: export,
33
+ stdlib_dependencies: stdlib_dependencies,
34
+ gem_dependencies: gem_dependencies,
35
+ rails_dependencies: rails_dependencies,
36
+ )
37
+
38
+ Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
39
+ # !!! GENERATED CODE !!!
40
+ # Please see generators/rails-generator
41
+
42
+ class SendMessageJob < ActiveJob::Base
43
+ queue_as :default
44
+ self.queue_adapter = :sidekiq
45
+
46
+ before_enqueue do |job|
47
+ # before enqueued
48
+ end
49
+
50
+ around_perform :around_task
51
+
52
+ def perform(*args)
53
+ # Do something later
54
+ end
55
+
56
+ private
57
+
58
+ def around_task
59
+ # Do something before
60
+ # yield
61
+ # Do something after
62
+ end
63
+ end
64
+
65
+ SendMessageJob.perform_now
66
+ SendMessageJob.set(queue: :another_queue).perform_later(flag: false)
67
+ RUBY
68
+
69
+ Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
70
+ # !!! GENERATED CODE !!!
71
+ # Please see generators/rails-generator
72
+
73
+ class SendMessageJob < ActiveJob::Base
74
+ def perform: (*untyped) -> void
75
+ end
76
+ RBS
77
+ end
78
+
79
+ desc "validate version=#{version} gem=active_job"
80
+ task :validate do
81
+ stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
82
+ gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
83
+ rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
84
+ sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
85
+ end
86
+
87
+ desc "install to ../../../gems/activejob/#{version}"
88
+ task :install do
89
+ install_to = File.expand_path("../../../gems/activejob/#{version}", __dir__)
90
+ sh "rm -fr #{install_to}"
91
+ sh "cp -a #{export} #{install_to}"
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,46 @@
1
+ stdlib_dependencies = %w[benchmark date digest forwardable json logger monitor mutex_m singleton time]
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
@@ -0,0 +1,83 @@
1
+ stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest forwardable did_you_mean openssl socket]
2
+ gem_dependencies = %w[nokogiri]
3
+ rails_dependencies = %w[activesupport activemodel activejob]
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
+ sh "rm #{export}/active_record/railtie.rbs"
21
+ sh "cat out/#{version}/active_record/base.rbs | grep -v ActiveStorage > #{export}/active_record/base.rbs"
22
+
23
+ Pathname(export).join("EXTERNAL_TODO.rbs").write(<<~RBS)
24
+ # !!! GENERATED CODE !!!
25
+ # Please see generators/rails-generator
26
+
27
+ module PG
28
+ class SimpleDecoder
29
+ end
30
+ end
31
+ module GlobalID
32
+ module Identification
33
+ end
34
+ module FixtureSet
35
+ end
36
+ end
37
+ RBS
38
+
39
+ generate_test_script(
40
+ gem: :activerecord,
41
+ version: version,
42
+ export: export,
43
+ stdlib_dependencies: stdlib_dependencies,
44
+ gem_dependencies: gem_dependencies,
45
+ rails_dependencies: rails_dependencies,
46
+ )
47
+
48
+ Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
49
+ # !!! GENERATED CODE !!!
50
+ # Please see generators/rails-generator
51
+
52
+ class User < ActiveRecord::Base
53
+ end
54
+
55
+ user = User.new
56
+ RUBY
57
+
58
+ Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
59
+ # !!! GENERATED CODE !!!
60
+ # Please see generators/rails-generator
61
+
62
+ class User < ActiveRecord::Base
63
+ end
64
+ RBS
65
+ end
66
+
67
+ desc "validate version=#{version} gem=active_record"
68
+ task :validate do
69
+ stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
70
+ gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
71
+ rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
72
+ sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
73
+ end
74
+
75
+ desc "install to ../../../gems/activerecord/#{version}"
76
+ task :install do
77
+ install_to = File.expand_path("../../../gems/activerecord/#{version}", __dir__)
78
+ sh "rm -fr #{install_to}"
79
+ sh "cp -a #{export} #{install_to}"
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,94 @@
1
+ require 'rbs'
2
+
3
+ stdlib_dependencies = %w[time monitor singleton logger mutex_m json date benchmark digest forwardable did_you_mean openssl socket]
4
+ gem_dependencies = %w[nokogiri]
5
+ rails_dependencies = %w[activesupport activemodel activejob activerecord]
6
+
7
+ VERSIONS.each do |version|
8
+ namespace version do
9
+ namespace :active_storage do
10
+ export = "export/activestorage/#{version}"
11
+
12
+ desc "export to #{export}"
13
+ task :export do
14
+ sh "rm -fr #{export}"
15
+ sh "mkdir -p #{export}"
16
+
17
+ # base
18
+ sh "cp -a out/#{version}/active_storage.rbs #{export}"
19
+ sh "cp -a out/#{version}/active_storage #{export}"
20
+ sh "rm #{export}/active_storage/engine.rbs"
21
+ decls = RBS::Parser.parse_signature(RBS::Buffer.new(
22
+ content: File.read("out/#{version}/active_record/base.rbs"),
23
+ name: "out/#{version}/active_record/base.rbs"
24
+ )).map do |decl|
25
+ decl.members.select! do |member|
26
+ case member
27
+ when RBS::AST::Members::Mixin
28
+ # Remove ActiveStorage
29
+ member.name.to_s.include?("ActiveStorage")
30
+ end
31
+ end
32
+ decl
33
+ end
34
+ File.open("#{export}/active_record_base.rbs", "w+") do |f|
35
+ RBS::Writer.new(out: f).write(decls)
36
+ end
37
+
38
+ # TODO: remove after support action_controller
39
+ sh "rm -fr #{export}/active_storage/blobs"
40
+ sh "rm -fr #{export}/active_storage/representations"
41
+ Dir.glob("#{export}/active_storage/*_controller.rbs").each do |controller|
42
+ sh "rm -f #{controller}"
43
+ end
44
+ sh "rm -f #{export}/active_storage/streaming.rbs"
45
+
46
+ generate_test_script(
47
+ gem: :activestorage,
48
+ version: version,
49
+ export: export,
50
+ stdlib_dependencies: stdlib_dependencies,
51
+ gem_dependencies: gem_dependencies,
52
+ rails_dependencies: rails_dependencies,
53
+ )
54
+
55
+ Pathname(export).join('_test').join('test.rb').write(<<~RUBY)
56
+ # !!! GENERATED CODE !!!
57
+ # Please see generators/rails-generator
58
+
59
+ class User < ActiveRecord::Base
60
+ has_one_attached :one_image
61
+ has_many_attached :many_image
62
+ end
63
+
64
+ user = User.new
65
+ one = ActiveStorage::Attached::One.new("one_image", user)
66
+ one.url
67
+ RUBY
68
+
69
+ Pathname(export).join('_test').join('test.rbs').write(<<~RBS)
70
+ # !!! GENERATED CODE !!!
71
+ # Please see generators/rails-generator
72
+
73
+ class User < ActiveRecord::Base
74
+ end
75
+ RBS
76
+ end
77
+
78
+ desc "validate version=#{version} gem=active_storage"
79
+ task :validate do
80
+ stdlib_opt = stdlib_dependencies.map{"-r #{_1}"}.join(" ")
81
+ gem_opt = gem_dependencies.map{"-I ../../.gem_rbs_collection/#{_1}"}.join(" ")
82
+ rails_opt = rails_dependencies.map{"-I export/#{_1}/#{version}"}.join(" ")
83
+ sh "rbs #{stdlib_opt} #{gem_opt} #{rails_opt} -I #{export} validate --silent"
84
+ end
85
+
86
+ desc "install to ../../../gems/activestorage/#{version}"
87
+ task :install do
88
+ install_to = File.expand_path("../../../gems/activestorage/#{version}", __dir__)
89
+ sh "rm -fr #{install_to}"
90
+ sh "cp -a #{export} #{install_to}"
91
+ end
92
+ end
93
+ end
94
+ end