phlex-stimulus 0.1.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 (147) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +16 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +341 -0
  6. data/Rakefile +12 -0
  7. data/lib/generators/phlex/stimulus/controller/USAGE +5 -0
  8. data/lib/generators/phlex/stimulus/controller/controller_generator.rb +49 -0
  9. data/lib/generators/phlex/stimulus/controller/templates/component.rb.erb +30 -0
  10. data/lib/generators/phlex/stimulus/controller/templates/controller.ts.erb +23 -0
  11. data/lib/generators/phlex/stimulus/generator_mixin.rb +21 -0
  12. data/lib/generators/phlex/stimulus/install/USAGE +5 -0
  13. data/lib/generators/phlex/stimulus/install/install_generator.rb +111 -0
  14. data/lib/generators/phlex/stimulus/install/templates/app/components/base.rb.erb +29 -0
  15. data/lib/generators/phlex/stimulus/install/templates/app/components/chain_controller.rb.erb +29 -0
  16. data/lib/generators/phlex/stimulus/install/templates/app/components/classlist_controller.rb.erb +30 -0
  17. data/lib/generators/phlex/stimulus/install/templates/app/components/controller.rb.erb +10 -0
  18. data/lib/generators/phlex/stimulus/install/templates/app/components/controller_chain.rb.erb +32 -0
  19. data/lib/generators/phlex/stimulus/install/templates/app/components/controller_template.rb.erb +24 -0
  20. data/lib/generators/phlex/stimulus/install/templates/app/components/log_controller.rb.erb +33 -0
  21. data/lib/generators/phlex/stimulus/install/templates/app/components/sleep_controller.rb.erb +30 -0
  22. data/lib/generators/phlex/stimulus/install/templates/app/components.rb.erb +7 -0
  23. data/lib/generators/phlex/stimulus/install/templates/app/javascript/application.ts.erb +5 -0
  24. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/application.ts.erb +10 -0
  25. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/chain_controller.ts.erb +32 -0
  26. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/chainable_controller.ts.erb +44 -0
  27. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/classlist_controller.ts.erb +30 -0
  28. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/index.ts.erb +4 -0
  29. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/log_controller.ts.erb +25 -0
  30. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/sleep_controller.ts.erb +19 -0
  31. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/typed_controller.ts.erb +53 -0
  32. data/lib/generators/phlex/stimulus/install/templates/app/javascript/utils/misc.ts.erb +37 -0
  33. data/lib/generators/phlex/stimulus/install/templates/app/javascript/utils/template.ts.erb +11 -0
  34. data/lib/phlex/stimulus/components/base.rb +81 -0
  35. data/lib/phlex/stimulus/components/controller.rb +170 -0
  36. data/lib/phlex/stimulus/components.rb +9 -0
  37. data/lib/phlex/stimulus/version.rb +8 -0
  38. data/lib/phlex/stimulus.rb +15 -0
  39. data/sorbet/config +7 -0
  40. data/sorbet/rbi/annotations/.gitattributes +1 -0
  41. data/sorbet/rbi/annotations/actionmailer.rbi +15 -0
  42. data/sorbet/rbi/annotations/actionpack.rbi +430 -0
  43. data/sorbet/rbi/annotations/actionview.rbi +75 -0
  44. data/sorbet/rbi/annotations/activejob.rbi +50 -0
  45. data/sorbet/rbi/annotations/activemodel.rbi +119 -0
  46. data/sorbet/rbi/annotations/activerecord.rbi +172 -0
  47. data/sorbet/rbi/annotations/activesupport.rbi +561 -0
  48. data/sorbet/rbi/annotations/globalid.rbi +30 -0
  49. data/sorbet/rbi/annotations/minitest.rbi +116 -0
  50. data/sorbet/rbi/annotations/railties.rbi +104 -0
  51. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  52. data/sorbet/rbi/dsl/.gitattributes +1 -0
  53. data/sorbet/rbi/dsl/active_support/callbacks.rbi +21 -0
  54. data/sorbet/rbi/gems/.gitattributes +1 -0
  55. data/sorbet/rbi/gems/action_text-trix@2.1.19.rbi +9 -0
  56. data/sorbet/rbi/gems/actioncable@8.1.3.rbi +9 -0
  57. data/sorbet/rbi/gems/actionmailbox@8.1.3.rbi +9 -0
  58. data/sorbet/rbi/gems/actionmailer@8.1.3.rbi +9 -0
  59. data/sorbet/rbi/gems/actionpack@8.1.3.rbi +20478 -0
  60. data/sorbet/rbi/gems/actiontext@8.1.3.rbi +9 -0
  61. data/sorbet/rbi/gems/actionview@8.1.3.rbi +14722 -0
  62. data/sorbet/rbi/gems/activejob@8.1.3.rbi +9 -0
  63. data/sorbet/rbi/gems/activemodel@8.1.3.rbi +9 -0
  64. data/sorbet/rbi/gems/activerecord@8.1.3.rbi +9 -0
  65. data/sorbet/rbi/gems/activestorage@8.1.3.rbi +9 -0
  66. data/sorbet/rbi/gems/activesupport@8.1.3.rbi +20153 -0
  67. data/sorbet/rbi/gems/ast@2.4.3.rbi +550 -0
  68. data/sorbet/rbi/gems/base64@0.3.0.rbi +545 -0
  69. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +621 -0
  70. data/sorbet/rbi/gems/booleans@0.1.3.rbi +31 -0
  71. data/sorbet/rbi/gems/builder@3.3.0.rbi +9 -0
  72. data/sorbet/rbi/gems/byebug@12.0.0.rbi +49 -0
  73. data/sorbet/rbi/gems/concurrent-ruby@1.3.8.rbi +10656 -0
  74. data/sorbet/rbi/gems/connection_pool@3.0.2.rbi +9 -0
  75. data/sorbet/rbi/gems/crass@1.0.7.rbi +648 -0
  76. data/sorbet/rbi/gems/date@3.5.1.rbi +391 -0
  77. data/sorbet/rbi/gems/drb@2.2.3.rbi +9 -0
  78. data/sorbet/rbi/gems/erb@6.0.6.rbi +1600 -0
  79. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  80. data/sorbet/rbi/gems/globalid@1.4.0.rbi +9 -0
  81. data/sorbet/rbi/gems/i18n@1.15.2.rbi +2285 -0
  82. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  83. data/sorbet/rbi/gems/json@2.21.1.rbi +2289 -0
  84. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  85. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  86. data/sorbet/rbi/gems/loofah@2.25.2.rbi +1134 -0
  87. data/sorbet/rbi/gems/mail@2.9.1.rbi +9 -0
  88. data/sorbet/rbi/gems/marcel@1.2.1.rbi +9 -0
  89. data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +9 -0
  90. data/sorbet/rbi/gems/minitest@6.0.6.rbi +1482 -0
  91. data/sorbet/rbi/gems/net-imap@0.6.4.1.rbi +9 -0
  92. data/sorbet/rbi/gems/net-pop@0.1.2.rbi +9 -0
  93. data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +244 -0
  94. data/sorbet/rbi/gems/net-smtp@0.5.1.rbi +9 -0
  95. data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
  96. data/sorbet/rbi/gems/nio4r@2.7.5.rbi +9 -0
  97. data/sorbet/rbi/gems/nokogiri@1.19.4.rbi +8168 -0
  98. data/sorbet/rbi/gems/parallel@1.28.0.rbi +270 -0
  99. data/sorbet/rbi/gems/phlex-rails@2.4.0.rbi +1945 -0
  100. data/sorbet/rbi/gems/phlex@2.4.1.rbi +1413 -0
  101. data/sorbet/rbi/gems/pp@0.6.4.rbi +387 -0
  102. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +455 -0
  103. data/sorbet/rbi/gems/prism@1.9.0.rbi +42226 -0
  104. data/sorbet/rbi/gems/racc@1.8.1.rbi +165 -0
  105. data/sorbet/rbi/gems/rack-session@2.1.2.rbi +756 -0
  106. data/sorbet/rbi/gems/rack-test@2.2.0.rbi +681 -0
  107. data/sorbet/rbi/gems/rack@3.2.6.rbi +4653 -0
  108. data/sorbet/rbi/gems/rackup@2.3.1.rbi +9 -0
  109. data/sorbet/rbi/gems/rails-dom-testing@2.3.0.rbi +517 -0
  110. data/sorbet/rbi/gems/rails-html-sanitizer@1.7.1.rbi +620 -0
  111. data/sorbet/rbi/gems/rails@8.1.3.rbi +9 -0
  112. data/sorbet/rbi/gems/railties@8.1.3.rbi +3507 -0
  113. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
  114. data/sorbet/rbi/gems/rake@13.4.2.rbi +3130 -0
  115. data/sorbet/rbi/gems/rbi@0.4.0.rbi +5706 -0
  116. data/sorbet/rbi/gems/rbs@4.0.3.rbi +6908 -0
  117. data/sorbet/rbi/gems/refract@1.1.0.rbi +9 -0
  118. data/sorbet/rbi/gems/reline@0.6.3.rbi +2446 -0
  119. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  120. data/sorbet/rbi/gems/rexml@3.4.4.rbi +4905 -0
  121. data/sorbet/rbi/gems/rubocop-espago@1.3.0.rbi +9 -0
  122. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  123. data/sorbet/rbi/gems/rubydex@0.2.9.rbi +841 -0
  124. data/sorbet/rbi/gems/securerandom@0.4.1.rbi +75 -0
  125. data/sorbet/rbi/gems/shoulda-context@2.0.0.rbi +544 -0
  126. data/sorbet/rbi/gems/spoom@1.8.4.rbi +6738 -0
  127. data/sorbet/rbi/gems/tapioca@0.19.2.rbi +3599 -0
  128. data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
  129. data/sorbet/rbi/gems/timeout@0.6.1.rbi +200 -0
  130. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  131. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5474 -0
  132. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
  133. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
  134. data/sorbet/rbi/gems/uri@1.1.1.rbi +2402 -0
  135. data/sorbet/rbi/gems/useragent@0.16.11.rbi +9 -0
  136. data/sorbet/rbi/gems/websocket-driver@0.8.2.rbi +9 -0
  137. data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +9 -0
  138. data/sorbet/rbi/gems/zeitwerk@2.8.2.rbi +9 -0
  139. data/sorbet/rbi/shims/gems/parser.rbi +12 -0
  140. data/sorbet/rbi/shims/gems/rails.rbi +55 -0
  141. data/sorbet/rbi/shims/gems/refract.rbi +13 -0
  142. data/sorbet/rbi/shims/gems/shoulda-context.rbi +16 -0
  143. data/sorbet/tapioca/compilers/phlex_controller.rb +80 -0
  144. data/sorbet/tapioca/config.yml +26 -0
  145. data/sorbet/tapioca/extensions/load_gem.rb +1 -0
  146. data/sorbet/tapioca/require.rb +4 -0
  147. metadata +266 -0
