hospital 0.7.4 → 0.7.5

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: 3ab764f421c7160201af9e785c00b3e3d4169199a921a03a295f5e694f1eb13c
4
- data.tar.gz: 8aa64d6b14b30149df786c8f1c00b027a4ec1ee741d37e7fa597da02e23a1bce
3
+ metadata.gz: 119a4bfc2acfd175c027a6734fd053db355e754872e0b1ea92a1f3e4fb687519
4
+ data.tar.gz: 597eff9eea46aec5f52a4f0ed9c85a21003645040184ce6649a2e7da120dd9b2
5
5
  SHA512:
6
- metadata.gz: 63229fb186f76c3c73bce046be58ab68d0f5a3a3526189e902992ebae073fd915aa16b7e01054806db9f7bc2a3fb08a791aa4aadba1b72f55b8afa23fe3e6245
7
- data.tar.gz: ea6b28da799c06aa01b271e475449fa61e8bed3cef01f60fe9f68f8707bbaacfb15075075bf917451a47ed923723469468ff1c1dd6586f2f24fbc7f0ac32fd2f
6
+ metadata.gz: cb3001125845587feeec41413f9bdd95693f17568ed1ec4be31ab51b3db99f2038a7eb2bd82bc39f75424c34a4a1a17be52c501706ddd8c3e4a248d9b1b750dd
7
+ data.tar.gz: 73cf2b0cb3f08c18c8da77ee0f640c09a1439dd45d7505d67ab4ab00f22a7a0196c37dfc125f54464eb5d8ede77a63a79055597b18f3440753dfa234edc837ad
@@ -1,11 +1,13 @@
1
1
  module Hospital
2
2
  module Formatter
3
3
  class Base
4
- attr_reader :buffer
5
-
6
4
  def initialize
7
5
  @buffer = ""
8
6
  end
7
+
8
+ def result
9
+ @buffer
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -0,0 +1,44 @@
1
+ require_relative "base"
2
+
3
+ using StringFormatter
4
+
5
+ module Hospital
6
+ module Formatter
7
+ class Hash < Base
8
+
9
+ def initialize
10
+ @data = {}
11
+ @current_group = nil
12
+ @current_diagnosis = nil
13
+ end
14
+
15
+ def put_group_header text
16
+ @current_group = text
17
+ end
18
+
19
+ def put_diagnosis_header text
20
+ @current_diagnosis = text
21
+ end
22
+
23
+ def put_diagnosis_skipped text
24
+ end
25
+
26
+ def put_summary errors_count, warnings_count
27
+ @data['summary'] = {
28
+ 'errors' => errors_count,
29
+ 'warnings' => warnings_count
30
+ }
31
+ end
32
+
33
+ def put_diagnosis_result text
34
+ @data[@current_group] ||= {}
35
+ @data[@current_group][@current_diagnosis] ||= []
36
+ @data[@current_group][@current_diagnosis] << text
37
+ end
38
+
39
+ def result
40
+ @data
41
+ end
42
+ end
43
+ end
44
+ end
@@ -5,12 +5,16 @@ using StringFormatter
5
5
  module Hospital
6
6
  module Formatter
7
7
  class Pre < Base
8
- def put_group_header text
8
+ def put_group_headeresult
9
9
  @buffer << "\n\n### #{text}"
10
10
  end
11
11
 
12
12
  def put_diagnosis_header text
13
- @buffer << "\n\n## #{text}"
13
+ @buffer << "\n\n## Checking #{text}"
14
+ end
15
+
16
+ def put_diagnosis_skipped text
17
+ @buffer << "\n\n## Skipped #{text}"
14
18
  end
15
19
 
16
20
  def put_summary errors_count, warnings_count
@@ -10,7 +10,11 @@ module Hospital
10
10
  end
11
11
 
12
12
  def put_diagnosis_header text
13
- @buffer << "\n#{text.h2.indented}"
13
+ @buffer << "\nChecking #{text.h2.indented}"
14
+ end
15
+
16
+ def put_diagnosis_skipped text
17
+ @buffer << "\nSkipped #{text.h2.indented}"
14
18
  end
15
19
 
16
20
  def put_summary errors_count, warnings_count
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hospital
4
- VERSION = "0.7.4"
4
+ VERSION = "0.7.5"
5
5
  end
data/lib/hospital.rb CHANGED
@@ -63,8 +63,9 @@ module Hospital
63
63
  def initialize verbose: false, formatter: :shell
64
64
  @verbose = verbose
65
65
  @formatter = case formatter
66
- when :pre then Formatter::Pre
67
- else Formatter::Shell
66
+ when :pre then Formatter::Pre
67
+ when :hash then Formatter::Hash
68
+ else Formatter::Shell
68
69
  end
69
70
 
70
71
  @out = @formatter.new
@@ -85,10 +86,10 @@ module Hospital
85
86
  warcount += diagnosis.warnings.count
86
87
 
87
88
  if !checkup.skipped && (!checkup.group.skipped || checkup.precondition)
88
- @out.put_diagnosis_header "Checking #{diagnosis.name}:"
89
+ @out.put_diagnosis_header "#{diagnosis.name}:"
89
90
  diagnosis.put_results @out
90
91
  elsif verbose
91
- @out.put_diagnosis_header "Skipped #{diagnosis.name}."
92
+ @out.put_diagnosis_skipped "Skipped #{diagnosis.name}."
92
93
  end
93
94
  end
94
95
  end
@@ -96,7 +97,7 @@ module Hospital
96
97
 
97
98
  @out.put_summary errcount, warcount
98
99
 
99
- @out.buffer
100
+ @out.result
100
101
  end
101
102
  end
102
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hospital
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-12 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -39,6 +39,7 @@ files:
39
39
  - lib/hospital/checkup_group.rb
40
40
  - lib/hospital/diagnosis.rb
41
41
  - lib/hospital/formatter/base.rb
42
+ - lib/hospital/formatter/hash.rb
42
43
  - lib/hospital/formatter/pre.rb
43
44
  - lib/hospital/formatter/shell.rb
44
45
  - lib/hospital/string_formatter.rb