epb_view_models 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6921bcda99893c67e6092002a2e3f9f2d7626167fa2daf9de023648b5ad5e95
4
- data.tar.gz: 3dc7ea49e4fe1269e5b2ab9811e058cfba1d0b603490e17684680de3a048ec54
3
+ metadata.gz: b71b827370438edcfacfdd4d8d44e8272526fde8cbd7e58bc77df2d60b5ef1a7
4
+ data.tar.gz: 374238b4324acea447bcce054ed895960b3c9c684e8efc0e229a418077eb64c2
5
5
  SHA512:
6
- metadata.gz: fe5118b48a7c6945c38c120cf7f65a2d3efa082a95394017eb879a20489f1ad08e34acebf11719e8b8c37ff732d010fa53dfb0089f3f57abf163177b1a33adbc
7
- data.tar.gz: a191bcdb868c250255c1134c7a606de01e5c4f85e9b49987364f7cd0e2c854f6e69e96fbdd56e67fcf68d015b783e765ad04855a74186da4d4831661c8e767fd
6
+ metadata.gz: e34f118818e142c9d9a9e38628f8f56eb9e02373a41571b632e842674370e84ed36d7bc3fff85e6687af6c06dd61579056050a2f1d34bbb793f21fc125d869ee
7
+ data.tar.gz: 2b023ad18d63ea973dba32b6849307045372101debda793711a27bca16ebd7bef2459e9c426c1e7e544bdb9835663d07f1905015caca35b90b4ffea3e46953e4
data/Makefile CHANGED
@@ -4,7 +4,7 @@ SHELL := /bin/bash
4
4
  .PHONY: help install test format
5
5
 
6
6
  help: ## Print help documentation
7
- @echo -e "Makefile Help for epb-auth-tools"
7
+ @echo -e "Makefile Help for epb-view-models"
8
8
  @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
9
9
 
10
10
  install: ## Install required libraries and setup
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "1.0.1"
8
+ VERSION = "1.0.2"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -12,43 +12,41 @@ module Helper
12
12
  end
13
13
 
14
14
  def checklist_values(checklist, skip_state: false)
15
- results =
16
- checklist&.element_children&.map { |node|
17
- next if xpath(%w[Flag], node).nil? && !skip_state
15
+ return {} if checklist.nil? || checklist.element_children.nil?
18
16
 
19
- checklist_item = node.name.underscore.to_sym
20
- if skip_state
21
- { checklist_item => { note: xpath(%w[Note], node) } }
22
- else
23
- {
24
- checklist_item => {
25
- state: xpath(%w[Flag], node) == "Yes",
26
- note: xpath(%w[Note], node),
27
- },
28
- }
29
- end
30
- }&.compact.inject(&:merge)
31
-
32
- results.nil? ? {} : results
33
- end
34
-
35
- def checklist_values_with_guidance(checklist)
36
- results =
37
- checklist&.element_children&.map { |node|
38
- next if xpath(%w[Flag], node).nil?
39
-
40
- checklist_item = node.name.underscore.to_sym
17
+ checklist.element_children.map { |node|
18
+ next if xpath(%w[Flag], node).nil? && !skip_state
41
19
 
20
+ checklist_item = node.name.underscore.to_sym
21
+ if skip_state
22
+ { checklist_item => { note: xpath(%w[Note], node) } }
23
+ else
42
24
  {
43
25
  checklist_item => {
44
26
  state: xpath(%w[Flag], node) == "Yes",
45
27
  note: xpath(%w[Note], node),
46
- guidance: xpath(%w[Text], node),
47
28
  },
48
29
  }
49
- }&.compact.inject(&:merge)
30
+ end
31
+ }.compact.inject(&:merge)
32
+ end
33
+
34
+ def checklist_values_with_guidance(checklist)
35
+ return {} if checklist.nil? || checklist.element_children.nil?
36
+
37
+ checklist.element_children.map { |node|
38
+ next if xpath(%w[Flag], node).nil?
50
39
 
51
- results.nil? ? {} : results
40
+ checklist_item = node.name.underscore.to_sym
41
+
42
+ {
43
+ checklist_item => {
44
+ state: xpath(%w[Flag], node) == "Yes",
45
+ note: xpath(%w[Note], node),
46
+ guidance: xpath(%w[Text], node),
47
+ },
48
+ }
49
+ }.compact.inject(&:merge)
52
50
  end
53
51
 
54
52
  def guidance(guidance_elements)
@@ -57,10 +57,6 @@ module ViewModel
57
57
  xpath(%w[Other-Fuel-Description])
58
58
  end
59
59
 
60
- def primary_energy_use
61
- xpath(%w[Energy-Consumption-Current])
62
- end
63
-
64
60
  def primary_energy_use
65
61
  nil
66
62
  end
@@ -53,10 +53,6 @@ module ViewModel
53
53
  xpath(%w[New-Build-Benchmark])
54
54
  end
55
55
 
56
- def other_fuel_description
57
- nil
58
- end
59
-
60
56
  def other_fuel_description
61
57
  xpath(%w[Other-Fuel-Description])
62
58
  end
@@ -81,10 +81,6 @@ module ViewModel
81
81
  xpath(%w[Technical-Information Main-Heating-Fuel])
