hub_kernel-interface 0.1.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38b1b23f80d6d9309426a790f9f7e44d0ab7d3da6c092e5845a4a6ba7bbe9b36
4
- data.tar.gz: 4e82d38b3c66e95e5ca4388d1ba45ef25e0b36984ed52bac9dc86c1cfa9fa45c
3
+ metadata.gz: 37c5ea275a8aaacc15d056ff35580688737ef2210a22e22846276404cf7b052b
4
+ data.tar.gz: 8ca84328489427f9d5616ad4d93b620219bbb6bc550a5ec63ac0f7e54ec3e569
5
5
  SHA512:
6
- metadata.gz: ccdc332bfa7357d30249401bbef0e7fca543840bb3a580410a001c310aabbdbf7ddeea058ccee121da6e4915e1084eff5c82fabc62e3a7ffe88945c45fbd72d2
7
- data.tar.gz: ab16e65c6a53358f99766428a2ff35ac46500a1cd0c0d4cbcf96177da11e89978793dc28d36b179b193b2dc37808140b8d2ea8b9d3faa156926971119dd8c202
6
+ metadata.gz: ef4ee5d46d58f791c724fbaa24402cc3db861c05b1193a4a13d60a413aae415bdab29400cbf10c4fe5ae7580be660c6e3740012ad5c9cbe0a93733674f1b2c32
7
+ data.tar.gz: 2410f02d15351de8a053741bd66c14a162d34ce4f60a910acaa13f2002cc63742716f2029ed02ff042d4aee2323123cb9fc9dff2ec1f07498fee4f9c166c634c
data/README.md CHANGED
@@ -40,6 +40,21 @@ for a missing person, account or required value. A hub refuses with `HubKernel::
40
40
  reason a person can read. A call made while the permission check or the account scope is unset
41
41
  raises `HubKernel::UnwiredPortError`.
42
42
 
43
+ The host names the hubs every interface serves, once. A hub listed alone is served at its
44
+ module name in snake case, and a hub listed as a one-pair hash is served only at the name
45
+ given. An interface gem finds the hub served at a name, or `nil` when none is:
46
+
47
+ ```ruby
48
+ HubKernel::Interface.hubs = [ Supplies, { "money" => Billing::Ledger } ]
49
+
50
+ HubKernel::Interface.find("supplies") # => Supplies
51
+ HubKernel::Interface.find("money") # => Billing::Ledger
52
+ HubKernel::Interface.served # => { "supplies" => Supplies, "money" => Billing::Ledger }
53
+ ```
54
+
55
+ The permission check is still asked about a hub served under a chosen name by its own name,
56
+ such as `ledger:record_spend`.
57
+
43
58
  `Supplies.exposure_problems` names each exposed method the hub has no method for, or lists
44
59
  with values it does not take. `HubKernel::Interface::ExposingHubs.list` holds every hub that
45
60
  declares an exposed method.
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Interface
3
- VERSION = "0.1.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -1,2 +1,14 @@
1
1
  require "hub_kernel/interface/version"
2
2
  require "hub_kernel/exposes"
3
+
4
+ module HubKernel
5
+ module Interface
6
+ singleton_class.attr_writer :hubs
7
+
8
+ def self.hubs = @hubs ||= []
9
+
10
+ def self.find(name) = served[name]
11
+
12
+ def self.served = hubs.flat_map { |entry| entry.is_a?(Hash) ? entry.to_a : [ [ entry.name.demodulize.underscore, entry ] ] }.to_h
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel-interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider