ratalada-contrib 3.0.0 → 3.0.1
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/ratalada/contrib/router/file_based.rb +17 -13
- data/lib/ratalada/contrib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f94789e43bf70a8638e24126024e340669543cdb8126516faf70e4efb0ebb553
|
|
4
|
+
data.tar.gz: 1e428b4d5dae6ed2dfc9ef06cc28d24bceb982f7255295d3918717e99a431881
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dfe78d482fbd3486981c591e50875219c0f2c1865c1cf7147547021a7a66aaeb535c9e1edeb1d09d85619047791d68805641bb577d2d62ea98267cf740b1669
|
|
7
|
+
data.tar.gz: 4ca2093d272fc1e124d2c5f6697193206af316b53daf1113e57125b295877226250ecdefb2453a86013a62b8c108820e57d42a419e98e74ff38f2d99c7f5ce95
|
|
@@ -12,21 +12,25 @@ module Ratalada
|
|
|
12
12
|
|
|
13
13
|
module_function
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
15
|
+
# Evaluates every route file in the directory into an app class, under
|
|
16
|
+
# the prefix its path spells. That class is the frontend's own, so this
|
|
17
|
+
# is what a Server.run block calls: the block is already being evaluated
|
|
18
|
+
# into it, and `self` is it. Requiring the frontend's adapter is what
|
|
19
|
+
# teaches the class `route_prefix`.
|
|
20
|
+
#
|
|
21
|
+
# Server.run { Ratalada::Contrib::Router::FileBased.mount(self, "app") }
|
|
22
|
+
def mount(app, directory)
|
|
23
|
+
build_map(directory).each do |prefix, paths|
|
|
24
|
+
app.route_prefix = prefix
|
|
25
|
+
paths.each { |path| app.class_eval(File.read(path), path, 1) }
|
|
27
26
|
end
|
|
27
|
+
end
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
# The same, as a whole app built by whichever Ratalada frontend is in
|
|
30
|
+
# use — for mounting a directory somewhere other than the server's own
|
|
31
|
+
# run block.
|
|
32
|
+
def build(directory)
|
|
33
|
+
Ratalada.frontend.build(proc { FileBased.mount(self, directory) })
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
# A hash of route => the files that serve it, ordered most specific
|