hub_kernel 0.11.0 → 0.12.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 +3 -0
- data/lib/hub_kernel/conformance/crossings.rb +14 -3
- data/lib/hub_kernel/crossings.rb +9 -1
- 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: 229fcc87e3137795f02b73e3f0be126e9809181b14446e09e8a1a050fa83420e
|
|
4
|
+
data.tar.gz: 2347fa14b7911dda34f7e1cbebb924eb10f99f8da0e5e086f112f78aa79440b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e432500a7d6b4dc4c0e7a4061d74dfc81108435a640d4098afaa0a9ca58518790b75d94ba5e5d49e28c87e88925a1b6369f36968cc5b9fafb31480034730ecde
|
|
7
|
+
data.tar.gz: fbf852ad51486ad330f5b7b0cefa7f36d599c7c713a0a95e2cffcbd689e41ea0042550a00e24c66a19778507e32ff992001aa90828ea10f6c8ed2d4f6d74f644
|
data/README.md
CHANGED
|
@@ -196,6 +196,9 @@ end
|
|
|
196
196
|
- The test fails with "The crossing check found no files to read" when none of the files
|
|
197
197
|
it read belongs to a hub or the host's layer, so a wrong `files:` pattern or an empty
|
|
198
198
|
map does not pass unnoticed.
|
|
199
|
+
- It also fails naming each class defined in the files it reads that no hub owns, such as
|
|
200
|
+
"No hub owns Shop::Refund", and each class the map gives to two hubs, such as "Two hubs
|
|
201
|
+
own Shop::Receipt".
|
|
199
202
|
|
|
200
203
|
## Installation
|
|
201
204
|
Add this line to your application's Gemfile:
|
|
@@ -17,15 +17,26 @@ module HubKernel
|
|
|
17
17
|
|
|
18
18
|
included do
|
|
19
19
|
test "no file names a class another hub owns" do
|
|
20
|
-
|
|
21
|
-
flunk "The crossing check found no files to read" if paths.none? { |path| the_crossings.belongs?(path) }
|
|
20
|
+
flunk "The crossing check found no files to read" if crossing_paths.none? { |path| the_crossings.belongs?(path) }
|
|
22
21
|
|
|
23
|
-
found =
|
|
22
|
+
found = crossing_paths.flat_map do |path|
|
|
24
23
|
the_crossings.in(path, File.read(File.join(crossing_root, path))).map { |name| "#{path} names #{name}" }
|
|
25
24
|
end
|
|
26
25
|
assert found.empty?, found.join("\n")
|
|
27
26
|
end
|
|
27
|
+
|
|
28
|
+
test "every class it reads belongs to a hub" do
|
|
29
|
+
unowned = the_crossings.unowned_classes(crossing_paths)
|
|
30
|
+
assert unowned.empty?, unowned.map { |name| "No hub owns #{name}" }.join("\n")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "no class belongs to two hubs" do
|
|
34
|
+
twice = the_crossings.claimed_twice
|
|
35
|
+
assert twice.empty?, twice.map { |name| "Two hubs own #{name}" }.join("\n")
|
|
36
|
+
end
|
|
28
37
|
end
|
|
38
|
+
|
|
39
|
+
def crossing_paths = (Dir.glob(crossing_files, base: crossing_root) - crossing_exceptions).sort
|
|
29
40
|
end
|
|
30
41
|
end
|
|
31
42
|
end
|
data/lib/hub_kernel/crossings.rb
CHANGED
|
@@ -16,8 +16,16 @@ module HubKernel
|
|
|
16
16
|
|
|
17
17
|
def belongs?(path) = !owner_of_file(path).nil?
|
|
18
18
|
|
|
19
|
+
def unowned_classes(paths)
|
|
20
|
+
paths.select { |path| path.end_with?(".rb") && !path.start_with?("app/views/") }.map { |path| class_of(path) }.reject { |name| owner_of(name) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def claimed_twice = @owners.values.flatten.tally.select { |_name, hubs| hubs > 1 }.keys
|
|
24
|
+
|
|
19
25
|
private
|
|
20
26
|
|
|
27
|
+
def class_of(path) = path.sub(%r{\Aapp/[^/]+/}, "").delete_suffix(".rb").camelize
|
|
28
|
+
|
|
21
29
|
def crossing?(name, hub)
|
|
22
30
|
return false if @shared.include?(name) || owner_of(name) == hub
|
|
23
31
|
|
|
@@ -34,7 +42,7 @@ module HubKernel
|
|
|
34
42
|
def owner_of_file(path)
|
|
35
43
|
return owner_of_view_folder(File.dirname(path.delete_prefix("app/views/")).camelize) if path.start_with?("app/views/")
|
|
36
44
|
|
|
37
|
-
owner_of(path
|
|
45
|
+
owner_of(class_of(path))
|
|
38
46
|
end
|
|
39
47
|
|
|
40
48
|
def owner_of_view_folder(folder) = owner_of("#{folder}Controller") || owner_of(folder) || @host_layer
|
data/lib/hub_kernel/version.rb
CHANGED