rackr 0.0.70 → 0.0.72
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/lib/rackr/action/callbacks.rb +18 -14
- data/lib/rackr/action.rb +7 -3
- data/lib/rackr/router.rb +6 -1
- data/lib/rackr.rb +8 -4
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72cceb3bd70c8b972d5a3aa576cc5a599324556ea8352ca3bd98c223e72e06d3
|
|
4
|
+
data.tar.gz: 75ca9eb7196080083fdd6c023ca19182ca778ae501f62105fc26253c2311e8c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb6481af7ec6eca55a45795d9237936ed71b26a36e3b31c49574a00de827d71ec57abe62d21ff49595a806d83b24361a55c1c2865b72df12a598c3a09a1a5084
|
|
7
|
+
data.tar.gz: a2958c5afe1df9932d64723c9f7f1ea3844d2e11e3c41a64f78b2534dde2add1e257c732118a7f688d14b9f3d1e9139f7550b636436495530e593f4be375d06e
|
|
@@ -13,37 +13,41 @@ class Rackr
|
|
|
13
13
|
|
|
14
14
|
# Class methods for callbacks
|
|
15
15
|
module ClassMethods
|
|
16
|
+
def inherited(subclass)
|
|
17
|
+
super
|
|
18
|
+
# When a class inherits, it should get a copy of the parent's callbacks
|
|
19
|
+
# so that its own additions don't modify the parent's list.
|
|
20
|
+
# Using .dup to ensure a new array object is created for the subclass.
|
|
21
|
+
subclass.instance_variable_set(:@befores, befores.dup) if instance_variable_defined?(:@befores)
|
|
22
|
+
subclass.instance_variable_set(:@afters, afters.dup) if instance_variable_defined?(:@afters)
|
|
23
|
+
end
|
|
24
|
+
|
|
16
25
|
def before(callback)
|
|
17
|
-
@befores
|
|
26
|
+
@befores ||= []
|
|
27
|
+
@befores.concat(ensure_array(callback))
|
|
18
28
|
end
|
|
19
29
|
|
|
20
30
|
def befores
|
|
21
|
-
@befores
|
|
31
|
+
@befores || []
|
|
22
32
|
end
|
|
23
33
|
|
|
24
34
|
def after(callback)
|
|
25
|
-
@afters
|
|
35
|
+
@afters ||= []
|
|
36
|
+
@afters.concat(ensure_array(callback))
|
|
26
37
|
end
|
|
27
38
|
|
|
28
39
|
def afters
|
|
29
|
-
@afters
|
|
40
|
+
@afters || []
|
|
30
41
|
end
|
|
31
42
|
end
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
@befores = ensure_array(callback)
|
|
35
|
-
end
|
|
36
|
-
|
|
44
|
+
# Instance methods to access class-level callbacks
|
|
37
45
|
def befores
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def after(callback)
|
|
42
|
-
@afters = ensure_array(callback)
|
|
46
|
+
self.class.befores
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
def afters
|
|
46
|
-
|
|
50
|
+
self.class.afters
|
|
47
51
|
end
|
|
48
52
|
end
|
|
49
53
|
end
|
data/lib/rackr/action.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'erubi'
|
|
|
4
4
|
require 'oj'
|
|
5
5
|
require 'rack'
|
|
6
6
|
require_relative 'action/callbacks'
|
|
7
|
+
require_relative 'callback'
|
|
7
8
|
|
|
8
9
|
class Rackr
|
|
9
10
|
# This module provides the action functions available inside the routes context or
|
|
@@ -149,12 +150,14 @@ class Rackr
|
|
|
149
150
|
else
|
|
150
151
|
attr_reader :routes, :config, :deps, :db, :log, :cache
|
|
151
152
|
|
|
152
|
-
include Callbacks unless include?(Rackr::
|
|
153
|
+
include Callbacks unless include?(Rackr::Action::Callbacks)
|
|
154
|
+
include HtmlSlice if Object.const_defined?('HtmlSlice')
|
|
155
|
+
include Stimulux if Object.const_defined?('Stimulux')
|
|
153
156
|
end
|
|
154
157
|
|
|
155
158
|
def initialize(routes: nil, config: nil)
|
|
156
|
-
self.class.include(HtmlSlice) if Object.const_defined?('HtmlSlice')
|
|
157
|
-
self.class.include(Stimulux) if Object.const_defined?('Stimulux')
|
|
159
|
+
# self.class.include(HtmlSlice) if Object.const_defined?('HtmlSlice')
|
|
160
|
+
# self.class.include(Stimulux) if Object.const_defined?('Stimulux')
|
|
158
161
|
|
|
159
162
|
@routes = routes
|
|
160
163
|
@config = config
|
|
@@ -342,6 +345,7 @@ class Rackr
|
|
|
342
345
|
@content_security_policy ||=
|
|
343
346
|
DEFAULT_CSP_HEADERS
|
|
344
347
|
.merge(config&.dig(:csp_headers) || {})
|
|
348
|
+
.compact
|
|
345
349
|
.map { |k, v| "#{k.to_s.tr('_', '-')} #{v}" }
|
|
346
350
|
.join('; ')
|
|
347
351
|
end
|
data/lib/rackr/router.rb
CHANGED
|
@@ -30,6 +30,7 @@ class Rackr
|
|
|
30
30
|
@scopes = []
|
|
31
31
|
@befores = ensure_array(before)
|
|
32
32
|
@scopes_befores = {}
|
|
33
|
+
@empty_scopes_ids = 0
|
|
33
34
|
@afters = ensure_array(after)
|
|
34
35
|
@scopes_afters = {}
|
|
35
36
|
@path_routes_tree = {}
|
|
@@ -227,6 +228,10 @@ class Rackr
|
|
|
227
228
|
Errors.check_callbacks(scope_afters, name)
|
|
228
229
|
|
|
229
230
|
name = ":#{name}" if name.is_a? Symbol
|
|
231
|
+
if name == ''
|
|
232
|
+
@empty_scopes_ids = @empty_scopes_ids + 1
|
|
233
|
+
name = @empty_scopes_ids
|
|
234
|
+
end
|
|
230
235
|
|
|
231
236
|
@scopes.push(name)
|
|
232
237
|
|
|
@@ -246,7 +251,7 @@ class Rackr
|
|
|
246
251
|
end
|
|
247
252
|
|
|
248
253
|
def not_empty_scopes
|
|
249
|
-
@scopes.reject { |
|
|
254
|
+
@scopes.reject { |s| s.is_a?(Integer) }
|
|
250
255
|
end
|
|
251
256
|
|
|
252
257
|
private
|
data/lib/rackr.rb
CHANGED
|
@@ -7,7 +7,7 @@ require_relative 'rackr/router'
|
|
|
7
7
|
|
|
8
8
|
# Rackr is a simple router for Rack.
|
|
9
9
|
class Rackr
|
|
10
|
-
VERSION = '0.0.
|
|
10
|
+
VERSION = '0.0.72'
|
|
11
11
|
|
|
12
12
|
class NotFound < StandardError; end
|
|
13
13
|
|
|
@@ -202,9 +202,13 @@ class Rackr
|
|
|
202
202
|
path = params[0] || ''
|
|
203
203
|
endpoint = params[1] || ''
|
|
204
204
|
scopes = []
|
|
205
|
-
if path.is_a?(String)
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
if path.is_a?(String)
|
|
206
|
+
path = path.delete_prefix('/')
|
|
207
|
+
|
|
208
|
+
if path.include?('/')
|
|
209
|
+
scopes = path.split('/')[0...-1]
|
|
210
|
+
path = path.split('/').pop
|
|
211
|
+
end
|
|
208
212
|
end
|
|
209
213
|
scopes.each { |scope_name| @router.append_scope(scope_name) }
|
|
210
214
|
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rackr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.72
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henrique F. Teixeira
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-21 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: erubi
|
|
@@ -80,6 +81,7 @@ homepage: https://github.com/henrique-ft/rackr
|
|
|
80
81
|
licenses:
|
|
81
82
|
- MIT
|
|
82
83
|
metadata: {}
|
|
84
|
+
post_install_message:
|
|
83
85
|
rdoc_options: []
|
|
84
86
|
require_paths:
|
|
85
87
|
- lib
|
|
@@ -94,7 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
96
|
- !ruby/object:Gem::Version
|
|
95
97
|
version: '0'
|
|
96
98
|
requirements: []
|
|
97
|
-
rubygems_version: 3.
|
|
99
|
+
rubygems_version: 3.3.3
|
|
100
|
+
signing_key:
|
|
98
101
|
specification_version: 4
|
|
99
102
|
summary: Rack first web framework.
|
|
100
103
|
test_files: []
|