epb_view_models 2.1.0 → 2.1.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: b9db4fa85bbd8a3e3ce9d382956d73d0ede454349669d8c417eceaa17ef3364b
4
- data.tar.gz: 35e87c714233925e22d192ff0d3d1f2c261f73bd74a7031fa411a9a9133e5ce0
3
+ metadata.gz: 78f74ec906136a35d182c42870bf5475d182908f774c2d67ab7318537a12723c
4
+ data.tar.gz: 93c2585995cfaaf1c2be9b4b51e326ac3513db18677ce913d87a163018b0b9f8
5
5
  SHA512:
6
- metadata.gz: d1a89d38cc64b145833d0e337c7fb103138010b095b2317804a74253e304a79c35b1585cd7888622defd4f1b822bd136f4190f9cf4973a3979bfafc3a6cc7c5b
7
- data.tar.gz: 75accbc9e3befa7cf462de14330cee27993017e0888b5b817045d6e527651a826a8cf4812f11599596ca59c81f208718a699a48a7e8820e1caa65ddb90ce1d67
6
+ metadata.gz: 6c911cc83d2eb27753c56b83518f7b206ecf5e586f28050246c6f03fbe9e02f0c848acd37a19297c27a9c7af7f41fb26012a7a07f88105df55f15af8b46ffcf4
7
+ data.tar.gz: d38db75247ef3b7def54f418a9275204bebc37ad218ec79194a6e820511996de82332654ee927e09cf1167de9ea31f3fd39e6765f6a4ea17d2f621444b02b934
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (8.0.1)
4
+ activesupport (8.0.2)
5
5
  base64
6
6
  benchmark (>= 0.3)
7
7
  bigdecimal
@@ -14,75 +14,85 @@ GEM
14
14
  securerandom (>= 0.3)
15
15
  tzinfo (~> 2.0, >= 2.0.5)
16
16
  uri (>= 0.13.1)
17
- ast (2.4.2)
18
- base64 (0.2.0)
19
- benchmark (0.4.0)
20
- bigdecimal (3.1.9)
17
+ ast (2.4.3)
18
+ base64 (0.3.0)
19
+ benchmark (0.4.1)
20
+ bigdecimal (3.2.2)
21
21
  concurrent-ruby (1.3.5)
22
- connection_pool (2.5.0)
23
- diff-lcs (1.5.1)
24
- drb (2.2.1)
22
+ connection_pool (2.5.3)
23
+ diff-lcs (1.6.2)
24
+ drb (2.2.3)
25
25
  i18n (1.14.7)
26
26
  concurrent-ruby (~> 1.0)
27
- json (2.10.0)
28
- language_server-protocol (3.17.0.4)
29
- logger (1.6.5)
30
- minitest (5.25.4)
31
- nokogiri (1.18.8-arm64-darwin)
27
+ json (2.12.2)
28
+ language_server-protocol (3.17.0.5)
29
+ lint_roller (1.1.0)
30
+ logger (1.7.0)
31
+ mini_portile2 (2.8.9)
32
+ minitest (5.25.5)
33
+ nokogiri (1.18.8)
34
+ mini_portile2 (~> 2.8.2)
32
35
  racc (~> 1.4)
33
- parallel (1.26.3)
34
- parser (3.3.7.1)
36
+ parallel (1.27.0)
37
+ parser (3.3.8.0)
35
38
  ast (~> 2.4.1)
36
39
  racc
37
- racc (1.7.3)
38
- rack (3.1.9)
40
+ prism (1.4.0)
41
+ racc (1.8.1)
42
+ rack (3.1.16)
39
43
  rainbow (3.1.1)
40
44
  rake (13.0.6)
41
45
  regexp_parser (2.10.0)
42
- rexml (3.4.0)
43
- rspec (3.13.0)
46
+ rexml (3.4.1)
47
+ rspec (3.13.1)
44
48
  rspec-core (~> 3.13.0)
45
49
  rspec-expectations (~> 3.13.0)
46
50
  rspec-mocks (~> 3.13.0)
47
- rspec-core (3.13.0)
51
+ rspec-core (3.13.4)
48
52
  rspec-support (~> 3.13.0)
49
- rspec-expectations (3.13.0)
53
+ rspec-expectations (3.13.5)
50
54
  diff-lcs (>= 1.2.0, < 2.0)
51
55
  rspec-support (~> 3.13.0)
52
- rspec-mocks (3.13.0)
56
+ rspec-mocks (3.13.5)
53
57
  diff-lcs (>= 1.2.0, < 2.0)
54
58
  rspec-support (~> 3.13.0)
55
- rspec-support (3.13.1)
56
- rubocop (1.70.0)
59
+ rspec-support (3.13.4)
60
+ rubocop (1.76.2)
57
61
  json (~> 2.3)
58
- language_server-protocol (>= 3.17.0)
62
+ language_server-protocol (~> 3.17.0.2)
63
+ lint_roller (~> 1.1.0)
59
64
  parallel (~> 1.10)
