hub_kernel 0.23.0 → 0.24.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/README.md +5 -0
- data/lib/hub_kernel/crossings.rb +1 -2
- data/lib/hub_kernel/engine.rb +2 -0
- data/lib/hub_kernel/hub_folders.rb +7 -0
- data/lib/hub_kernel/records.rb +10 -4
- data/lib/hub_kernel/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: 278e7929cc3994d1e1149a5fa9ce387922748cb829f615e9bf56e52d960f1d06
|
|
4
|
+
data.tar.gz: b60a8992e16825e54d1c8f211e9ce09a814bfe4d0215d94bc40d8da77f74a281
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82a223294f8bbe74427019e44a38ef20678e8d6680d4e384e2c68be6322abe05da574dfa47dca5689d0ee31103ff903f841001906378842ed25aa81f1f6e5310
|
|
7
|
+
data.tar.gz: bb81b8f0de934af592603666605e30349170ac35bd89fe59a6903cf51e62a5e4cf0dc36070dd1dd44d9c201999efddfc46e79c45002698787e3b9015f99c7819
|
data/README.md
CHANGED
|
@@ -42,6 +42,11 @@ module may be defined in `app/models/` or in another hub's folder. A host with n
|
|
|
42
42
|
|
|
43
43
|
Files under a hub's `lib/` folder, such as its generated event pack, are not loaded.
|
|
44
44
|
|
|
45
|
+
Every hub module in a hub folder, a module that extends `HubKernel::Ports` or
|
|
46
|
+
`HubKernel::Exposes`, is loaded at boot and again after each code reload, before the
|
|
47
|
+
host's own `to_prepare` code runs. A hub the host's code never names is still on
|
|
48
|
+
`HubKernel::Hubs.list` for the start check, and hub_kernel-interface still serves it.
|
|
49
|
+
|
|
45
50
|
A hub folder's `views` are searched after the host's `app/views`, so a controller in the
|
|
46
51
|
hub renders its templates from there, any view can render a hub partial by its usual
|
|
47
52
|
path, and a template in `app/views` wins over one at the same path in a hub folder. A
|
data/lib/hub_kernel/crossings.rb
CHANGED
|
@@ -3,7 +3,6 @@ require "active_support/core_ext/string/inflections"
|
|
|
3
3
|
|
|
4
4
|
module HubKernel
|
|
5
5
|
class Crossings
|
|
6
|
-
HUB_MODULE = /extend HubKernel::(Ports|Exposes)\b/
|
|
7
6
|
def initialize(owners: {}, shared: [], host_layer: nil, interfaces: {}, namespaces: {}, folder_files: [])
|
|
8
7
|
@owners = owners
|
|
9
8
|
@folder_classes = {}
|
|
@@ -27,7 +26,7 @@ module HubKernel
|
|
|
27
26
|
|
|
28
27
|
def read_hub_modules(sources)
|
|
29
28
|
sources.each do |path, source|
|
|
30
|
-
next unless
|
|
29
|
+
next unless HubFolders.hub_module?(path, source)
|
|
31
30
|
|
|
32
31
|
@folder_interfaces[HubFolders.class_of(path)] = HubFolders.hub_of(path)
|
|
33
32
|
end
|
data/lib/hub_kernel/engine.rb
CHANGED
|
@@ -7,6 +7,7 @@ module HubKernel
|
|
|
7
7
|
|
|
8
8
|
PATH = %r{\A#{ROOT}/([^/]+)/}
|
|
9
9
|
CODE_PATH = %r{\A#{ROOT}/[^/]+/#{CODE}/[^/]+/}
|
|
10
|
+
HUB_MODULE = /extend HubKernel::(Ports|Exposes)\b/
|
|
10
11
|
|
|
11
12
|
def self.folder(hub) = "#{ROOT}/#{hub}"
|
|
12
13
|
|
|
@@ -24,6 +25,12 @@ module HubKernel
|
|
|
24
25
|
|
|
25
26
|
def self.helper_paths(root) = Dir[root.join("#{code_glob}/helpers")]
|
|
26
27
|
|
|
28
|
+
def self.hub_module?(path, source) = source.match?(HUB_MODULE) && path.match?(CODE_PATH)
|
|
29
|
+
|
|
30
|
+
def self.hub_modules(root)
|
|
31
|
+
Dir.glob("#{code_glob}/**/*.rb", base: root).select { |path| hub_module?(path, root.join(path).read) }.map { |path| class_of(path) }
|
|
32
|
+
end
|
|
33
|
+
|
|
27
34
|
def self.hub_of_controller(root, page)
|
|
28
35
|
controllers = Dir[root.join(code_glob, "controllers", "#{page}_controller.rb").to_s].sort
|
|
29
36
|
hubs = controllers.map { |controller| hub_of(Pathname(controller).relative_path_from(root).to_s) }
|
data/lib/hub_kernel/records.rb
CHANGED
|
@@ -3,15 +3,21 @@ module HubKernel
|
|
|
3
3
|
private
|
|
4
4
|
|
|
5
5
|
def saved(record)
|
|
6
|
-
record.save ? record.id : refuse(record)
|
|
6
|
+
record.save ? record.id : refuse(record, "saved")
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def removed(record)
|
|
10
|
-
record.destroy ? record.id : refuse(record)
|
|
10
|
+
record.destroy ? record.id : refuse(record, "deleted")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def refuse(record)
|
|
14
|
-
raise Refused, record
|
|
13
|
+
def refuse(record, action)
|
|
14
|
+
raise Refused, refusal(record, action)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def refusal(record, action)
|
|
18
|
+
return record.errors.full_messages.to_sentence if record.errors.any?
|
|
19
|
+
|
|
20
|
+
"#{record.model_name.human} could not be #{action}"
|
|
15
21
|
end
|
|
16
22
|
end
|
|
17
23
|
end
|
data/lib/hub_kernel/version.rb
CHANGED