epb_view_models 1.0.18 → 1.0.19

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: 21ae4bba2efbc28d42200e7a331a4111b76071399e0a1f901313c2d57035196a
4
- data.tar.gz: 0e244cf4dec75c6213a3c3e8bac4aa2fea2c02f44c9958419d5bf9b9bb2f4f38
3
+ metadata.gz: 4c9e0148c91fdfa17b8230647b7f44630d9197877639f5f8da2948d329afb8e6
4
+ data.tar.gz: db0feff6c2a220fef4810e938bb53d6382df34df65355ff3946443b58ada8950
5
5
  SHA512:
6
- metadata.gz: a2e9785b8c3141d8eaf2b1bf5c1cd647efe67022417b5922e94e44af3b57ce157dab168f4499d4a1b1bce1a6092d8aa87ef954a8ab09cc03335b5bc0a1417571
7
- data.tar.gz: dcf95783220f96004c33f270bd844dd22de531f57136d7f9d230e7244a42b880c310088ca070b60aaedaf78dfb2f766f7f783098603302ca5cb2085b1afbc03f
6
+ metadata.gz: f5e51bceb16b9c4ec62cb2a724ccb58e4daf1d8699b67672a755533278b568c00c7f13ee119f7d78983f913bb13a2cd69b36a1d1372e43a4dc4f62f82b89bb03
7
+ data.tar.gz: 9813262b24abc17231f36b6d5b4bf0eac81f58a31d103b80172e518b228e1974b15176af4c97f6ffeee7bea8cd8ac47cd74b08286554ff57883f6ec9fb3085e3
data/.buildspec.yml CHANGED
@@ -3,10 +3,10 @@ version: 0.2
3
3
  phases:
4
4
  install:
5
5
  runtime-versions:
6
- ruby: 2.7
6
+ ruby: 3.1
7
7
  pre_build:
8
8
  commands:
9
- - gem install bundler:2.2.21
9
+ - gem install bundler:2.3.15
10
10
  - make install
11
11
  build:
12
12
  commands:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.5
1
+ 3.1.2
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby "~> 2.7"
3
+ ruby ">=2.7", "<3.2"
4
4
 
5
5
  source "https://rubygems.org"
6
6
 
data/Gemfile.lock CHANGED
@@ -85,4 +85,4 @@ RUBY VERSION
85
85
  ruby 2.7.5p203
86
86
 
87
87
  BUNDLED WITH
88
- 2.2.32
88
+ 2.3.15
@@ -1360,7 +1360,7 @@
1360
1360
  </xs:enumeration>
1361
1361
  </xs:restriction>
1362
1362
  </xs:simpleType>
1363
- <xs:simpleType name="SAP-FlatLevelCode">
1363
+ <xs:simpleType name="SAP-FlatLevelCode">
1364
1364
  <xs:annotation>
1365
1365
  <xs:documentation>Codes which indicates where a flat is located within a building.</xs:documentation>
1366
1366
  </xs:annotation>
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "1.0.18"
8
+ VERSION = "1.0.19"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -68,8 +68,8 @@ module Presenter::Export
68
68
  view[:lighting_environmental_efficiency_rating] =
69
69
  @view_model.lighting_environmental_efficiency_rating.to_i
70
70
  view[:low_energy_fixed_lighting_outlets_count] =
71
- @view_model.low_energy_fixed_lighting_outlets_count.to_i
72
- view[:low_energy_lighting] = @view_model.low_energy_lighting.to_i
71
+ @view_model.low_energy_fixed_lighting_outlets_count.nil? ? nil : @view_model.low_energy_fixed_lighting_outlets_count.to_i
72
+ view[:low_energy_lighting] = @view_model.low_energy_lighting.nil? ? nil : @view_model.low_energy_lighting.to_i
73
73
  view[:main_fuel_type] = @view_model.main_fuel_type
74
74
  view[:main_heating_controls_descriptions] =
75
75
  @view_model.all_main_heating_controls_descriptions
@@ -259,12 +259,12 @@ module ViewModel
259
259
  end
260
260
 
261
261
  def top_storey
262
- flat_level_code = xpath(%w[Level])
262
+ flat_level_code = xpath(%w[SAP-FlatLevelCode])
263
263
  flat_level_code == "3" ? "Y" : "N"
264
264
  end
265
265
 
266
266
  def storey_count
267
- nil
267
+ xpath(%w[Storeys])
268
268
  end
269
269
 
270
270
  def building_part_number
@@ -365,20 +365,51 @@ module ViewModel
365
365
  nil
366
366
  end
367
367
 
368
- def low_energy_lighting
369
- xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Percentage])
368
+ def fixed_lighting_outlets_count
369
+ @xml_doc.search("Fixed-Lights/Fixed-Light/Lighting-Outlets").map(&:content).map(&:to_i).sum
370
370
  end
371
371
 
372
- def fixed_lighting_outlets_count
373
- xpath(%w[Fixed-Lighting-Outlets-Count])
372
+ def format_fixed_light_array
373
+ @xml_doc
374
+ .search("Fixed-Lights/Fixed-Light")
375
+ .map do |part|
376
+ {
377
+ lighting_efficacy:
378
+ xpath(%w[Lighting-Efficacy], part),
379
+ lighting_outlets:
380
+ xpath(%w[Lighting-Outlets], part),
381
+ }
382
+ end
383
+ end
384
+
385
+ def low_energy_lighting
386
+ total_energy_outlet_count = []
387
+ low_energy_outlet_count = []
388
+
389
+ format_fixed_light_array.each do |outlet|
390
+ if outlet[:lighting_efficacy].to_i > 65
391
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
392
+ end
393
+ total_energy_outlet_count << outlet[:lighting_outlets].to_f
394
+ end
395
+
396
+ (low_energy_outlet_count.sum / total_energy_outlet_count.sum * 100).round
374
397
  end
375
398
 
376
399
  def low_energy_fixed_lighting_outlets_count
377
- xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Count])
400
+ low_energy_outlet_count = []
401
+
402
+ format_fixed_light_array.each do |outlet|
403
+ if outlet[:lighting_efficacy].to_i > 65
404
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
405
+ end
406
+ end
407
+
408
+ low_energy_outlet_count.sum
378
409
  end
379
410
 
380
411
  def open_fireplaces_count
381
- xpath(%w[Open-Fireplaces-Count])
412
+ xpath(%w[Open-Chimneys-Count])
382
413
  end
383
414
 
384
415
  def hot_water_description
@@ -438,7 +469,7 @@ module ViewModel
438
469
  end
439
470
 
440
471
  def wind_turbine_count
441
- xpath(%w[Wind-Turbines-Count])
472
+ @xml_doc.search("Wind-Turbines/Wind-Turbine").map(&:content).count
442
473
  end
443
474
 
444
475
  def unheated_corridor_length
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.18
4
+ version: 1.0.19
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: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -1870,7 +1870,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1870
1870
  - !ruby/object:Gem::Version
1871
1871
  version: '0'
1872
1872
  requirements: []
1873
- rubygems_version: 3.1.6
1873
+ rubygems_version: 3.3.7
1874
1874
  signing_key:
1875
1875
  specification_version: 4
1876
1876
  summary: Library used to parse Energy Performance Certificates (EPC)