60
65
  parser (>= 3.3.0.2)
61
66
  rainbow (>= 2.2.2, < 4.0)
62
67
  regexp_parser (>= 2.9.3, < 3.0)
63
- rubocop-ast (>= 1.36.2, < 2.0)
68
+ rubocop-ast (>= 1.45.1, < 2.0)
64
69
  ruby-progressbar (~> 1.7)
65
70
  unicode-display_width (>= 2.4.0, < 4.0)
66
- rubocop-ast (1.37.0)
67
- parser (>= 3.3.1.0)
68
- rubocop-capybara (2.21.0)
69
- rubocop (~> 1.41)
70
- rubocop-govuk (5.0.8)
71
- rubocop (= 1.70.0)
72
- rubocop-ast (= 1.37.0)
73
- rubocop-capybara (= 2.21.0)
74
- rubocop-rails (= 2.28.0)
75
- rubocop-rake (= 0.6.0)
76
- rubocop-rspec (= 3.3.0)
77
- rubocop-rails (2.28.0)
71
+ rubocop-ast (1.45.1)
72
+ parser (>= 3.3.7.2)
73
+ prism (~> 1.4)
74
+ rubocop-capybara (2.22.1)
75
+ lint_roller (~> 1.1)
76
+ rubocop (~> 1.72, >= 1.72.1)
77
+ rubocop-govuk (5.1.15)
78
+ rubocop (= 1.76.2)
79
+ rubocop-ast (= 1.45.1)
80
+ rubocop-capybara (= 2.22.1)
81
+ rubocop-rails (= 2.32.0)
82
+ rubocop-rake (= 0.7.1)
83
+ rubocop-rspec (= 3.6.0)
84
+ rubocop-rails (2.32.0)
78
85
  activesupport (>= 4.2.0)
86
+ lint_roller (~> 1.1)
79
87
  rack (>= 1.1)
80
- rubocop (>= 1.52.0, < 2.0)
81
- rubocop-ast (>= 1.31.1, < 2.0)
82
- rubocop-rake (0.6.0)
83
- rubocop (~> 1.0)
84
- rubocop-rspec (3.3.0)
85
- rubocop (~> 1.61)
88
+ rubocop (>= 1.75.0, < 2.0)
89
+ rubocop-ast (>= 1.44.0, < 2.0)
90
+ rubocop-rake (0.7.1)
91
+ lint_roller (~> 1.1)
92
+ rubocop (>= 1.72.1)
93
+ rubocop-rspec (3.6.0)
94
+ lint_roller (~> 1.1)
95
+ rubocop (~> 1.72, >= 1.72.1)
86
96
  ruby-progressbar (1.13.0)
87
97
  securerandom (0.4.1)
88
98
  tzinfo (2.0.6)
@@ -90,8 +100,8 @@ GEM
90
100
  unicode-display_width (3.1.4)
91
101
  unicode-emoji (~> 4.0, >= 4.0.4)
92
102
  unicode-emoji (4.0.4)
93
- uri (1.0.2)
94
- zeitwerk (2.6.13)
103
+ uri (1.0.3)
104
+ zeitwerk (2.7.3)
95
105
 
96
106
  PLATFORMS
97
107
  ruby
@@ -5,15 +5,15 @@ loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "2.1.0"
8
+ VERSION = "2.1.3"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
12
12
  # Source: http://jeffgardner.org/2011/08/04/rails-string-to-boolean-method/
13
13
  class String
14
14
  def to_bool
15
- return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
16
- return false if self == false || blank? || self =~ (/(false|f|no|n|0)$/i)
15
+ return true if self == true || self =~ /(true|t|yes|y|1)$/i
16
+ return false if self == false || blank? || self =~ /(false|f|no|n|0)$/i
17
17
 
18
18
  raise ArgumentError, "invalid value for Boolean: \"#{self}\""
19
19
  end
@@ -104,7 +104,7 @@ module Helper
104
104
  xpath(%w[ACI-Cooling-Plant-Refrigeration/Refrigerant-Name], node),
105
105
  f_gas_inspection:
106
106
  checklist_values_with_guidance(node.at("ACI-Cooling-Plant-Refrigeration"))[
107
- :f_gas_inspection
107
+ :f_gas_inspection,
108
108
  ],
109
109
  pre_compressor:
110
110
  xpath(%w[ACI-Cooling-Plant-Refrigeration/Pre-Compressor], node),
@@ -118,11 +118,11 @@ module Helper
118
118
  ),
119
119
  compressor_control:
120
120
  checklist_values(node.at("ACI-Cooling-Plant-Refrigeration"), skip_state: true)[
121
- :compressor_control
121
+ :compressor_control,
122
122
  ],
123
123
  refrigerant_leak:
124
124
  checklist_values(node.at("ACI-Cooling-Plant-Refrigeration"))[
125
- :refrigerant_leak
125
+ :refrigerant_leak,
126
126
  ],
127
127
  guidance:
128
128
  guidance(node.at("ACI-Cooling-Plant-Refrigeration/Guidance")),
