hub_kernel 0.22.0 → 0.23.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: fa846ab97d20c75f7e3dd54468262589d42a134aa487f54e4a54216861d73a2f
4
- data.tar.gz: 2e85a76639b5cb385446786265d99f73be3fac6a701da33e038f49e8ae85b8df
3
+ metadata.gz: 62d50b8fc5eef4ade3f013299536de0776ffe8bf0635aa5ffb80ea8518f971aa
4
+ data.tar.gz: 955b417a4a57bb859e7991ae6832b4f1c70233d56a30abae5771a729e5b79c05
5
5
  SHA512:
6
- metadata.gz: 710c5a3a33ccbba307e5c2cc2327a329de79055dc6f8519f062b33cb3c15d154a458081461e7a72be2ab668bea993baee8804d8730f7b2771cd536e6c5207c54
7
- data.tar.gz: 9db5be35d6a50094db6bf76811830b21308fcce941c86caaa4d6bc72adc36583441633a985f07cbea95a00ec895d0f84fdfc71266c1f210bd66b3400ade814d6
6
+ metadata.gz: b2707daa5d057cc5fce381bb225af606a62f429651a276d2b6b84d953b0df357b8a51cc9fa142be89c3f1fa79b7e9edd7ac7a0a6d8028248294db0c9478c32fa
7
+ data.tar.gz: f2f06d8c9e8cd8c21eb01950e8461fc5eed0474069c595b3b6d7a790f6fea1e9164d8040bf88352623f82e6a7955acfdfb27ace413ddd738d3f94f3b105b1b0e
@@ -1,5 +1,7 @@
1
1
  module HubKernel
2
2
  module HubFolders
3
+ class SharedController < StandardError; end
4
+
3
5
  ROOT = "hubs".freeze
4
6
  CODE = "app".freeze
5
7
 
@@ -21,5 +23,13 @@ module HubKernel
21
23
  def self.view_paths(root) = Dir[root.join("#{code_glob}/views")]
22
24
 
23
25
  def self.helper_paths(root) = Dir[root.join("#{code_glob}/helpers")]
26
+
27
+ def self.hub_of_controller(root, page)
28
+ controllers = Dir[root.join(code_glob, "controllers", "#{page}_controller.rb").to_s].sort
29
+ hubs = controllers.map { |controller| hub_of(Pathname(controller).relative_path_from(root).to_s) }
30
+ raise SharedController, "#{page}_controller.rb is in more than one hub folder: #{hubs.map { |hub| folder(hub) }.join(", ")}" if hubs.many?
31
+
32
+ hubs.first
33
+ end
24
34
  end
25
35
  end
@@ -0,0 +1,24 @@
1
+ require "active_support/concern"
2
+
3
+ module HubKernel
4
+ module KeptPorts
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def keep_ports(&block)
9
+ define_method(:hubs_with_kept_ports) { Array(instance_exec(&block)) }
10
+ end
11
+ end
12
+
13
+ included do
14
+ setup { @kept_ports = hubs_with_kept_ports.to_h { |hub| [ hub, fillings_of(hub) ] } }
15
+ teardown { @kept_ports.each { |hub, fillings| fillings.each { |port, filling| hub.public_send(:"#{port}=", filling) } } }
16
+ end
17
+
18
+ private
19
+
20
+ def hubs_with_kept_ports = [ the_hub ]
21
+
22
+ def fillings_of(hub) = hub.port_names.to_h { |port| [ port, hub.instance_variable_get(:"@#{port}") ] }
23
+ end
24
+ end
@@ -13,6 +13,8 @@ module HubKernel
13
13
  define_singleton_method(as) { |*args, **options| public_send(name).call(*args, **options) }
14
14
  end
15
15
 
16
+ def port_names = declared_ports.dup
17
+
16
18
  def unwired_ports
17
19
  declared_ports.reject { |name| instance_variable_get(:"@#{name}") }.map { |name| unwired_message(name) }
18
20
  end
@@ -1,3 +1,3 @@
1
1
  module HubKernel
2
- VERSION = "0.22.0"
2
+ VERSION = "0.23.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -64,6 +64,7 @@ files:
64
64
  - lib/hub_kernel/follow_up.rb
65
65
  - lib/hub_kernel/hub_folders.rb
66
66
  - lib/hub_kernel/hubs.rb
67
+ - lib/hub_kernel/kept_ports.rb
67
68
  - lib/hub_kernel/markup.rb
68
69
  - lib/hub_kernel/ports.rb
69
70
  - lib/hub_kernel/records.rb