sorbet-rails 0.7.33 → 0.7.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci-master.yml +1 -1
  3. data/.github/workflows/ci.yml +1 -1
  4. data/CONTRIBUTING.md +1 -0
  5. data/Gemfile +4 -0
  6. data/README.md +1 -1
  7. data/Rakefile +27 -1
  8. data/lib/sorbet-rails/active_record_rbi_formatter.rb +1 -1
  9. data/lib/sorbet-rails/model_plugins/active_record_querying.rb +14 -0
  10. data/lib/sorbet-rails/rails_mixins/active_record_overrides.rb +1 -1
  11. data/lib/sorbet-rails/tasks/rails_rbi.rake +15 -0
  12. data/sorbet-rails.gemspec +1 -1
  13. data/spec/bin/run_all_specs.sh +1 -0
  14. data/spec/generators/rails-template.rb +2 -7
  15. data/spec/rails_helper.rb +2 -0
  16. data/spec/rake_rails_rbi_models_spec.rb +1 -1
  17. data/spec/support/v5.2/sorbet_test_cases.rb +8 -0
  18. data/spec/support/v6.0/sorbet_test_cases.rb +8 -0
  19. data/spec/support/v6.1/sorbet_test_cases.rb +8 -0
  20. data/spec/support/v7.0/.gitattributes +7 -0
  21. data/spec/support/v7.0/.gitignore +35 -0
  22. data/spec/support/v7.0/Gemfile +48 -0
  23. data/spec/support/v7.0/Gemfile.lock +218 -0
  24. data/spec/support/v7.0/README.md +24 -0
  25. data/spec/support/v7.0/Rakefile +6 -0
  26. data/spec/support/v7.0/app/assets/images/.keep +0 -0
  27. data/spec/support/v7.0/app/assets/stylesheets/application.css +1 -0
  28. data/spec/support/v7.0/app/controllers/application_controller.rb +3 -0
  29. data/spec/support/v7.0/app/controllers/concerns/.keep +0 -0
  30. data/spec/support/v7.0/app/helpers/application_helper.rb +3 -0
  31. data/spec/support/v7.0/app/helpers/bar_helper.rb +3 -0
  32. data/spec/support/v7.0/app/helpers/baz_helper.rb +3 -0
  33. data/spec/support/v7.0/app/helpers/foo_helper.rb +3 -0
  34. data/spec/support/v7.0/app/jobs/application_job.rb +8 -0
  35. data/spec/support/v7.0/app/jobs/award_house_point_hourglasses.rb +12 -0
  36. data/spec/support/v7.0/app/mailers/application_mailer.rb +5 -0
  37. data/spec/support/v7.0/app/mailers/daily_prophet_mailer.rb +9 -0
  38. data/spec/support/v7.0/app/mailers/hogwarts_acceptance_mailer.rb +29 -0
  39. data/spec/support/v7.0/app/models/application_record.rb +4 -0
  40. data/spec/support/v7.0/app/models/concerns/.keep +0 -0
  41. data/spec/support/v7.0/app/models/concerns/mythical.rb +11 -0
  42. data/spec/support/v7.0/app/models/headmaster.rb +8 -0
  43. data/spec/support/v7.0/app/models/potion.rb +6 -0
  44. data/spec/support/v7.0/app/models/robe.rb +4 -0
  45. data/spec/support/v7.0/app/models/school.rb +5 -0
  46. data/spec/support/v7.0/app/models/spell.rb +5 -0
  47. data/spec/support/v7.0/app/models/spell_book.rb +18 -0
  48. data/spec/support/v7.0/app/models/squib.rb +6 -0
  49. data/spec/support/v7.0/app/models/subject.rb +5 -0
  50. data/spec/support/v7.0/app/models/wand.rb +19 -0
  51. data/spec/support/v7.0/app/models/wizard.rb +65 -0
  52. data/spec/support/v7.0/app/views/layouts/application.html.erb +15 -0
  53. data/spec/support/v7.0/app/views/layouts/mailer.html.erb +13 -0
  54. data/spec/support/v7.0/app/views/layouts/mailer.text.erb +1 -0
  55. data/spec/support/v7.0/bin/bundle +114 -0
  56. data/spec/support/v7.0/bin/rails +4 -0
  57. data/spec/support/v7.0/bin/rake +4 -0
  58. data/spec/support/v7.0/bin/setup +33 -0
  59. data/spec/support/v7.0/config/application.rb +38 -0
  60. data/spec/support/v7.0/config/boot.rb +4 -0
  61. data/spec/support/v7.0/config/database.yml +25 -0
  62. data/spec/support/v7.0/config/environment.rb +6 -0
  63. data/spec/support/v7.0/config/environments/development.rb +69 -0
  64. data/spec/support/v7.0/config/environments/production.rb +83 -0
  65. data/spec/support/v7.0/config/environments/test.rb +61 -0
  66. data/spec/support/v7.0/config/initializers/content_security_policy.rb +26 -0
  67. data/spec/support/v7.0/config/initializers/filter_parameter_logging.rb +9 -0
  68. data/spec/support/v7.0/config/initializers/inflections.rb +17 -0
  69. data/spec/support/v7.0/config/initializers/permissions_policy.rb +12 -0
  70. data/spec/support/v7.0/config/initializers/sorbet_rails.rb +3 -0
  71. data/spec/support/v7.0/config/locales/en.yml +33 -0
  72. data/spec/support/v7.0/config/puma.rb +44 -0
  73. data/spec/support/v7.0/config/routes.rb +8 -0
  74. data/spec/support/v7.0/config/storage.yml +34 -0
  75. data/spec/support/v7.0/config.ru +6 -0
  76. data/spec/support/v7.0/db/migrate/20190620000001_create_wizards.rb +14 -0
  77. data/spec/support/v7.0/db/migrate/20190620000002_create_wands.rb +12 -0
  78. data/spec/support/v7.0/db/migrate/20190620000003_create_spell_books.rb +10 -0
  79. data/spec/support/v7.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +14 -0
  80. data/spec/support/v7.0/db/migrate/20190620000005_add_broom_to_wizard.rb +6 -0
  81. data/spec/support/v7.0/db/migrate/20190620000006_add_more_enums_to_wizard.rb +9 -0
  82. data/spec/support/v7.0/db/migrate/20190620000007_add_type_to_wizard.rb +6 -0
  83. data/spec/support/v7.0/db/migrate/20190620000008_add_robe_to_wizard.rb +8 -0
  84. data/spec/support/v7.0/db/migrate/20190620000009_add_school.rb +10 -0
  85. data/spec/support/v7.0/db/migrate/20190620000010_add_subject.rb +8 -0
  86. data/spec/support/v7.0/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
  87. data/spec/support/v7.0/db/migrate/20190620000012_add_spell.rb +8 -0
  88. data/spec/support/v7.0/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
  89. data/spec/support/v7.0/db/migrate/20190620000014_create_headmasters.rb +9 -0
  90. data/spec/support/v7.0/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
  91. data/spec/support/v7.0/db/schema.rb +98 -0
  92. data/spec/support/v7.0/db/seeds.rb +8 -0
  93. data/spec/support/v7.0/lib/assets/.keep +0 -0
  94. data/spec/support/v7.0/lib/mythical_rbi_plugin.rb +16 -0
  95. data/spec/support/v7.0/lib/tasks/.keep +0 -0
  96. data/spec/support/v7.0/log/.keep +0 -0
  97. data/spec/support/v7.0/sorbet_test_cases.rb +439 -0
  98. data/spec/support/v7.0/storage/.keep +0 -0
  99. data/spec/support/v7.0/tmp/.keep +0 -0
  100. data/spec/support/v7.0/tmp/pids/.keep +0 -0
  101. data/spec/support/v7.0/tmp/storage/.keep +0 -0
  102. data/spec/support/v7.0/vendor/.keep +0 -0
  103. data/spec/test_data/v5.2/expected_active_record_base.rbi +6 -0
  104. data/spec/test_data/v5.2/expected_active_record_relation.rbi +6 -0
  105. data/spec/test_data/v6.0/expected_active_record_base.rbi +6 -0
  106. data/spec/test_data/v6.0/expected_active_record_relation.rbi +6 -0
  107. data/spec/test_data/v6.1/expected_active_record_base.rbi +6 -0
  108. data/spec/test_data/v6.1/expected_active_record_relation.rbi +6 -0
  109. data/spec/test_data/v7.0/expected_active_record_base.rbi +119 -0
  110. data/spec/test_data/v7.0/expected_active_record_relation.rbi +180 -0
  111. data/spec/test_data/v7.0/expected_application_job.rbi +20 -0
  112. data/spec/test_data/v7.0/expected_application_mailer.rbi +5 -0
  113. data/spec/test_data/v7.0/expected_attachment.rbi +358 -0
  114. data/spec/test_data/v7.0/expected_award_house_point_hourglasses.rbi +20 -0
  115. data/spec/test_data/v7.0/expected_blob.rbi +394 -0
  116. data/spec/test_data/v7.0/expected_custom_application_job.rbi +21 -0
  117. data/spec/test_data/v7.0/expected_custom_application_mailer.rbi +6 -0
  118. data/spec/test_data/v7.0/expected_custom_award_house_point_hourglasses.rbi +21 -0
  119. data/spec/test_data/v7.0/expected_custom_daily_prophet_mailer.rbi +8 -0
  120. data/spec/test_data/v7.0/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
  121. data/spec/test_data/v7.0/expected_daily_prophet_mailer.rbi +7 -0
  122. data/spec/test_data/v7.0/expected_headmaster.rbi +376 -0
  123. data/spec/test_data/v7.0/expected_helpers.rbi +27 -0
  124. data/spec/test_data/v7.0/expected_helpers_with_application_and_devise_helpers.rbi +34 -0
  125. data/spec/test_data/v7.0/expected_hogwarts_acceptance_mailer.rbi +20 -0
  126. data/spec/test_data/v7.0/expected_internal_metadata.rbi +346 -0
  127. data/spec/test_data/v7.0/expected_no_routes.rbi +4 -0
  128. data/spec/test_data/v7.0/expected_potion.rbi +328 -0
  129. data/spec/test_data/v7.0/expected_record.rbi +307 -0
  130. data/spec/test_data/v7.0/expected_robe.rbi +349 -0
  131. data/spec/test_data/v7.0/expected_routes.rbi +182 -0
  132. data/spec/test_data/v7.0/expected_schema_migration.rbi +319 -0
  133. data/spec/test_data/v7.0/expected_school.rbi +349 -0
  134. data/spec/test_data/v7.0/expected_spell/habtm_spell_books.rbi +367 -0
  135. data/spec/test_data/v7.0/expected_spell.rbi +340 -0
  136. data/spec/test_data/v7.0/expected_spell_book/habtm_spells.rbi +367 -0
  137. data/spec/test_data/v7.0/expected_spell_book.rbi +499 -0
  138. data/spec/test_data/v7.0/expected_squib.rbi +1204 -0
  139. data/spec/test_data/v7.0/expected_srb_tc_output.txt +1 -0
  140. data/spec/test_data/v7.0/expected_subject/habtm_wizards.rbi +367 -0
  141. data/spec/test_data/v7.0/expected_subject.rbi +340 -0
  142. data/spec/test_data/v7.0/expected_variant_record.rbi +382 -0
  143. data/spec/test_data/v7.0/expected_wand.rbi +611 -0
  144. data/spec/test_data/v7.0/expected_wizard/habtm_subjects.rbi +367 -0
  145. data/spec/test_data/v7.0/expected_wizard.rbi +1280 -0
  146. data/spec/test_data/v7.0/expected_wizard_wo_spellbook.rbi +1274 -0
  147. metadata +243 -1
