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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd2d16bc3b97e31abe859281ecc0ba7a322a6bce7dc1a71e854a21d80e470fdb
4
- data.tar.gz: 4f4139c69c3183ddae2b4c2df734424e0a18be4d31b10f937491be9718753156
3
+ metadata.gz: f94789e43bf70a8638e24126024e340669543cdb8126516faf70e4efb0ebb553
4
+ data.tar.gz: 1e428b4d5dae6ed2dfc9ef06cc28d24bceb982f7255295d3918717e99a431881
5
5
  SHA512:
6
- metadata.gz: 601080c5ec4fff081b714aaca9d6499bea7eda3d97ef1cfd7f5ea355e00178094c81d52921024d414bf07663fd4090c37d3e943b40bf53c52977629cd85b92f4
7
- data.tar.gz: 66c6a9b432555f7d0a542f1eed3d364d108cdb2fbb9b2f4e6cc2f414020997369e2a4ac3518f05402400e09a9cfd3c39c8f7a9bcad4825214966c5635065d661
6
+ metadata.gz: 7dfe78d482fbd3486981c591e50875219c0f2c1865c1cf7147547021a7a66aaeb535c9e1edeb1d09d85619047791d68805641bb577d2d62ea98267cf740b1669
7
+ data.tar.gz: 4ca2093d272fc1e124d2c5f6697193206af316b53daf1113e57125b295877226250ecdefb2453a86013a62b8c108820e57d42a419e98e74ff38f2d99c7f5ce95
@@ -12,21 +12,25 @@ module Ratalada
12
12
 
13
13
  module_function
14
14
 
15
- # The app, built by whichever Ratalada frontend is in use: every route
16
- # file is evaluated into the frontend's own class, under the prefix its
17
- # path spells. Requiring the frontend's adapter is what teaches that
18
- # class `route_prefix`.
19
- def build(directory)
20
- map = build_map(directory)
21
-
22
- routes = proc do
23
- map.each do |prefix, paths|
24
- self.route_prefix = prefix
25
- paths.each { |path| class_eval(File.read(path), path, 1) }
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
- Ratalada.frontend.build(routes)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ratalada
4
4
  module Contrib
5
- VERSION = "3.0.0"
5
+ VERSION = "3.0.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratalada-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K