hub_kernel 0.4.0 → 0.5.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 +17 -0
- data/lib/hub_kernel/conformance/hub.rb +22 -0
- data/lib/hub_kernel/ports.rb +5 -0
- data/lib/hub_kernel/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8117d21e5e81d6489c16ee5315f636623eafbab7aa0bc9ebe3e25b66fd139cef
|
|
4
|
+
data.tar.gz: 82f9add4dde24ed15db4be6b649f39b9e9c047292760479b8da9fc8891d72ff5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bc2bfa185995e9773224c2d5570e7f7c9d7ed520409524289a40da34132331dfc03546d4c74036f03bad13dfe5d586a9fceac389e00cef0d0ba6456eca0396d
|
|
7
|
+
data.tar.gz: 7f6465796e50d486e907c0d0d682ca97c1fb69dd0a264ba44d54bb99e133cc78d062b316b4771912d68ca41b7696ad87b78984997ca93acec24392a2ff27aa80
|
data/README.md
CHANGED
|
@@ -44,6 +44,23 @@ It raises `HubKernel::UnwiredPortError` naming every unfilled port with its hub,
|
|
|
44
44
|
line. Running it inside `to_prepare` checks again after every code reload, and a hub
|
|
45
45
|
declared again on a reload stays on the list once.
|
|
46
46
|
|
|
47
|
+
### The hub check
|
|
48
|
+
A hub's own test can check that the app filled every one of its ports, so a missing
|
|
49
|
+
fill shows in the suite rather than on the next start:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
require "hub_kernel/conformance/hub"
|
|
53
|
+
|
|
54
|
+
class SuppliesHubTest < ActiveSupport::TestCase
|
|
55
|
+
include HubKernel::Conformance::Hub
|
|
56
|
+
|
|
57
|
+
hub { Supplies }
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The test fails and names each port the app left unfilled, and each port filled with
|
|
62
|
+
something that cannot be called.
|
|
63
|
+
|
|
47
64
|
## Installation
|
|
48
65
|
Add this line to your application's Gemfile:
|
|
49
66
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "active_support/concern"
|
|
2
|
+
|
|
3
|
+
module HubKernel
|
|
4
|
+
module Conformance
|
|
5
|
+
module Hub
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
class_methods do
|
|
9
|
+
def hub(&block)
|
|
10
|
+
define_method(:the_hub, &block)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
included do
|
|
15
|
+
test "every port of the hub is filled with something that can be called" do
|
|
16
|
+
problems = the_hub.unwired_ports + the_hub.uncallable_ports
|
|
17
|
+
flunk problems.join("\n") if problems.any?
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/hub_kernel/ports.rb
CHANGED
|
@@ -17,6 +17,11 @@ module HubKernel
|
|
|
17
17
|
declared_ports.reject { |name| instance_variable_get(:"@#{name}") }.map { |name| unwired_message(name) }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def uncallable_ports
|
|
21
|
+
declared_ports.select { |name| instance_variable_get(:"@#{name}")&.respond_to?(:call) == false }
|
|
22
|
+
.map { |name| "#{hub_name} #{name.to_s.tr("_", " ")} is filled with something that cannot be called" }
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
private
|
|
21
26
|
|
|
22
27
|
def declared_ports = @declared_ports ||= []
|
data/lib/hub_kernel/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -41,6 +41,7 @@ files:
|
|
|
41
41
|
- lib/hub_kernel/answer.rb
|
|
42
42
|
- lib/hub_kernel/authz.rb
|
|
43
43
|
- lib/hub_kernel/conformance/action.rb
|
|
44
|
+
- lib/hub_kernel/conformance/hub.rb
|
|
44
45
|
- lib/hub_kernel/conformance/partial.rb
|
|
45
46
|
- lib/hub_kernel/context.rb
|
|
46
47
|
- lib/hub_kernel/engine.rb
|