@@ -130,11 +130,11 @@ module Helper
130
130
  maintenance: {
131
131
  records_kept:
132
132
  checklist_values(node.at("ACI-Cooling-Plant-Maintenance"))[
133
- :records_kept
133
+ :records_kept,
134
134
  ],
135
135
  competent_person:
136
136
  checklist_values(node.at("ACI-Cooling-Plant-Maintenance"))[
137
- :competent_person
137
+ :competent_person,
138
138
  ],
139
139
  guidance: guidance(node.at("ACI-Cooling-Plant-Maintenance/Guidance")),
140
140
  },
@@ -146,7 +146,7 @@ module Helper
146
146
  },
147
147
  humidity_control:
148
148
  checklist_values(node.at("ACI-Cooling-Plant-Humidity-Control"))[
149
- :humidity_control
149
+ :humidity_control,
150
150
  ],
151
151
  chillers:
152
152
  if xpath(%w[ACI-Cooling-Plant-Chillers], node).nil?
@@ -153,7 +153,7 @@ module Presenter
153
153
  end
154
154
 
155
155
  def is_bool?(string)
156
- string == true || string == false || string =~ (/(true|false)$/i) ? true : false
156
+ string == true || string == false || string =~ /(true|false)$/i ? true : false
157
157
  end
158
158
 
159
159
  def try_as_number(string)
@@ -398,13 +398,17 @@ module ViewModel
398
398
  end
399
399
 
400
400
  def low_energy_lighting
401
- (low_energy_fixed_lighting_outlets_count / fixed_lighting_outlets_count) * 100
401
+ if fixed_lighting_outlets_count.zero?
402
+ return 0
403
+ end
404
+
405
+ ((low_energy_fixed_lighting_outlets_count.to_f / fixed_lighting_outlets_count) * 100).round
402
406
  end
403
407
 
404
408
  def fixed_lighting_outlets_count
405
409
  fixed_lighting_outlets_count = low_energy_fixed_lighting_outlets_count
406
- if xpath(%w[Incandescent-Lighting-Bulbs-Count])
407
- fixed_lighting_outlets_count += xpath(%w[Incandescent-Lighting-Bulbs-Count])&.to_i
410
+ if xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])
411
+ fixed_lighting_outlets_count += xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])&.to_i
408
412
  end
409
413
  fixed_lighting_outlets_count
410
414
  end
@@ -125,8 +125,8 @@ module ViewModel
125
125
  {
126
126
  sequence: xpath(%w[Sequence], node).to_i,
127
127
  improvement_code: xpath(%w[Improvement-Details Improvement-Number], node),
128
- improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
- improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.0", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
128
+ improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.1", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
+ improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.1", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
130
130
  indicative_cost: xpath(%w[Indicative-Cost], node),
131
131
  }
132
132
  end
@@ -398,13 +398,17 @@ module ViewModel
398
398
  end
399
399
 
400
400
  def low_energy_lighting
401
- (low_energy_fixed_lighting_outlets_count / fixed_lighting_outlets_count) * 100
401
+ if fixed_lighting_outlets_count.zero?
402
+ return 0
403
+ end
404
+
405
+ ((low_energy_fixed_lighting_outlets_count.to_f / fixed_lighting_outlets_count) * 100).round
402
406
  end
403
407
 
404
408
  def fixed_lighting_outlets_count
405
409
  fixed_lighting_outlets_count = low_energy_fixed_lighting_outlets_count
406
- if xpath(%w[Incandescent-Lighting-Bulbs-Count])
407
- fixed_lighting_outlets_count += xpath(%w[Incandescent-Lighting-Bulbs-Count])&.to_i
410
+ if xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])
411
+ fixed_lighting_outlets_count += xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])&.to_i
408
412
  end
409
413
  fixed_lighting_outlets_count
410
414
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MHCLG Energy Performance of Buildings
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-07-07 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: nokogiri
@@ -37,6 +38,7 @@ dependencies:
37
38
  - - "~>"
38
39
  - !ruby/object:Gem::Version
39
40
  version: '2.6'
41
+ description:
40
42
  email:
41
43
  - mhclg.digital-services@levellingup.gov.uk
42
44
  executables: []
@@ -1948,6 +1950,7 @@ homepage: https://github.com/communitiesuk/epb-view-models
1948
1950
  licenses:
1949
1951
  - MIT
1950
1952
  metadata: {}
1953
+ post_install_message:
1951
1954
  rdoc_options: []
1952
1955
  require_paths:
1953
1956
  - lib
@@ -1962,7 +1965,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1962
1965
  - !ruby/object:Gem::Version
1963
1966
  version: '0'
1964
1967
  requirements: []
1965
- rubygems_version: 3.6.9
1968
+ rubygems_version: 3.5.11
1969
+ signing_key:
1966
1970
  specification_version: 4
1967
1971
  summary: Library used to parse Energy Performance Certificates (EPC)
1968
1972
  test_files: []