82
82
  end
83
83
 
84
- def special_energy_uses
85
- xpath(%w[Technical-Information Special-Energy-Uses])
86
- end
87
-
88
84
  def occupancy_level
89
85
  xpath(%w[Benchmarks Benchmark Occupancy-Level])
90
86
  end
@@ -10,12 +10,13 @@ module ViewModel
10
10
  end
11
11
 
12
12
  def extract_aci_recommendations(nodes)
13
- nodes.map { |node|
13
+ recommendations = nodes.map do |node|
14
14
  {
15
15
  sequence: node.at("Seq-Number").content,
16
16
  text: node.at("Text").content,
17
17
  }
18
- }.reject { |node| node[:text].nil? || node[:text].empty? }
18
+ end
19
+ recommendations.reject { |node| node[:text].nil? || node[:text].empty? }
19
20
  end
20
21
 
21
22
  def key_recommendations_efficiency
@@ -297,10 +297,6 @@ module ViewModel
297
297
  @xml_doc.search("Secondary-Heating/Description").map(&:content)
298
298
  end
299
299
 
300
- def all_main_heating_controls_descriptions
301
- @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
302
- end
303
-
304
300
  def all_sap_floor_dimensions
305
301
  @xml_doc.search("SAP-Floor-Dimension").select(&:element?).map { |node|
306
302
  { total_floor_area: xpath(%w[Total-Floor-Area], node).to_f }
@@ -437,10 +437,6 @@ module ViewModel
437
437
  xpath(%w[Electricity-Tariff])
438
438
  end
439
439
 
440
- def all_main_heating_energy_efficiency
441
- @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
442
- end
443
-
444
440
  def solar_water_heating_flag
445
441
  nil
446
442
  end
@@ -397,10 +397,6 @@ module ViewModel
397
397
  xpath(%w[Wind-Turbines-Count])
398
398
  end
399
399
 
400
- def unheated_corridor_length
401
- xpath(%w[Unheated-Corridor-Length])
402
- end
403
-
404
400
  def all_main_heating_descriptions
405
401
  @xml_doc.search("Main-Heating/Description").map(&:content)
406
402
  end
@@ -491,10 +491,6 @@ module ViewModel
491
491
  .map(&:content)
492
492
  end
493
493
 
494
- def transaction_type
495
- nil
496
- end
497
-
498
494
  def main_dwelling_construction_age_band_or_year
499
495
  sap_building_parts =
500
496
  @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
@@ -392,10 +392,6 @@ module ViewModel
392
392
  xpath(%w[Wind-Turbines-Count])
393
393
  end
394
394
 
395
- def unheated_corridor_length
396
- xpath(%w[Unheated-Corridor-Length])
397
- end
398
-
399
395
  def all_main_heating_descriptions
400
396
  @xml_doc.search("Main-Heating/Description").map(&:content)
401
397
  end
@@ -494,10 +490,6 @@ module ViewModel
494
490
  @xml_doc.search("Storey-Height").map(&:content)
495
491
  end
496
492
 
497
- def all_main_heating_energy_efficiency
498
- @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
499
- end
500
-
501
493
  def all_main_heating_controls_energy_efficiency
502
494
  @xml_doc
503
495
  .search("Main-Heating-Controls/Energy-Efficiency-Rating")
@@ -391,10 +391,6 @@ module ViewModel
391
391
  xpath(%w[Wind-Turbines-Count])
392
392
  end
393
393
 
394
- def unheated_corridor_length
395
- xpath(%w[Unheated-Corridor-Length])
396
- end
397
-
398
394
  def all_main_heating_descriptions
399
395
  @xml_doc.search("Main-Heating/Description").map(&:content)
400
396
  end
@@ -393,10 +393,6 @@ module ViewModel
393
393
  nil
394
394
  end
395
395
 
396
- def unheated_corridor_length
397
- xpath(%w[Unheated-Corridor-Length])
398
- end
399
-
400
396
  def built_form
401
397
  xpath(%w[Built-Form])
402
398
  end
@@ -353,10 +353,6 @@ module ViewModel
353
353
  nil
354
354
  end
355
355
 
356
- def level
357
- xpath(%w[Level])
358
- end
359
-
360
356
  def main_heating_controls
361
357
  xpath(%w[Main-Heating-Controls Description])
362
358
  end
@@ -491,24 +491,6 @@ module ViewModel
491
491
  @xml_doc.search("Storey-Height").map(&:content)
492
492
  end
493
493
 
494
- def main_dwelling_construction_age_band_or_year
495
- sap_building_parts =
496
- @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
497
- sap_building_parts.each do |sap_building_part|
498
- building_part_number = sap_building_part.at("Building-Part-Number")
499
-
500
- # Identifies the Main Dwelling
501
- if building_part_number&.content == "1"
502
- return(
503
- sap_building_part.at_xpath(
504
- "Construction-Age-Band | Construction-Year",
505
- )&.content
506
- )
507
- end
508
- end
509
- nil
510
- end
511
-
512
494
  def all_main_heating_environmental_efficiency
513
495
  @xml_doc
514
496
  .search("Main-Heating/Environmental-Efficiency-Rating")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MHCLG Energy Performance of Buildings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-27 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri