hub_kernel-interface 0.1.0 → 0.2.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: fcf68ba40018916adda2764b12c9b576a9650aa5c3c954fae85e0e59c63a6d32
4
+ data.tar.gz: 531acede6b1476e7847f2ede96bafb3cfb2685cb2c30c5fe816f71250f739951
5
5
  SHA512:
6
- metadata.gz: ccdc332bfa7357d30249401bbef0e7fca543840bb3a580410a001c310aabbdbf7ddeea058ccee121da6e4915e1084eff5c82fabc62e3a7ffe88945c45fbd72d2
7
- data.tar.gz: ab16e65c6a53358f99766428a2ff35ac46500a1cd0c0d4cbcf96177da11e89978793dc28d36b179b193b2dc37808140b8d2ea8b9d3faa156926971119dd8c202
6
+ metadata.gz: f9d0f6e042f40f9aece6780b756505ae52047dabe7d64a1e54c893f9508c861a4763d1babfb8dfa766ccb60f39ef6d5e2606b1d0b8114243fbc62f7fdbc1aca4
7
+ data.tar.gz: 6d41d5ddbbfa3ce0e315e22604ac85a8312b95ee0cdb19f7bf5b9c60a9a47791f996b74e0dc06b0dc4a6b8a940131f5222cfb343e1722fe4df915edccc1e8d77
data/README.md CHANGED
@@ -40,6 +40,20 @@ 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
+ ```
53
+
54
+ The permission check is still asked about a hub served under a chosen name by its own name,
55
+ such as `ledger:record_spend`.
56
+
43
57
  `Supplies.exposure_problems` names each exposed method the hub has no method for, or lists
44
58
  with values it does not take. `HubKernel::Interface::ExposingHubs.list` holds every hub that
45
59
  declares an exposed method.
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Interface
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,2 +1,15 @@
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.to_h[name]
11
+
12
+ def self.served = hubs.flat_map { |entry| entry.is_a?(Hash) ? entry.to_a : [ [ entry.name.demodulize.underscore, entry ] ] }
13
+ private_class_method :served
14
+ end
15
+ 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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider