hospital 0.8.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48c3347cae93d82d34c613f70e56b1a5da814f04a23342f034eab160de787f3d
4
- data.tar.gz: 4898a00723b7e7142f462a63c4fa1276c16488d6bdf0f8e4c711c0178106fb9f
3
+ metadata.gz: bfcbe599829bcaf2c9cb197b398f44a6571d9ab67cc50ccb0b17e35c0ee7a490
4
+ data.tar.gz: de51adaacd2978a830f793346d27bebd563ed200dcc6e8e9739fe9d1695dae51
5
5
  SHA512:
6
- metadata.gz: 6138ab73e2808174cc12eaeb9bf9e35b6909eb5c92071c68ed2a27e34d179ea3cb8f80892832fd0d517e93ac24bba05a77ce9494e3633c64a68ad8d79dd5a72c
7
- data.tar.gz: cff7a3fec97e90b3167dd19024fd8e7e711d4326d683d4666c4c1e202d8a679b3c03a87e9edb12a2207d0c8d9b9e813209ca3e637876ae5d3352affb46fe5190
6
+ metadata.gz: 6573587d48ee9f18fbd9f4993db20872fcecff2b35533af8c0a70137b8038b4aceba4a486864c16114350ae089a4cc6e712eddc16fb50a8dcc0fd1ac8dfa0fc8
7
+ data.tar.gz: cb776fcc3cce26a735e110e180900b4d137c649402d619f90f88cfcce641c1118ef937ae5cccdacf8b27bbb80e9d8318a7a41fa42f531ec80e8c4a5ed2737d1d
@@ -17,12 +17,13 @@ module Hospital
17
17
  @buffer << "\n\n## Skipped #{text}"
18
18
  end
19
19
 
20
- def put_summary errors_count, warnings_count
20
+ def put_summary errors_count, warnings_count, infos_count
21
21
  @buffer << <<~END
22
22
  \n\n
23
23
  #### Summary:
24
24
  Errors: #{errors_count}
25
25
  Warnings: #{warnings_count}
26
+ Infos: #{infos_count}
26
27
  END
27
28
  end
28
29
 
@@ -23,10 +23,11 @@ module Hospital
23
23
  def put_diagnosis_skipped text
24
24
  end
25
25
 
26
- def put_summary errors_count, warnings_count
26
+ def put_summary errors_count, warnings_count, infos_count
27
27
  @data['summary'] = {
28
- 'errors' => errors_count,
29
- 'warnings' => warnings_count
28
+ 'errors' => errors_count,
29
+ 'warnings' => warnings_count,
30
+ 'infos' => infos_count
30
31
  }
31
32
  end
32
33
 
@@ -17,12 +17,13 @@ module Hospital
17
17
  @buffer << "\nSkipped #{text.h2.indented}"
18
18
  end
19
19
 
20
- def put_summary errors_count, warnings_count
20
+ def put_summary errors_count, warnings_count, infos_count
21
21
  @buffer << <<~END
22
22
 
23
23
  #{"Summary:".h1}
24
24
  #{"Errors: #{errors_count}".red}
25
25
  #{"Warnings: #{warnings_count}".yellow}
26
+ #{"Infos: #{infos_count}".green}
26
27
  END
27
28
  end
28
29
 
@@ -24,6 +24,10 @@ module StringFormatter
24
24
  "\e[33m#{self}\e[0m"
25
25
  end
26
26
 
27
+ def green
28
+ "\e[32m#{self}\e[0m"
29
+ end
30
+
27
31
  def indented
28
32
  "#{self}"
29
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hospital
4
- VERSION = "0.8.1"
4
+ VERSION = "0.8.3"
5
5
  end
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 }.map do |cu|
30
- cu.check verbose: verbose, ignore_condition: ignore_condition
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
@@ -76,6 +100,7 @@ module Hospital
76
100
  def do_checkup_all
77
101
  errcount = 0
78
102
  warcount = 0
103
+ infocount = 0
79
104
 
80
105
  Hospital.groups.each do |group|
81
106
  @out.put_group_header group.header
@@ -83,8 +108,9 @@ module Hospital
83
108
 
84
109
  group.all_checkups.each do |checkup|
85
110
  if diagnosis = checkup.diagnosis
86
- errcount += diagnosis.errors.count
87
- warcount += diagnosis.warnings.count
111
+ errcount += diagnosis.errors.count
112
+ warcount += diagnosis.warnings.count
113
+ infocount += diagnosis.infos.count
88
114
 
89
115
  if !checkup.skipped && (!checkup.group.skipped || checkup.precondition)
90
116
  @out.put_diagnosis_header "#{diagnosis.name}:"
@@ -96,7 +122,7 @@ module Hospital
96
122
  end
97
123
  end
98
124
 
99
- @out.put_summary errcount, warcount
125
+ @out.put_summary errcount, warcount, infocount
100
126
 
101
127
  @out.result
102
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hospital
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander