hospital 0.8.2 → 0.8.3
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/lib/hospital/version.rb +1 -1
- data/lib/hospital.rb +26 -2
- 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: bfcbe599829bcaf2c9cb197b398f44a6571d9ab67cc50ccb0b17e35c0ee7a490
|
|
4
|
+
data.tar.gz: de51adaacd2978a830f793346d27bebd563ed200dcc6e8e9739fe9d1695dae51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6573587d48ee9f18fbd9f4993db20872fcecff2b35533af8c0a70137b8038b4aceba4a486864c16114350ae089a4cc6e712eddc16fb50a8dcc0fd1ac8dfa0fc8
|
|
7
|
+
data.tar.gz: cb776fcc3cce26a735e110e180900b4d137c649402d619f90f88cfcce641c1118ef937ae5cccdacf8b27bbb80e9d8318a7a41fa42f531ec80e8c4a5ed2737d1d
|
data/lib/hospital/version.rb
CHANGED
data/lib/hospital.rb
CHANGED
|
@@ -25,10 +25,34 @@ module Hospital
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# used to call the checkup for a specific class directly (in specs)
|
|
28
|
+
# respects preconditions: runs preconditions first, skips dependents if any fail
|
|
28
29
|
def do_checkup(klass, verbose: false, ignore_condition: false)
|
|
29
|
-
@@groups.map(&:all_checkups).flatten.select{|cu| cu.klass == klass }
|
|
30
|
-
|
|
30
|
+
checkups = @@groups.map(&:all_checkups).flatten.select { |cu| cu.klass == klass }
|
|
31
|
+
by_group = checkups.group_by(&:group)
|
|
32
|
+
results = []
|
|
33
|
+
|
|
34
|
+
by_group.each do |group, group_checkups|
|
|
35
|
+
preconditions = group_checkups.select(&:precondition)
|
|
36
|
+
dependents = group_checkups.reject(&:precondition)
|
|
37
|
+
|
|
38
|
+
# run preconditions first
|
|
39
|
+
preconditions_passed = true
|
|
40
|
+
preconditions.each do |cu|
|
|
41
|
+
result = cu.check verbose: verbose, ignore_condition: ignore_condition
|
|
42
|
+
results << result if result
|
|
43
|
+
preconditions_passed = false unless cu.success?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# only run dependents if all preconditions passed
|
|
47
|
+
if preconditions_passed
|
|
48
|
+
dependents.each do |cu|
|
|
49
|
+
result = cu.check verbose: verbose, ignore_condition: ignore_condition
|
|
50
|
+
results << result if result
|
|
51
|
+
end
|
|
52
|
+
end
|
|
31
53
|
end
|
|
54
|
+
|
|
55
|
+
results
|
|
32
56
|
end
|
|
33
57
|
|
|
34
58
|
def find_or_create_checkup_group name
|