@@ -0,0 +1,170 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Phlex::Stimulus
5
+ module Components
6
+ # Abstract class for Phlex components
7
+ # that wrap Stimulus.js controllers.
8
+ #
9
+ # @abstract
10
+ class Controller < Base
11
+ class ActionDefinition
12
+ #: singleton(Controller)
13
+ attr_reader :component
14
+ #: String
15
+ attr_reader :action_name
16
+
17
+ #: (component: singleton(Controller), action_name: String) -> void
18
+ def initialize(component:, action_name:)
19
+ @component = component
20
+ @action_name = action_name
21
+ end
22
+
23
+ #: -> String
24
+ def full_name
25
+ "#{@component.controller_name}##{@action_name}"
26
+ end
27
+
28
+ #: -> String
29
+ def ruby_name
30
+ @action_name.underscore
31
+ end
32
+
33
+ #: -> String
34
+ def ruby_action_method_name
35
+ "#{ruby_name}_action"
36
+ end
37
+ end
38
+
39
+ class TargetDefinition
40
+ #: singleton(Controller)
41
+ attr_reader :component
42
+ #: String
43
+ attr_reader :target_name
44
+
45
+ #: (component: singleton(Controller), target_name: String) -> void
46
+ def initialize(component:, target_name:)
47
+ @component = component
48
+ @target_name = target_name
49
+ end
50
+
51
+ #: -> String
52
+ def ruby_name
53
+ @target_name.underscore
54
+ end
55
+
56
+ #: -> String
57
+ def ruby_target_method_name
58
+ "#{ruby_name}_target"
59
+ end
60
+ end
61
+
62
+ class << self
63
+ # Name of the Stimulus controller
64
+ #
65
+ #: String
66
+ attr_accessor :controller_name
67
+
68
+ #: -> String
69
+ def controller_path
70
+ name = controller_name
71
+ sections = name.split('--')
72
+ subpath = sections.map(&:underscore).join('/')
73
+
74
+ "app/javascript/controllers/#{subpath}_controller.ts"
75
+ end
76
+
77
+ #: -> Array[ActionDefinition]
78
+ def action_defs
79
+ @action_defs ||= []
80
+ end
81
+
82
+ #: -> Array[TargetDefinition]
83
+ def target_defs
84
+ @target_defs ||= []
85
+ end
86
+
87
+ # Constructs a Stimulus dispatched event name
88
+ # eg.
89
+ #
90
+ # SummaryController.dispatched('ready') #=> "summary:ready"
91
+ #
92
+ #: (String) -> String
93
+ def dispatched(event_name)
94
+ "#{controller_name}:#{event_name}"
95
+ end
96
+
97
+ # Returns the name of the data attribute for the controller's targets without the initial `"data-"`
98
+ # eg. `"summary-target"`
99
+ #
100
+ #: -> String
101
+ def target_key
102
+ "#{controller_name}-target"
103
+ end
104
+
105
+ # Returns the full name of the data attribute for the controller's targets
106
+ # eg. `"data-summary-target"`
107
+ #
108
+ #: -> String
109
+ def data_target_key
110
+ "data-#{target_key}"
111
+ end
112
+
113
+ # Register actions that exist on the Stimulus controller.
114
+ # Will define typed getter methods for each action.
115
+ #
116
+ #: (*Symbol) -> void
117
+ def actions(*actions)
118
+ actions.each do |action|
119
+ action_def = ActionDefinition.new(
120
+ component: self,
121
+ action_name: action.to_s,
122
+ )
123
+ action_defs << action_def
124
+
125
+ instance_eval <<~RUBY, __FILE__, __LINE__ + 1
126
+ def #{action_def.ruby_action_method_name}
127
+ "\#{controller_name}##{action}"
128
+ end
129
+ RUBY
130
+ end
131
+ end
132
+
133
+ # Register targets that exist on the Stimulus controller.
134
+ # Will define typed getter methods for each target.
135
+ #
136
+ #: (*Symbol) -> void
137
+ def targets(*targets)
138
+ targets.each do |target|
139
+ target_str = target.to_s
140
+ target_def = TargetDefinition.new(
141
+ component: self,
142
+ target_name: target_str,
143
+ )
144
+ target_defs << target_def
145
+
146
+ instance_eval <<~RUBY, __FILE__, __LINE__ + 1
147
+ def #{target_def.ruby_target_method_name}
148
+ #{target_str.inspect}
149
+ end
150
+ RUBY
151
+ end
152
+ end
153
+
154
+ end
155
+
156
+ #: -> String
157
+ def controller_name
158
+ self.class.controller_name
159
+ end
160
+
161
+ # @overridable
162
+ #: ?{ -> void } -> void
163
+ def view_template(&block)
164
+ div(data: { controller: self.class.controller_name }) do
165
+ block&.call
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,9 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Phlex::Stimulus
5
+ # Contains Phlex on Rails base components
6
+ module Components; end
7
+ end
8
+
9
+ require_relative 'components/base'
@@ -0,0 +1,8 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Phlex
5
+ module Stimulus
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'stimulus/version'
4
+
5
+ require 'rails'
6
+ require 'phlex'
7
+ require 'phlex/rails'
8
+ require 'booleans'
9
+
10
+ module Phlex
11
+ module Stimulus
12
+ end
13
+ end
14
+
15
+ require_relative 'stimulus/components'
data/sorbet/config ADDED
@@ -0,0 +1,7 @@
1
+ --dir
2
+ .
3
+ --enable-experimental-requires-ancestor
4
+ --enable-experimental-rbs-comments
5
+ --parser=prism
6
+ --ignore=tmp/
7
+ --ignore=vendor/
@@ -0,0 +1 @@
1
+ **/*.rbi linguist-vendored=true
@@ -0,0 +1,15 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This file was pulled from a central RBI files repository.
5
+ # Please run `bin/tapioca annotations` to update it.
6
+
7
+ class ActionMailer::Base
8
+ sig { params(headers: T.untyped, block: T.nilable(T.proc.params(arg0: ActionMailer::Collector).void)).returns(Mail::Message) }
9
+ def mail(headers = nil, &block); end
10
+ end
11
+
12
+ module ActionMailer::TestHelper
13
+ sig { params(block: T.proc.void).returns(T::Array[Mail::Message]) }
14
+ def capture_emails(&block); end
15
+ end
@@ -0,0 +1,430 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This file was pulled from a central RBI files repository.
5
+ # Please run `bin/tapioca annotations` to update it.
6
+
7
+ class ActionController::API
8
+ MODULES = T.let(T.unsafe(nil), T::Array[T.untyped])
9
+ end
10
+
11
+ module ActionController::Flash::ClassMethods
12
+ sig { params(types: Symbol).void }
13
+ def add_flash_types(*types); end
14
+ end
15
+
16
+ module ActionController::Helpers::ClassMethods
17
+ sig { returns(ActionView::Base) }
18
+ def helpers; end
19
+ end
20
+
21
+ class ActionController::Metal < AbstractController::Base
22
+ sig { returns(ActionController::Parameters) }
23
+ def params; end
24
+
25
+ sig { returns(ActionDispatch::Request) }
26
+ def request; end
27
+
28
+ sig { returns(ActionDispatch::Response) }
29
+ def response; end
30
+ end
31
+
32
+ module ActionController::MimeResponds
33
+ sig { params(mimes: T.nilable(Symbol), block: T.nilable(T.proc.params(arg0: ActionController::MimeResponds::Collector).void)).void }
34
+ def respond_to(*mimes, &block); end
35
+ end
36
+
37
+ class ActionController::Parameters
38
+ sig { params(other: T.any(String, ActionController::Parameters)).returns(T::Boolean) }
39
+ def ==(other); end
40
+
41
+ sig { params(key: T.any(String, Symbol), value: T.untyped).void }
42
+ def []=(key, value); end
43
+
44
+ sig { returns(T.nilable(T::Array[T.any(String, Symbol)])) }
45
+ def always_permitted_parameters; end
46
+
47
+ sig { params(obj: T.nilable(T::Array[T.any(String, Symbol)])).void }
48
+ def always_permitted_parameters=(obj); end
49
+
50
+ sig { returns(T.untyped) }
51
+ def deep_dup; end
52
+
53
+ sig { params(key: T.any(String, Symbol), block: T.untyped).returns(T.untyped) }
54
+ def delete(key, &block); end
55
+
56
+ sig { params(keys: T.any(String, Symbol)).returns(T.untyped) }
57
+ def dig(*keys); end
58
+
59
+ sig { params(block: T.untyped).returns(T.untyped) }
60
+ def each_pair(&block); end
61
+
62
+ # each is an alias of each_pair
63
+ sig { params(block: T.untyped).returns(T.untyped) }
64
+ def each(&block); end
65
+
66
+ sig { params(keys: T.any(String, Symbol)).returns(ActionController::Parameters) }
67
+ def except(*keys); end
68
+
69
+ sig { params(keys: T.any(String, Symbol)).returns(T.untyped) }
70
+ def extract!(*keys); end
71
+
72
+ sig { params(key: T.any(String, Symbol), args: T.untyped, block: T.nilable(T.proc.params(key: T.any(String, Symbol)).returns(T.untyped))).returns(T.untyped) }
73
+ def fetch(key, *args, &block); end
74
+
75
+ sig { returns(String) }
76
+ def inspect; end
77
+
78
+ sig { params(other_hash: T.untyped, block: T.untyped).returns(ActionController::Parameters) }
79
+ def merge!(other_hash, &block); end
80
+
81
+ sig { params(other_hash: T.untyped).returns(ActionController::Parameters) }
82
+ def merge(other_hash); end
83
+
84
+ sig { returns(T.untyped) }
85
+ def parameters; end
86
+
87
+ sig { returns(T.self_type) }
88
+ def permit!; end
89
+
90
+ # You can pass _a lot_ of stuff to permit, so filters is left untyped for now.
91
+ sig { params(filters: T.untyped).returns(ActionController::Parameters) }
92
+ def permit(*filters); end
93
+
94
+ sig { params(new_permitted: T.untyped).void }
95
+ def permitted=(new_permitted); end
96
+
97
+ sig { returns(T::Boolean) }
98
+ def permitted?; end
99
+
100
+ sig { params(block: T.untyped).returns(T.untyped) }
101
+ def reject!(&block); end
102
+
103
+ # delete_if is an alias of reject!
104
+ sig { params(block: T.untyped).returns(T.untyped) }
105
+ def delete_if(&block); end
106
+
107
+ sig { params(block: T.untyped).returns(T.untyped) }
108
+ def reject(&block); end
109
+
110
+ sig { params(key: T.any(String, Symbol)).returns(T.untyped) }
111
+ def [](key); end
112
+
113
+ sig { params(key: T.any(String, Symbol)).returns(T.untyped) }
114
+ sig { params(key: T::Array[T.any(String, Symbol)]).returns(T::Array[T.untyped]) }
115
+ def require(key); end
116
+
117
+ # required is an alias of require
118
+ sig { params(key: T.any(String, Symbol)).returns(T.untyped) }
119
+ sig { params(key: T::Array[T.any(String, Symbol)]).returns(T::Array[T.untyped]) }
120
+ def required(key); end
121
+
122
+ sig { params(other_hash: T.untyped).returns(ActionController::Parameters) }
123
+ def reverse_merge!(other_hash); end
124
+
125
+ # with_defaults! is an alias of reverse_merge!
126
+ sig { params(other_hash: T.untyped).returns(ActionController::Parameters) }
127
+ def with_defaults!(other_hash); end
128
+
129
+ sig { params(other_hash: T.untyped).returns(ActionController::Parameters) }
130
+ def reverse_merge(other_hash); end
131
+
132
+ # with_defaults is an alias of reverse_merge
133
+ sig { params(other_hash: T.untyped).returns(ActionController::Parameters) }
134
+ def with_defaults(other_hash); end
135
+
136
+ sig { params(block: T.untyped).returns(T.nilable(ActionController::Parameters)) }
137
+ def select!(&block); end
138
+
139
+ # keep_if is an alias of select!
140
+ sig { params(block: T.untyped).returns(T.nilable(ActionController::Parameters)) }
141
+ def keep_if(&block); end
142
+
143
+ sig { params(block: T.untyped).returns(ActionController::Parameters) }
144
+ def select(&block); end
145
+
146
+ sig { params(keys: T.any(String, Symbol)).returns(ActionController::Parameters) }
147
+ def slice!(*keys); end
148
+
149
+ sig { params(keys: T.any(String, Symbol)).returns(ActionController::Parameters) }
150
+ def slice(*keys); end
151
+
152
+ sig { params(block: T.nilable(Proc)).returns(ActiveSupport::HashWithIndifferentAccess) }
153
+ def to_h(&block); end
154
+
155
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
156
+ def to_hash; end
157
+
158
+ # to_param is an alias of to_query
159
+ sig { params(args: String).returns(T.nilable(String)) }
160
+ def to_param(*args); end
161
+
162
+ sig { params(args: String).returns(T.nilable(String)) }
163
+ def to_query(*args); end
164
+
165
+ sig { returns(ActiveSupport::HashWithIndifferentAccess) }
166
+ def to_unsafe_h; end
167
+
168
+ # to_unsafe_hash is an alias of to_unsafe_h
169
+ sig { returns(ActiveSupport::HashWithIndifferentAccess) }
170
+ def to_unsafe_hash; end
171
+
172
+ sig { params(block: T.untyped).returns(ActionController::Parameters) }
173
+ def transform_keys!(&block); end
174
+
175
+ sig { params(block: T.untyped).returns(ActionController::Parameters) }
176
+ def transform_keys(&block); end
177
+
178
+ sig { params(block: T.nilable(T.proc.params(value: T.untyped).returns(T.untyped))).returns(ActionController::Parameters) }
179
+ def transform_values!(&block); end
180
+
181
+ sig { params(block: T.nilable(T.proc.params(value: T.untyped).returns(T.untyped))).returns(ActionController::Parameters) }
182
+ def transform_values(&block); end
183
+
184
+ sig { params(keys: T.any(String, Symbol)).returns(T.untyped) }
185
+ def values_at(*keys); end
186
+
187
+ sig { returns(T.any(Symbol, T::Boolean)) }
188
+ def self.action_on_unpermitted_parameters; end
189
+
190
+ sig { params(obj: T.any(Symbol, T::Boolean)).void }
191
+ def self.action_on_unpermitted_parameters=(obj); end
192
+
193
+ sig { returns(T::Array[T.any(String, Symbol)]) }
194
+ def self.always_permitted_parameters; end
195
+
196
+ sig { params(obj: T::Array[T.any(String, Symbol)]).void }
197
+ def self.always_permitted_parameters=(obj); end
198
+
199
+ sig { returns(T::Boolean) }
200
+ def self.permit_all_parameters; end
201
+
202
+ sig { params(obj: T::Boolean).void }
203
+ def self.permit_all_parameters=(obj); end
204
+ end
205
+
206
+ module ActionController::RequestForgeryProtection
207
+ sig { returns(T::Boolean) }
208
+ def protect_against_forgery?; end
209
+
210
+ sig { params(form_options: T::Hash[T.untyped, T.untyped]).returns(String) }
211
+ def form_authenticity_token(form_options: {}); end
212
+ end
213
+
214
+ module ActionController::RequestForgeryProtection::ClassMethods
215
+ sig { params(options: T::Hash[T.untyped, T.untyped]).void }
216
+ def skip_forgery_protection(options = T.unsafe(nil)); end
217
+ end
218
+
219
+ module ActionController::StrongParameters
220
+ sig { returns(ActionController::Parameters) }
221
+ def params; end
222
+ end
223
+
224
+ module ActionDispatch::Http::Parameters
225
+ sig { returns(ActionController::Parameters) }
226
+ def parameters; end
227
+
228
+ # params is an alias of parameters
229
+ sig { returns(ActionController::Parameters) }
230
+ def params; end
231
+ end
232
+
233
+ module ActionDispatch::Integration::Runner
234
+ # @method_missing: delegated to ActionDispatch::Integration::Session
235
+ sig { params(host: String).returns(String) }
236
+ def host!(host); end
237
+
238
+ # @method_missing: delegated to ActionDispatch::Integration::Session
239
+ sig { params(flag: T::Boolean).returns(T::Boolean) }
240
+ def https!(flag = true); end
241
+ end
242
+
243
+ class ActionDispatch::IntegrationTest
244
+ # The following methods are accessible on `IntegrationTest`
245
+ # through the following delegation chain:
246
+ # - `IntegrationTest` includes `IntegrationTest::Behavior`
247
+ # - `IntegrationTest::Behavior` includes `Integration::Runner`
248
+ # - `Integration::Runner#method_missing` delegates to `Integration::Session`
249
+ #
250
+ # Then `Integration::Session` either implements the methods
251
+ # directly or further delegates to `TestProcess` (included) or
252
+ # `TestResponse` / `Request` (via `delegate`).
253
+ #
254
+ # Cf. https://github.com/Shopify/rbi-central/pull/138 for more context.
255
+ # @method_missing: delegated to ActionDispatch::TestProcess
256
+ sig { returns(ActionDispatch::Flash::FlashHash) }
257
+ def flash; end
258
+
259
+ # @method_missing: delegated to ActionDispatch::TestProcess
260
+ sig { returns(ActionDispatch::Request::Session) }
261
+ def session; end
262
+
263
+ # @method_missing: delegated to ActionDispatch::TestResponse
264
+ sig { returns(T.nilable(Integer)) }
265
+ def status; end
266
+
267
+ # @method_missing: delegated to ActionDispatch::TestResponse
268
+ sig { returns(T.nilable(String)) }
269
+ def status_message; end
270
+
271
+ # @method_missing: delegated to ActionDispatch::TestResponse
272
+ sig { returns(ActionDispatch::Response::Header) }
273
+ def headers; end
274
+
275
+ # @method_missing: delegated to ActionDispatch::TestResponse
276
+ sig { returns(T.nilable(String)) }
277
+ def body; end
278
+
279
+ # @method_missing: delegated to ActionDispatch::TestResponse
280
+ sig { returns(T.nilable(T::Boolean)) }
281
+ def redirect?; end
282
+
283
+ # @method_missing: delegated to ActionDispatch::Request
284
+ sig { returns(T.nilable(String)) }
285
+ def path; end
286
+
287
+ # @method_missing: delegated to ActionDispatch::Integration::Session
288
+ sig { returns(String) }
289
+ def host; end
290
+
291
+ # @method_missing: delegated to ActionDispatch::Integration::Session
292
+ sig { params(host: String).returns(String) }
293
+ attr_writer :host
294
+
295
+ # @method_missing: delegated to ActionDispatch::Integration::Session
296
+ sig { returns(T.nilable(String)) }
297
+ attr_accessor :remote_addr
298
+
299
+ # @method_missing: delegated to ActionDispatch::Integration::Session
300
+ sig { returns(T.nilable(String)) }
301
+ attr_accessor :accept
302
+
303
+ # @method_missing: delegated to ActionDispatch::Integration::Session
304
+ sig { returns(Rack::Test::CookieJar) }
305
+ def cookies; end
306
+
307
+ # @method_missing: delegated to ActionDispatch::Integration::Session
308
+ sig { returns(T.nilable(ActionController::Base)) }
309
+ attr_reader :controller
310
+
311
+ # @method_missing: delegated to ActionDispatch::Integration::Session
312
+ sig { returns(ActionDispatch::TestRequest) }
313
+ attr_reader :request
314
+
315
+ # @method_missing: delegated to ActionDispatch::Integration::Session
316
+ sig { returns(ActionDispatch::TestResponse) }
317
+ attr_reader :response
318
+
319
+ # @method_missing: delegated to ActionDispatch::Integration::Session
320
+ sig { returns(Integer) }
321
+ attr_accessor :request_count
322
+ end
323
+
324
+ class ActionDispatch::Request
325
+ # Provides access to the request's HTTP headers, for example:
326
+ #
327
+ # ```ruby
328
+ # request.headers["Content-Type"] # => "text/plain"
329
+ # ```
330
+ sig { returns(ActionDispatch::Http::Headers) }
331
+ def headers; end
332
+
333
+ # Returns a `String` with the last requested path including their params.
334
+ #
335
+ # ```ruby
336
+ # # get '/foo'
337
+ # request.original_fullpath # => '/foo'
338
+ #
339
+ # # get '/foo?bar'
340
+ # request.original_fullpath # => '/foo?bar'
341
+ # ```
342
+ sig { returns(String) }
343
+ def original_fullpath; end
344
+
345
+ # Returns the `String` full path including params of the last URL requested.
346
+ #
347
+ # ```ruby
348
+ # # get "/articles"
349
+ # request.fullpath # => "/articles"
350
+ #
351
+ # # get "/articles?page=2"
352
+ # request.fullpath # => "/articles?page=2"
353
+ # ```
354
+ sig { returns(String) }
355
+ def fullpath; end
356
+
357
+ # Returns the original request URL as a `String`.
358
+ #
359
+ # ```ruby
360
+ # # get "/articles?page=2"
361
+ # request.original_url # => "http://www.example.com/articles?page=2"
362
+ # ```
363
+ sig { returns(String) }
364
+ def original_url; end
365
+
366
+ # The `String` MIME type of the request.
367
+ #
368
+ # ```
369
+ # # get "/articles"
370
+ # request.media_type # => "application/x-www-form-urlencoded"
371
+ # ```
372
+ sig { returns(String) }
373
+ def media_type; end
374
+
375
+ # Returns the content length of the request as an integer.
376
+ sig { returns(Integer) }
377
+ def content_length; end
378
+
379
+ # Returns the IP address of client as a `String`.
380
+ sig { returns(String) }
381
+ def ip; end
382
+
383
+ # Returns the IP address of client as a `String`,
384
+ # usually set by the RemoteIp middleware.
385
+ sig { returns(String) }
386
+ def remote_ip; end
387
+
388
+ # Returns the unique request id, which is based on either the X-Request-Id header that can
389
+ # be generated by a firewall, load balancer, or web server or by the RequestId middleware
390
+ # (which sets the action_dispatch.request_id environment variable).
391
+ #
392
+ # This unique ID is useful for tracing a request from end-to-end as part of logging or debugging.
393
+ # This relies on the Rack variable set by the ActionDispatch::RequestId middleware.
394
+ sig { returns(T.nilable(String)) }
395
+ def request_id; end
396
+
397
+ # Returns true if the request has a header matching the given key parameter.
398
+ #
399
+ # ```ruby
400
+ # request.key? :ip_spoofing_check # => true
401
+ # ```
402
+ sig { params(key: Symbol).returns(T::Boolean) }
403
+ def key?(key); end
404
+
405
+ # True if the request came from localhost, 127.0.0.1, or ::1.
406
+ sig { returns(T::Boolean) }
407
+ def local?; end
408
+ end
409
+
410
+ module ActionDispatch::Routing::Mapper::Resources
411
+ sig { params(name: T.untyped).returns(T.untyped) }
412
+ def action_path(name); end
413
+
414
+ sig { params(block: T.untyped).returns(T.untyped) }
415
+ def collection(&block); end
416
+
417
+ sig { params(block: T.untyped).returns(T.untyped) }
418
+ def member(&block); end
419
+
420
+ sig { returns(T.untyped) }
421
+ def shallow; end
422
+
423
+ sig { returns(T::Boolean) }
424
+ def shallow?; end
425
+ end
426
+
427
+ class ActionDispatch::Routing::RouteSet
428
+ sig { params(block: T.proc.bind(ActionDispatch::Routing::Mapper).void).void }
429
+ def draw(&block); end
430
+ end