Skip to content

Commit d8edfc1

Browse files
authored
Merge pull request #901 from ksss/drop-actionpack-v6
Drop to support actionpack v6
2 parents e4074da + 4b043a4 commit d8edfc1

File tree

8 files changed

+12296
-63
lines changed

8 files changed

+12296
-63
lines changed

gems/actionpack/.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
inherit_from: ../../.rubocop.yml
22

3+
# Please specify only supported versions.
34
RBS/Layout:
45
Enabled: true
6+
Include:
7+
- "gems/actionpack/7.2/**/*.rbs"
58
RBS/Lint:
69
Enabled: true
10+
Include:
11+
- "gems/actionpack/7.2/**/*.rbs"
712
RBS/Style:
813
Enabled: true
14+
Include:
15+
- "gems/actionpack/7.2/**/*.rbs"
16+

gems/actionpack/6.0/_test/test.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

gems/actionpack/6.0/_test/test.rbs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gems/actionpack/7.2/actioncontroller.rbs

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
module ActionController
2+
interface _API_and_Base
3+
def flash: () -> untyped
4+
end
5+
6+
class Base < Metal
7+
include _API_and_Base
8+
9+
# https://github.com/rails/rails/blob/v6.0.3.2/actionpack/lib/action_controller/base.rb#L205-L255
10+
include AbstractController::Rendering
11+
include AbstractController::Translation
12+
include AbstractController::AssetPaths
13+
include Helpers
14+
extend Helpers::ClassMethods
15+
extend AbstractController::Helpers::ClassMethods
16+
include UrlFor
17+
include Redirecting
18+
include ActionView::Layouts
19+
extend ::ActionView::Layouts::ClassMethods
20+
include Rendering
21+
extend Rendering::ClassMethods
22+
include Renderers::All
23+
include ConditionalGet
24+
extend ConditionalGet::ClassMethods
25+
include EtagWithTemplateDigest
26+
include EtagWithFlash
27+
include Caching
28+
include AbstractController::Caching
29+
extend AbstractController::Caching::ClassMethods
30+
extend AbstractController::Caching::Fragments::ClassMethods
31+
include MimeResponds
32+
include ImplicitRender
33+
include StrongParameters
34+
include ParameterEncoding
35+
extend ParameterEncoding::ClassMethods
36+
include Cookies
37+
include Flash
38+
extend Flash::ClassMethods
39+
include FormBuilder
40+
extend FormBuilder::ClassMethods
41+
include RequestForgeryProtection
42+
extend RequestForgeryProtection::ClassMethods
43+
include ContentSecurityPolicy
44+
extend ContentSecurityPolicy::ClassMethods
45+
include ForceSSL
46+
extend ForceSSL::ClassMethods
47+
include Streaming
48+
include DataStreaming
49+
include HttpAuthentication::Basic::ControllerMethods
50+
extend HttpAuthentication::Basic::ControllerMethods::ClassMethods
51+
include HttpAuthentication::Digest::ControllerMethods
52+
include HttpAuthentication::Token::ControllerMethods
53+
include DefaultHeaders
54+
extend DefaultHeaders::ClassMethods
55+
include AbstractController::Callbacks
56+
extend AbstractController::Callbacks::ClassMethods
57+
include Rescue
58+
include ActiveSupport::Rescuable
59+
extend ActiveSupport::Rescuable::ClassMethods
60+
include Instrumentation
61+
extend Instrumentation::ClassMethods
62+
include ParamsWrapper
63+
extend ParamsWrapper::ClassMethods
64+
end
65+
66+
class API < Metal
67+
include _API_and_Base
68+
69+
# https://github.com/rails/rails/blob/v6.0.3.2/actionpack/lib/action_controller/api.rb#L112-L145
70+
include AbstractController::Rendering
71+
include UrlFor
72+
include Redirecting
73+
include ApiRendering
74+
include Renderers::All
75+
include ConditionalGet
76+
extend ConditionalGet::ClassMethods
77+
include BasicImplicitRender
78+
include StrongParameters
79+
include ForceSSL
80+
extend ForceSSL::ClassMethods
81+
include DataStreaming
82+
include DefaultHeaders
83+
extend DefaultHeaders::ClassMethods
84+
include AbstractController::Callbacks
85+
extend AbstractController::Callbacks::ClassMethods
86+
include Rescue
87+
include ActiveSupport::Rescuable
88+
extend ActiveSupport::Rescuable::ClassMethods
89+
include Instrumentation
90+
extend Instrumentation::ClassMethods
91+
include ParamsWrapper
92+
extend ParamsWrapper::ClassMethods
93+
end
94+
95+
module HttpAuthentication
96+
module Token
97+
TOKEN_KEY: ::String
98+
TOKEN_REGEX: ::Regexp
99+
AUTHN_PAIR_DELIMITERS: ::Regexp
100+
101+
extend ::ActionController::HttpAuthentication::Token
102+
103+
module ControllerMethods
104+
def authenticate_or_request_with_http_token: (?String realm, ?String? message) { (String token, ActiveSupport::HashWithIndifferentAccess[untyped, untyped] options) -> boolish } -> untyped
105+
106+
def authenticate_with_http_token: () { (String token, ActiveSupport::HashWithIndifferentAccess[untyped, untyped] options) -> boolish } -> boolish
107+
108+
def request_http_token_authentication: (?String realm, ?String? message) -> void
109+
end
110+
111+
def authenticate: (instance controller) { (String token, ActiveSupport::HashWithIndifferentAccess[untyped, untyped] options) -> boolish } -> boolish
112+
113+
def token_and_options: (ActionDispatch::Request request) -> [String, ActiveSupport::HashWithIndifferentAccess[untyped, untyped]]?
114+
115+
def token_params_from: (String auth) -> Array[String]
116+
117+
def raw_params: (String auth) -> Array[String]
118+
119+
def params_array_from: (Array[String] raw_params) -> Array[String]
120+
121+
def rewrite_param_values: (Array[String] array_params) -> Array[String]
122+
123+
def encode_credentials: (String token, ?::Hash[untyped, untyped] options) -> ::String
124+
125+
def authentication_request: (instance controller, String realm, ?String? message) -> void
126+
end
127+
end
128+
end
129+
130+
module AbstractController::Callbacks::ClassMethods
131+
interface _BeforeActionCallback
132+
def before: (ActionController::Base controller) -> void
133+
end
134+
135+
interface _AroundActionCallback
136+
def around: (ActionController::Base controller) { () -> void } -> void
137+
end
138+
139+
interface _AfterActionCallback
140+
def after: (ActionController::Base controller) -> void
141+
end
142+
143+
type before_action_callback[T] = Symbol | ^(T controller) [self: T] -> void | _BeforeActionCallback
144+
type around_action_callback[T] = Symbol | ^(T controller, ^() -> void) [self: T] -> void | _AroundActionCallback
145+
type after_action_callback[T] = Symbol | ^(T controller) [self: T] -> void | _AfterActionCallback
146+
147+
def before_action: (*before_action_callback[instance], ?if: before_action_callback[instance], ?unless: before_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
148+
def around_action: (*around_action_callback[instance], ?if: around_action_callback[instance], ?unless: around_action_callback[instance], **untyped) ?{ (instance controller, ^() -> void) [self: instance] -> void } -> void
149+
def after_action: (*after_action_callback[instance], ?if: after_action_callback[instance], ?unless: after_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
150+
def skip_before_action: (*before_action_callback[instance], ?if: before_action_callback[instance], ?unless: before_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
151+
def skip_around_action: (*around_action_callback[instance], ?if: around_action_callback[instance], ?unless: around_action_callback[instance], **untyped) ?{ (instance controller, ^() -> void) [self: instance] -> void } -> void
152+
def skip_after_action: (*after_action_callback[instance], ?if: after_action_callback[instance], ?unless: after_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
153+
def prepend_before_action: (*before_action_callback[instance], ?if: before_action_callback[instance], ?unless: before_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
154+
def prepend_around_action: (*around_action_callback[instance], ?if: around_action_callback[instance], ?unless: around_action_callback[instance], **untyped) ?{ (instance controller, ^() -> void) [self: instance] -> void } -> void
155+
def prepend_after_action: (*after_action_callback[instance], ?if: after_action_callback[instance], ?unless: after_action_callback[instance], **untyped) ?{ (instance controller) [self: instance] -> void } -> void
156+
157+
alias append_before_action before_action
158+
alias append_around_action around_action
159+
alias append_after_action after_action
160+
end
161+
162+
module ActionController
163+
class Parameters
164+
# Deletes a key-value pair from +Parameters+ and returns the value. If
165+
# +key+ is not found, returns +nil+ (or, with optional code block, yields
166+
# +key+ and returns the result). Cf. +#extract!+, which returns the
167+
# corresponding +ActionController::Parameters+ object.
168+
def delete: (untyped key) ?{ (untyped key) -> untyped } -> untyped
169+
170+
def keys: () -> Array[untyped]
171+
def key?: (untyped key) -> bool
172+
def has_key?: (untyped key) -> bool
173+
def values: () -> Array[untyped]
174+
def has_value?: (untyped value) -> bool
175+
def empty?: () -> bool
176+
def include?: (untyped key) -> bool
177+
def as_json: () -> String
178+
def to_s: () -> String
179+
def each_key: () { (untyped) -> untyped } -> Hash[untyped, untyped]
180+
| () -> Enumerator[untyped, self]
181+
def fetch: (untyped key, *untyped args) ?{ () -> untyped } -> untyped
182+
end
183+
end
184+
185+
module AbstractController
186+
module Helpers
187+
module ClassMethods
188+
# The +helper+ class method can take a series of helper module names, a block, or both.
189+
#
190+
# ==== Options
191+
# * <tt>*args</tt> - Module, Symbol, String
192+
# * <tt>block</tt> - A block defining helper methods
193+
#
194+
# When the argument is a module it will be included directly in the template class.
195+
# helper FooHelper # => includes FooHelper
196+
#
197+
# When the argument is a string or symbol, the method will provide the "_helper" suffix, require the file
198+
# and include the module in the template class. The second form illustrates how to include custom helpers
199+
# when working with namespaced controllers, or other cases where the file containing the helper definition is not
200+
# in one of Rails' standard load paths:
201+
# helper :foo # => requires 'foo_helper' and includes FooHelper
202+
# helper 'resources/foo' # => requires 'resources/foo_helper' and includes Resources::FooHelper
203+
#
204+
# Additionally, the +helper+ class method can receive and evaluate a block, making the methods defined available
205+
# to the template.
206+
#
207+
# # One line
208+
# helper { def hello() "Hello, world!" end }
209+
#
210+
# # Multi-line
211+
# helper do
212+
# def foo(bar)
213+
# "#{bar} is the very best"
214+
# end
215+
# end
216+
#
217+
# Finally, all the above styles can be mixed together, and the +helper+ method can be invoked with a mix of
218+
# +symbols+, +strings+, +modules+ and blocks.
219+
#
220+
# helper(:three, BlindHelper) { def mice() 'mice' end }
221+
#
222+
def helper: (*untyped args) ?{ () -> untyped } -> untyped
223+
end
224+
end
225+
end
226+
227+
module AbstractController
228+
module Caching
229+
module Fragments
230+
module ClassMethods
231+
# Allows you to specify controller-wide key prefixes for
232+
# cache fragments. Pass either a constant +value+, or a block
233+
# which computes a value each time a cache key is generated.
234+
#
235+
# For example, you may want to prefix all fragment cache keys
236+
# with a global version identifier, so you can easily
237+
# invalidate all caches.
238+
#
239+
# class ApplicationController
240+
# fragment_cache_key "v1"
241+
# end
242+
#
243+
# When it's time to invalidate all fragments, simply change
244+
# the string constant. Or, progressively roll out the cache
245+
# invalidation using a computed value:
246+
#
247+
# class ApplicationController
248+
# fragment_cache_key do
249+
# @account.id.odd? ? "v1" : "v2"
250+
# end
251+
# end
252+
def fragment_cache_key: (?untyped? value) ?{ () -> untyped } -> untyped
253+
end
254+
end
255+
end
256+
end
257+
258+
module ActionController
259+
module Caching
260+
extend AbstractController::Caching::ClassMethods
261+
extend AbstractController::Caching::Fragments::ClassMethods
262+
end
263+
end
264+
265+
module ActionController
266+
module ContentSecurityPolicy
267+
module ClassMethods
268+
def content_security_policy: (?bool enabled, **untyped options) ?{ (untyped) -> untyped } -> untyped
269+
end
270+
end
271+
end
272+
273+
module ActionController
274+
class TestSession < Rack::Session::Abstract::PersistedSecure::SecureSessionHash
275+
def fetch: (untyped key) ?{ () -> untyped } -> untyped
276+
| (untyped key, untyped args) -> untyped
277+
end
278+
end

gems/actionpack/7.2/actiondispatch.rbs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)