@@ -0,0 +1,218 @@
1
+ PATH
2
+ remote: ../../..
3
+ specs:
4
+ sorbet-rails (0.7.33)
5
+ method_source (>= 0.9.2)
6
+ parlour (>= 4.0.1)
7
+ parser (>= 2.7)
8
+ sorbet-coerce (>= 0.2.6)
9
+ sorbet-runtime (>= 0.5.9892)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actioncable (7.0.3)
15
+ actionpack (= 7.0.3)
16
+ activesupport (= 7.0.3)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (>= 0.6.1)
19
+ actionmailbox (7.0.3)
20
+ actionpack (= 7.0.3)
21
+ activejob (= 7.0.3)
22
+ activerecord (= 7.0.3)
23
+ activestorage (= 7.0.3)
24
+ activesupport (= 7.0.3)
25
+ mail (>= 2.7.1)
26
+ net-imap
27
+ net-pop
28
+ net-smtp
29
+ actionmailer (7.0.3)
30
+ actionpack (= 7.0.3)
31
+ actionview (= 7.0.3)
32
+ activejob (= 7.0.3)
33
+ activesupport (= 7.0.3)
34
+ mail (~> 2.5, >= 2.5.4)
35
+ net-imap
36
+ net-pop
37
+ net-smtp
38
+ rails-dom-testing (~> 2.0)
39
+ actionpack (7.0.3)
40
+ actionview (= 7.0.3)
41
+ activesupport (= 7.0.3)
42
+ rack (~> 2.0, >= 2.2.0)
43
+ rack-test (>= 0.6.3)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
46
+ actiontext (7.0.3)
47
+ actionpack (= 7.0.3)
48
+ activerecord (= 7.0.3)
49
+ activestorage (= 7.0.3)
50
+ activesupport (= 7.0.3)
51
+ globalid (>= 0.6.0)
52
+ nokogiri (>= 1.8.5)
53
+ actionview (7.0.3)
54
+ activesupport (= 7.0.3)
55
+ builder (~> 3.1)
56
+ erubi (~> 1.4)
57
+ rails-dom-testing (~> 2.0)
58
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
59
+ activejob (7.0.3)
60
+ activesupport (= 7.0.3)
61
+ globalid (>= 0.3.6)
62
+ activemodel (7.0.3)
63
+ activesupport (= 7.0.3)
64
+ activerecord (7.0.3)
65
+ activemodel (= 7.0.3)
66
+ activesupport (= 7.0.3)
67
+ activestorage (7.0.3)
68
+ actionpack (= 7.0.3)
69
+ activejob (= 7.0.3)
70
+ activerecord (= 7.0.3)
71
+ activesupport (= 7.0.3)
72
+ marcel (~> 1.0)
73
+ mini_mime (>= 1.1.0)
74
+ activesupport (7.0.3)
75
+ concurrent-ruby (~> 1.0, >= 1.0.2)
76
+ i18n (>= 1.6, < 2)
77
+ minitest (>= 5.1)
78
+ tzinfo (~> 2.0)
79
+ ast (2.4.2)
80
+ bindex (0.8.1)
81
+ builder (3.2.4)
82
+ commander (4.6.0)
83
+ highline (~> 2.0.0)
84
+ concurrent-ruby (1.1.10)
85
+ crass (1.0.6)
86
+ debug (1.5.0)
87
+ irb (>= 1.3.6)
88
+ reline (>= 0.2.7)
89
+ digest (3.1.0)
90
+ erubi (1.10.0)
91
+ globalid (1.0.0)
92
+ activesupport (>= 5.0)
93
+ highline (2.0.3)
94
+ i18n (1.10.0)
95
+ concurrent-ruby (~> 1.0)
96
+ io-console (0.5.11)
97
+ irb (1.4.1)
98
+ reline (>= 0.3.0)
99
+ jbuilder (2.11.5)
100
+ actionview (>= 5.0.0)
101
+ activesupport (>= 5.0.0)
102
+ loofah (2.18.0)
103
+ crass (~> 1.0.2)
104
+ nokogiri (>= 1.5.9)
105
+ mail (2.7.1)
106
+ mini_mime (>= 0.1.1)
107
+ marcel (1.0.2)
108
+ method_source (1.0.0)
109
+ mini_mime (1.1.2)
110
+ minitest (5.16.1)
111
+ net-imap (0.2.3)
112
+ digest
113
+ net-protocol
114
+ strscan
115
+ net-pop (0.1.1)
116
+ digest
117
+ net-protocol
118
+ timeout
119
+ net-protocol (0.1.3)
120
+ timeout
121
+ net-smtp (0.3.1)
122
+ digest
123
+ net-protocol
124
+ timeout
125
+ nio4r (2.5.8)
126
+ nokogiri (1.13.6-x86_64-darwin)
127
+ racc (~> 1.4)
128
+ parlour (8.0.0)
129
+ commander (~> 4.5)
130
+ parser
131
+ rainbow (~> 3.0)
132
+ sorbet-runtime (>= 0.5)
133
+ parser (3.1.2.0)
134
+ ast (~> 2.4.1)
135
+ polyfill (1.9.0)
136
+ puma (5.6.4)
137
+ nio4r (~> 2.0)
138
+ racc (1.6.0)
139
+ rack (2.2.4)
140
+ rack-test (2.0.2)
141
+ rack (>= 1.3)
142
+ rails (7.0.3)
143
+ actioncable (= 7.0.3)
144
+ actionmailbox (= 7.0.3)
145
+ actionmailer (= 7.0.3)
146
+ actionpack (= 7.0.3)
147
+ actiontext (= 7.0.3)
148
+ actionview (= 7.0.3)
149
+ activejob (= 7.0.3)
150
+ activemodel (= 7.0.3)
151
+ activerecord (= 7.0.3)
152
+ activestorage (= 7.0.3)
153
+ activesupport (= 7.0.3)
154
+ bundler (>= 1.15.0)
155
+ railties (= 7.0.3)
156
+ rails-dom-testing (2.0.3)
157
+ activesupport (>= 4.2.0)
158
+ nokogiri (>= 1.6)
159
+ rails-html-sanitizer (1.4.3)
160
+ loofah (~> 2.3)
161
+ railties (7.0.3)
162
+ actionpack (= 7.0.3)
163
+ activesupport (= 7.0.3)
164
+ method_source
165
+ rake (>= 12.2)
166
+ thor (~> 1.0)
167
+ zeitwerk (~> 2.5)
168
+ rainbow (3.1.1)
169
+ rake (13.0.6)
170
+ reline (0.3.1)
171
+ io-console (~> 0.5)
172
+ safe_type (1.1.1)
173
+ sorbet (0.5.10139)
174
+ sorbet-static (= 0.5.10139)
175
+ sorbet-coerce (0.5.0)
176
+ polyfill (~> 1.8)
177
+ safe_type (~> 1.1, >= 1.1.1)
178
+ sorbet-runtime (>= 0.4.4704)
179
+ sorbet-runtime (0.5.10139)
180
+ sorbet-static (0.5.10139-universal-darwin-20)
181
+ sorbet-static (0.5.10139-universal-darwin-21)
182
+ sqlite3 (1.4.4)
183
+ strscan (3.0.3)
184
+ thor (1.2.1)
185
+ timeout (0.3.0)
186
+ tzinfo (2.0.4)
187
+ concurrent-ruby (~> 1.0)
188
+ web-console (4.2.0)
189
+ actionview (>= 6.0.0)
190
+ activemodel (>= 6.0.0)
191
+ bindex (>= 0.4.0)
192
+ railties (>= 6.0.0)
193
+ websocket-driver (0.7.5)
194
+ websocket-extensions (>= 0.1.0)
195
+ websocket-extensions (0.1.5)
196
+ zeitwerk (2.6.0)
197
+
198
+ PLATFORMS
199
+ x86_64-darwin-20
200
+ x86_64-darwin-21
201
+
202
+ DEPENDENCIES
203
+ debug
204
+ jbuilder
205
+ puma (~> 5.0)
206
+ rails (~> 7.0.3)
207
+ sorbet
208
+ sorbet-rails!
209
+ sorbet-runtime
210
+ sqlite3 (~> 1.4)
211
+ tzinfo-data
212
+ web-console
213
+
214
+ RUBY VERSION
215
+ ruby 3.0.1p64
216
+
217
+ BUNDLED WITH
218
+ 2.2.29
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1 @@
1
+ /* Application styles */
@@ -0,0 +1,3 @@
1
+ # typed: ignore
2
+ class ApplicationController < ActionController::Base
3
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ # typed: strict
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ # typed: strict
2
+ module BarHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ # typed: strict
2
+ module BazHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ # typed: strict
2
+ module FooHelper
3
+ end
@@ -0,0 +1,8 @@
1
+ # typed: strict
2
+ class ApplicationJob < ActiveJob::Base
3
+ # Automatically retry jobs that encountered a deadlock
4
+ # retry_on ActiveRecord::Deadlocked
5
+
6
+ # Most jobs are safe to ignore if the underlying records are no longer available
7
+ # discard_on ActiveJob::DeserializationError
8
+ end
@@ -0,0 +1,12 @@
1
+ # typed: strict
2
+ # N.B. You imagine the wizards update the point magically somehow?
3
+ # Nope, there is a "goblin" that takes their "give points" request and do it
4
+ # behind the scene.
5
+ class AwardHousePointHourglasses < ApplicationJob
6
+ extend T::Sig
7
+
8
+ sig { params(student: Wizard, point: Integer).void }
9
+ def perform(student:, point:)
10
+ # TODO: award point to student's house
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # typed: ignore
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
@@ -0,0 +1,9 @@
1
+ # typed: ignore
2
+ class DailyProphetMailer < ApplicationMailer
3
+ extend T::Sig
4
+
5
+ sig { params(wizards: T::Array[Wizard], hotnews_only: T::Boolean).void }
6
+ def notify_subscribers(wizards:, hotnews_only:)
7
+ # TODO: mail the latest news to wizards!
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # typed: ignore
2
+ class HogwartsAcceptanceMailer < ApplicationMailer
3
+ extend T::Sig
4
+
5
+ sig { params(student: Wizard).void }
6
+ def notify(student)
7
+ # TODO: mail acceptance letter to student
8
+ end
9
+
10
+ sig {
11
+ params(
12
+ teacher: Wizard,
13
+ note: String,
14
+ student: Wizard,
15
+ special: T::Boolean,
16
+ ).void
17
+ }
18
+ def notify_teacher(
19
+ teacher,
20
+ note=nil,
21
+ student:,
22
+ special: false
23
+ ) # TODO: let the teacher know when a students accepted offer
24
+ end
25
+
26
+ def notify_retry(student)
27
+ # TODO: send more owls!!
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ # typed: false
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ primary_abstract_class
4
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ # typed: false
2
+ require 'active_support/concern'
3
+ module Mythical
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def mythicals
8
+ all.to_a # yeah!
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # typed: strict
2
+ class Headmaster < ApplicationRecord
3
+ belongs_to :school, required: false
4
+ belongs_to :wizard, optional: true
5
+
6
+ validates :school, presence: true
7
+ validates :wizard_id, presence: true
8
+ end
@@ -0,0 +1,6 @@
1
+ # typed: strict
2
+ # an abstract class that has no table
3
+ class Potion < ApplicationRecord
4
+ self.abstract_class = true
5
+ belongs_to :wizard, required: false
6
+ end
@@ -0,0 +1,4 @@
1
+ # typed: strict
2
+ class Robe < ApplicationRecord
3
+ belongs_to :wizard, required: false
4
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strict
2
+ class School < ApplicationRecord
3
+ has_one :headmaster
4
+ validates :headmaster, presence: true
5
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strict
2
+ class Spell < ApplicationRecord
3
+ # habtm enforced at the DB level
4
+ has_and_belongs_to_many :spell_books
5
+ end
@@ -0,0 +1,18 @@
1
+ # typed: false
2
+ class SpellBook < ApplicationRecord
3
+ validates :name, length: { minimum: 5 }, presence: true
4
+
5
+ # simulate when belongs_to is optional by default, but it is enforced at the DB level
6
+ belongs_to :wizard, optional: true
7
+
8
+ # habtm enforced at the DB level
9
+ has_and_belongs_to_many :spells
10
+
11
+ enum book_type: {
12
+ unclassified: 0,
13
+ biology: 1,
14
+ dark_art: 999,
15
+ }
16
+
17
+ scope :recent, -> { where('created_at > ?', 1.month.ago) }
18
+ end
@@ -0,0 +1,6 @@
1
+ # typed: true
2
+ class Squib < Wizard
3
+ def is_magical
4
+ false
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strict
2
+ class Subject < ApplicationRecord
3
+ # habtm which is optional at the db level
4
+ has_and_belongs_to_many :wizards
5
+ end
@@ -0,0 +1,19 @@
1
+ # typed: false
2
+ class Wand < ApplicationRecord
3
+ include Mythical
4
+
5
+ self.skip_time_zone_conversion_for_attributes = [:broken_at]
6
+
7
+ enum core_type: {
8
+ phoenix_feather: 0,
9
+ dragon_heartstring: 1,
10
+ unicorn_tail_hair: 2,
11
+ basilisk_horn: 3,
12
+ }
13
+
14
+ belongs_to :wizard, required: true
15
+
16
+ def wood_type
17
+ 'Type ' + super
18
+ end
19
+ end
@@ -0,0 +1,65 @@
1
+ # typed: false
2
+ class Wizard < ApplicationRecord
3
+ validates :name, length: { minimum: 5 }, presence: true
4
+ # simulate conditional validation
5
+ validates :parent_email, presence: true, if: :Slytherin?
6
+
7
+ typed_enum house: {
8
+ Gryffindor: 0,
9
+ Hufflepuff: 1,
10
+ Ravenclaw: 2,
11
+ Slytherin: 3,
12
+ }
13
+
14
+ # To create conflict with enum
15
+ class Professor; end
16
+
17
+ enum professor: {
18
+ "Severus Snape": 0,
19
+ "Minerva McGonagall": 1,
20
+ "Pomona Sprout": 2,
21
+ "Filius Flitwick": 3,
22
+ "Hagrid": 4,
23
+ "Alastor 'Mad-Eye' Moody": 5,
24
+ }
25
+
26
+ typed_enum broom: {
27
+ nimbus: 'nimbus',
28
+ firebolt: 'firebolt',
29
+ }, _prefix: true
30
+
31
+ typed_enum quidditch_position: {
32
+ keeper: 0,
33
+ seeker: 1,
34
+ beater: 2,
35
+ chaser: 3,
36
+ }, _prefix: :quidditch
37
+
38
+ enum hair_color: {
39
+ brown: 0,
40
+ black: 1,
41
+ blonde: 2,
42
+ }, _suffix: :hair
43
+
44
+ enum eye_color: {
45
+ brown: 0,
46
+ green: 1,
47
+ blue: 2,
48
+ }, _prefix: :color, _suffix: :eyes
49
+
50
+ serialize :owl_results, Hash
51
+ serialize :newt_subjects # no specific data type, uses the default YAML Object coder
52
+ serialize :pets, Array
53
+ serialize :patronus_characteristics, JSON
54
+
55
+ has_one :wand
56
+ has_many :spell_books
57
+ # habtm which is optional at the db level
58
+ has_and_belongs_to_many :subjects
59
+
60
+ # simulate when belongs_to is optional by default
61
+ belongs_to :school, optional: true
62
+
63
+ scope :recent, -> { where('created_at > ?', 1.month.ago) }
64
+
65
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>V70</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= stylesheet_link_tag "application" %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
+ env_var_version || cli_arg_version ||
66
+ bundler_requirement_for(lockfile_version)
67
+ end
68
+
69
+ def bundler_requirement_for(version)
70
+ return "#{Gem::Requirement.default}.a" unless version
71
+
72
+ bundler_gem_version = Gem::Version.new(version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"