rage-rb 1.6.0 → 1.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +10 -7
- data/OVERVIEW.md +1 -1
- data/README.md +25 -9
- data/lib/rage/all.rb +1 -0
- data/lib/rage/cable/cable.rb +130 -0
- data/lib/rage/cable/channel.rb +452 -0
- data/lib/rage/cable/connection.rb +78 -0
- data/lib/rage/cable/protocol/actioncable_v1_json.rb +167 -0
- data/lib/rage/cable/router.rb +138 -0
- data/lib/rage/cli.rb +2 -1
- data/lib/rage/code_loader.rb +9 -0
- data/lib/rage/configuration.rb +53 -0
- data/lib/rage/controller/api.rb +51 -13
- data/lib/rage/cookies.rb +7 -9
- data/lib/rage/ext/active_record/connection_pool.rb +1 -1
- data/lib/rage/fiber.rb +3 -3
- data/lib/rage/fiber_scheduler.rb +1 -1
- data/lib/rage/logger/json_formatter.rb +1 -1
- data/lib/rage/logger/logger.rb +1 -1
- data/lib/rage/logger/text_formatter.rb +1 -1
- data/lib/rage/middleware/cors.rb +2 -2
- data/lib/rage/middleware/fiber_wrapper.rb +3 -1
- data/lib/rage/middleware/origin_validator.rb +38 -0
- data/lib/rage/middleware/reloader.rb +1 -1
- data/lib/rage/params_parser.rb +1 -1
- data/lib/rage/router/backend.rb +4 -6
- data/lib/rage/router/constrainer.rb +1 -1
- data/lib/rage/router/dsl.rb +7 -7
- data/lib/rage/router/dsl_plugins/legacy_hash_notation.rb +1 -1
- data/lib/rage/router/dsl_plugins/legacy_root_notation.rb +1 -1
- data/lib/rage/router/handler_storage.rb +1 -1
- data/lib/rage/session.rb +2 -2
- data/lib/rage/setup.rb +5 -1
- data/lib/rage/sidekiq_session.rb +1 -1
- data/lib/rage/version.rb +1 -1
- data/lib/rage-rb.rb +23 -15
- data/rage.gemspec +1 -1
- metadata +8 -2
data/lib/rage/router/dsl.rb
CHANGED
@@ -17,7 +17,7 @@ class Rage::Router::DSL
|
|
17
17
|
end
|
18
18
|
|
19
19
|
##
|
20
|
-
# This class implements routing logic for your application, providing API similar to Rails.
|
20
|
+
# This class implements routing logic for your application, providing an API similar to Rails.
|
21
21
|
#
|
22
22
|
# Compared to the Rails router, the most notable difference is that a wildcard segment can only be in the last section of the path and cannot be named.
|
23
23
|
# Example:
|
@@ -213,7 +213,7 @@ class Rage::Router::DSL
|
|
213
213
|
@path_prefixes << path_prefix
|
214
214
|
@module_prefixes << module_prefix
|
215
215
|
|
216
|
-
instance_eval
|
216
|
+
instance_eval(&block)
|
217
217
|
|
218
218
|
@path_prefixes.pop
|
219
219
|
@module_prefixes.pop
|
@@ -253,7 +253,7 @@ class Rage::Router::DSL
|
|
253
253
|
@module_prefixes << opts[:module] if opts[:module]
|
254
254
|
@controllers << opts[:controller] if opts[:controller]
|
255
255
|
|
256
|
-
instance_eval
|
256
|
+
instance_eval(&block)
|
257
257
|
|
258
258
|
@path_prefixes.pop if opts[:path]
|
259
259
|
@module_prefixes.pop if opts[:module]
|
@@ -269,7 +269,7 @@ class Rage::Router::DSL
|
|
269
269
|
# end
|
270
270
|
def defaults(defaults, &block)
|
271
271
|
@defaults << defaults
|
272
|
-
instance_eval
|
272
|
+
instance_eval(&block)
|
273
273
|
@defaults.pop
|
274
274
|
end
|
275
275
|
|
@@ -282,7 +282,7 @@ class Rage::Router::DSL
|
|
282
282
|
# end
|
283
283
|
def controller(controller, &block)
|
284
284
|
@controllers << controller
|
285
|
-
instance_eval
|
285
|
+
instance_eval(&block)
|
286
286
|
@controllers.pop
|
287
287
|
end
|
288
288
|
|
@@ -297,7 +297,7 @@ class Rage::Router::DSL
|
|
297
297
|
def collection(&block)
|
298
298
|
orig_path_prefixes = @path_prefixes
|
299
299
|
@path_prefixes = @path_prefixes[0...-1] if @path_prefixes.last&.start_with?(":")
|
300
|
-
instance_eval
|
300
|
+
instance_eval(&block)
|
301
301
|
@path_prefixes = orig_path_prefixes
|
302
302
|
end
|
303
303
|
|
@@ -317,7 +317,7 @@ class Rage::Router::DSL
|
|
317
317
|
@path_prefixes = [*@path_prefixes[0...-1], ":#{member_prefix}"]
|
318
318
|
end
|
319
319
|
|
320
|
-
instance_eval
|
320
|
+
instance_eval(&block)
|
321
321
|
|
322
322
|
@path_prefixes = orig_path_prefixes
|
323
323
|
end
|
data/lib/rage/session.rb
CHANGED
data/lib/rage/setup.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Iodine.patch_rack
|
2
2
|
|
3
|
-
|
3
|
+
begin
|
4
|
+
require_relative "#{Rage.root}/config/environments/#{Rage.env}"
|
5
|
+
rescue LoadError
|
6
|
+
raise LoadError, "The <#{Rage.env}> environment could not be found. Please check the environment name."
|
7
|
+
end
|
4
8
|
|
5
9
|
# Run application initializers
|
6
10
|
Dir["#{Rage.root}/config/initializers/**/*.rb"].each { |initializer| load(initializer) }
|
data/lib/rage/sidekiq_session.rb
CHANGED
data/lib/rage/version.rb
CHANGED
data/lib/rage-rb.rb
CHANGED
@@ -7,27 +7,17 @@ require "pathname"
|
|
7
7
|
|
8
8
|
module Rage
|
9
9
|
def self.application
|
10
|
-
|
11
|
-
|
12
|
-
config.middleware.middlewares.reverse.inject(app) do |next_in_chain, (middleware, args, block)|
|
13
|
-
# in Rails compatibility mode we first check if the middleware is a part of the Rails middleware stack;
|
14
|
-
# if it is - it is expected to be built using `ActionDispatch::MiddlewareStack::Middleware#build`
|
15
|
-
if Rage.config.internal.rails_mode
|
16
|
-
rails_middleware = Rails.application.config.middleware.middlewares.find { |m| m.name == middleware.name }
|
17
|
-
end
|
18
|
-
|
19
|
-
if rails_middleware
|
20
|
-
rails_middleware.build(next_in_chain)
|
21
|
-
else
|
22
|
-
middleware.new(next_in_chain, *args, &block)
|
23
|
-
end
|
24
|
-
end
|
10
|
+
with_middlewares(Application.new(__router), config.middleware.middlewares)
|
25
11
|
end
|
26
12
|
|
27
13
|
def self.multi_application
|
28
14
|
Rage::Router::Util::Cascade.new(application, Rails.application)
|
29
15
|
end
|
30
16
|
|
17
|
+
def self.cable
|
18
|
+
Rage::Cable
|
19
|
+
end
|
20
|
+
|
31
21
|
def self.routes
|
32
22
|
Rage::Router::DSL.new(__router)
|
33
23
|
end
|
@@ -90,6 +80,23 @@ module Rage
|
|
90
80
|
end
|
91
81
|
end
|
92
82
|
|
83
|
+
# @private
|
84
|
+
def self.with_middlewares(app, middlewares)
|
85
|
+
middlewares.reverse.inject(app) do |next_in_chain, (middleware, args, block)|
|
86
|
+
# in Rails compatibility mode we first check if the middleware is a part of the Rails middleware stack;
|
87
|
+
# if it is - it is expected to be built using `ActionDispatch::MiddlewareStack::Middleware#build`
|
88
|
+
if Rage.config.internal.rails_mode
|
89
|
+
rails_middleware = Rails.application.config.middleware.middlewares.find { |m| m.name == middleware.name }
|
90
|
+
end
|
91
|
+
|
92
|
+
if rails_middleware
|
93
|
+
rails_middleware.build(next_in_chain)
|
94
|
+
else
|
95
|
+
middleware.new(next_in_chain, *args, &block)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
93
100
|
module Router
|
94
101
|
module Strategies
|
95
102
|
end
|
@@ -106,6 +113,7 @@ module Rage
|
|
106
113
|
|
107
114
|
autoload :Cookies, "rage/cookies"
|
108
115
|
autoload :Session, "rage/session"
|
116
|
+
autoload :Cable, "rage/cable/cable"
|
109
117
|
end
|
110
118
|
|
111
119
|
module RageController
|
data/rage.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
21
|
spec.files = Dir.chdir(__dir__) do
|
22
22
|
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
-
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
23
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor .rubocop])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
spec.bindir = "exe"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rage-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Samoilov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -102,6 +102,11 @@ files:
|
|
102
102
|
- lib/rage.rb
|
103
103
|
- lib/rage/all.rb
|
104
104
|
- lib/rage/application.rb
|
105
|
+
- lib/rage/cable/cable.rb
|
106
|
+
- lib/rage/cable/channel.rb
|
107
|
+
- lib/rage/cable/connection.rb
|
108
|
+
- lib/rage/cable/protocol/actioncable_v1_json.rb
|
109
|
+
- lib/rage/cable/router.rb
|
105
110
|
- lib/rage/cli.rb
|
106
111
|
- lib/rage/code_loader.rb
|
107
112
|
- lib/rage/configuration.rb
|
@@ -118,6 +123,7 @@ files:
|
|
118
123
|
- lib/rage/logger/text_formatter.rb
|
119
124
|
- lib/rage/middleware/cors.rb
|
120
125
|
- lib/rage/middleware/fiber_wrapper.rb
|
126
|
+
- lib/rage/middleware/origin_validator.rb
|
121
127
|
- lib/rage/middleware/reloader.rb
|
122
128
|
- lib/rage/params_parser.rb
|
123
129
|
- lib/rage/rails.rb
|