epb_view_models 1.0.18 → 1.0.21

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: 21ae4bba2efbc28d42200e7a331a4111b76071399e0a1f901313c2d57035196a
4
- data.tar.gz: 0e244cf4dec75c6213a3c3e8bac4aa2fea2c02f44c9958419d5bf9b9bb2f4f38
3
+ metadata.gz: 572c2549664205ab7520da935aafc0035b54284e1393d57b311c8752dcffd6cb
4
+ data.tar.gz: 433ce122549667797f1fc3721e7d86141a5b4dc37ceb8c54b9b8992be1800e31
5
5
  SHA512:
6
- metadata.gz: a2e9785b8c3141d8eaf2b1bf5c1cd647efe67022417b5922e94e44af3b57ce157dab168f4499d4a1b1bce1a6092d8aa87ef954a8ab09cc03335b5bc0a1417571
7
- data.tar.gz: dcf95783220f96004c33f270bd844dd22de531f57136d7f9d230e7244a42b880c310088ca070b60aaedaf78dfb2f766f7f783098603302ca5cb2085b1afbc03f
6
+ metadata.gz: eda8faaa028aff00f41d34963876587040181b957aaba1cadaa5a16f3878c3c582712e9223fb0e18aa61dade755067b2bc70872a5d2e112dfb4e1de23cd46f1e
7
+ data.tar.gz: e9045b9d0e6d892c381e6f2c75f03704238e82866b31e4ec7fa0dd69e9e42bcb33e07f13f754b55eb07dd6c214e80ad610a915f183956e0b08798b2803b9de0f
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,13 +1,13 @@
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
 
7
7
  group :test do
8
8
  gem "rake", "~> 13.0.6"
9
9
  gem "rspec", "~> 3.0"
10
- gem "rubocop-govuk", "~> 4.0.0", require: false
10
+ gem "rubocop-govuk", "~> 4.7.0", require: false
11
11
  end
12
12
 
13
13
  gem "nokogiri", "~> 1.11"
data/Gemfile.lock CHANGED
@@ -1,29 +1,30 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (7.0.2.3)
4
+ activesupport (7.0.3.1)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (>= 1.6, < 2)
7
7
  minitest (>= 5.1)
8
8
  tzinfo (~> 2.0)
9
9
  ast (2.4.2)
10
- concurrent-ruby (1.1.9)
10
+ concurrent-ruby (1.1.10)
11
11
  diff-lcs (1.5.0)
12
- i18n (1.10.0)
12
+ i18n (1.12.0)
13
13
  concurrent-ruby (~> 1.0)
14
+ json (2.6.2)
14
15
  mini_portile2 (2.8.0)
15
- minitest (5.15.0)
16
- nokogiri (1.13.3)
16
+ minitest (5.16.3)
17
+ nokogiri (1.13.8)
17
18
  mini_portile2 (~> 2.8.0)
18
19
  racc (~> 1.4)
19
- parallel (1.21.0)
20
- parser (3.1.1.0)
20
+ parallel (1.22.1)
21
+ parser (3.1.2.1)
21
22
  ast (~> 2.4.1)
22
23
  racc (1.6.0)
23
- rack (2.2.3)
24
+ rack (2.2.4)
24
25
  rainbow (3.1.1)
25
26
  rake (13.0.6)
26
- regexp_parser (2.2.1)
27
+ regexp_parser (2.5.0)
27
28
  rexml (3.2.5)
28
29
  rspec (3.11.0)
29
30
  rspec-core (~> 3.11.0)
@@ -34,40 +35,40 @@ GEM
34
35
  rspec-expectations (3.11.0)
35
36
  diff-lcs (>= 1.2.0, < 2.0)
36
37
  rspec-support (~> 3.11.0)
37
- rspec-mocks (3.11.0)
38
+ rspec-mocks (3.11.1)
38
39
  diff-lcs (>= 1.2.0, < 2.0)
39
40
  rspec-support (~> 3.11.0)
40
41
  rspec-support (3.11.0)
41
- rubocop (1.15.0)
42
+ rubocop (1.35.0)
43
+ json (~> 2.3)
42
44
  parallel (~> 1.10)
43
- parser (>= 3.0.0.0)
45
+ parser (>= 3.1.2.1)
44
46
  rainbow (>= 2.2.2, < 4.0)
45
47
  regexp_parser (>= 1.8, < 3.0)
46
- rexml
47
- rubocop-ast (>= 1.5.0, < 2.0)
48
+ rexml (>= 3.2.5, < 4.0)
49
+ rubocop-ast (>= 1.20.1, < 2.0)
48
50
  ruby-progressbar (~> 1.7)
49
51
  unicode-display_width (>= 1.4.0, < 3.0)
50
- rubocop-ast (1.6.0)
51
- parser (>= 3.0.1.1)
52
- rubocop-govuk (4.0.0)
53
- rubocop (~> 1.15.0)
54
- rubocop-ast (~> 1.6.0)
55
- rubocop-rails (~> 2.10.0)
56
- rubocop-rake (= 0.5.1)
57
- rubocop-rspec (~> 2.3.0)
58
- rubocop-rails (2.10.1)
52
+ rubocop-ast (1.21.0)
53
+ parser (>= 3.1.1.0)
54
+ rubocop-govuk (4.7.0)
55
+ rubocop (= 1.35.0)
56
+ rubocop-ast (= 1.21.0)
57
+ rubocop-rails (= 2.15.2)
58
+ rubocop-rake (= 0.6.0)
59
+ rubocop-rspec (= 2.12.1)
60
+ rubocop-rails (2.15.2)
59
61
  activesupport (>= 4.2.0)
60
62
  rack (>= 1.1)
61
63
  rubocop (>= 1.7.0, < 2.0)
62
- rubocop-rake (0.5.1)
63
- rubocop
64
- rubocop-rspec (2.3.0)
64
+ rubocop-rake (0.6.0)
65
65
  rubocop (~> 1.0)
66
- rubocop-ast (>= 1.1.0)
66
+ rubocop-rspec (2.12.1)
67
+ rubocop (~> 1.31)
67
68
  ruby-progressbar (1.11.0)
68
- tzinfo (2.0.4)
69
+ tzinfo (2.0.5)
69
70
  concurrent-ruby (~> 1.0)
70
- unicode-display_width (2.1.0)
71
+ unicode-display_width (2.2.0)
71
72
  zeitwerk (2.4.2)
72
73
 
73
74
  PLATFORMS
@@ -78,11 +79,11 @@ DEPENDENCIES
78
79
  rake (~> 13.0.6)
79
80
  rexml (~> 3.2, >= 3.2.5)
80
81
  rspec (~> 3.0)
81
- rubocop-govuk (~> 4.0.0)
82
+ rubocop-govuk (~> 4.7.0)
82
83
  zeitwerk (~> 2.4.2)
83
84
 
84
85
  RUBY VERSION
85
86
  ruby 2.7.5p203
86
87
 
87
88
  BUNDLED WITH
88
- 2.2.32
89
+ 2.3.15
data/Makefile CHANGED
@@ -14,4 +14,4 @@ test: ## Run all tests
14
14
  @bundle exec rake spec
15
15
 
16
16
  format: ## Runs Rubocop with the GOV.UK rules
17
- @bundle exec rake rubocop:auto_correct
17
+ @bundle exec rake rubocop:autocorrect
@@ -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>
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = "Library used to parse Energy Performance Certificates (EPC)"
11
11
  spec.homepage = "https://github.com/communitiesuk/epb-view-models"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = ">= 2.7.0"
13
+ spec.required_ruby_version = ">= 3.1"
14
14
 
15
15
  # Specify which files should be added to the gem when it is released.
16
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -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.21"
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
@@ -1,6 +1,6 @@
1
1
  module Presenter
2
2
  module RdSap
3
- class Hera
3
+ class DomesticDigest
4
4
  TYPE_OF_ASSESSMENT = "RdSAP".freeze
5
5
  private_constant :TYPE_OF_ASSESSMENT
6
6
 
@@ -9,7 +9,7 @@ module Presenter
9
9
  @schema_type = schema_type
10
10
  end
11
11
 
12
- def to_hera_hash
12
+ def to_domestic_digest
13
13
  {
14
14
  type_of_assessment: TYPE_OF_ASSESSMENT,
15
15
  assessment_id: @view_model.assessment_id,
@@ -35,6 +35,8 @@ module Presenter
35
35
  @schema_type,
36
36
  @view_model.report_type),
37
37
  has_hot_water_cylinder: @view_model.has_hot_water_cylinder,
38
+ total_floor_area: @view_model.total_floor_area.to_s,
39
+ has_mains_gas: @view_model.mains_gas,
38
40
  }
39
41
  end
40
42
  end
@@ -54,7 +54,7 @@ module Presenter
54
54
  ),
55
55
  current_energy_efficiency_rating: @view_model.current_energy_rating,
56
56
  dwelling_type: @view_model.dwelling_type,
57
- estimated_energy_cost: estimated_energy_cost,
57
+ estimated_energy_cost:,
58
58
  main_fuel_type: @view_model.main_fuel_type,
59
59
  heat_demand: {
60
60
  current_space_heating_demand:
@@ -1,12 +1,12 @@
1
1
  module Presenter
2
2
  module Sap
3
- class Hera
3
+ class DomesticDigest
4
4
  def initialize(view_model, schema_type)
5
5
  @view_model = view_model
6
6
  @schema_type = schema_type
7
7
  end
8
8
 
9
- def to_hera_hash
9
+ def to_domestic_digest
10
10
  {
11
11
  type_of_assessment: @view_model.type_of_assessment,
12
12
  assessment_id: @view_model.assessment_id,
@@ -32,6 +32,8 @@ module Presenter
32
32
  @schema_type,
33
33
  @view_model.report_type),
34
34
  has_hot_water_cylinder: @view_model.has_hot_water_cylinder,
35
+ total_floor_area: @view_model.total_floor_area.to_s,
36
+ has_mains_gas: @view_model.mains_gas,
35
37
  }
36
38
  end
37
39
  end
@@ -51,7 +51,7 @@ module Presenter
51
51
  ),
52
52
  current_energy_efficiency_rating: @view_model.current_energy_rating,
53
53
  dwelling_type: @view_model.dwelling_type,
54
- estimated_energy_cost: estimated_energy_cost,
54
+ estimated_energy_cost:,
55
55
  main_fuel_type: @view_model.main_fuel_type,
56
56
  heat_demand: {
57
57
  current_space_heating_demand:
@@ -8,7 +8,7 @@ module ViewModel
8
8
  @summary = Presenter::RdSap::Summary.new(view_model)
9
9
  @report = Presenter::RdSap::Report.new(view_model, schema_type, additional_data)
10
10
  @recommendation_report = Presenter::RdSap::RecommendationReport.new(view_model)
11
- @hera = Presenter::RdSap::Hera.new(view_model, schema_type)
11
+ @domestic_digest = Presenter::RdSap::DomesticDigest.new(view_model, schema_type)
12
12
  end
13
13
 
14
14
  def type
@@ -31,10 +31,17 @@ module ViewModel
31
31
  @recommendation_report.to_hash
32
32
  end
33
33
 
34
+ def to_domestic_digest
35
+ @domestic_digest.to_domestic_digest
36
+ end
37
+
34
38
  def to_hera_hash
35
- @hera.to_hera_hash
39
+ to_domestic_digest
36
40
  end
37
41
 
42
+ extend Gem::Deprecate
43
+ deprecate :to_hera_hash, :to_domestic_digest, 2022, 9
44
+
38
45
  def get_view_model
39
46
  view_model
40
47
  end
@@ -1,6 +1,8 @@
1
1
  module ViewModel
2
2
  module SapSchema1900
3
3
  class CommonSchema < ViewModel::DomesticEpcViewModel
4
+ THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY = 65
5
+
4
6
  def assessment_id
5
7
  xpath(%w[Report-Header RRN])
6
8
  end
@@ -259,12 +261,12 @@ module ViewModel
259
261
  end
260
262
 
261
263
  def top_storey
262
- flat_level_code = xpath(%w[Level])
264
+ flat_level_code = xpath(%w[SAP-FlatLevelCode])
263
265
  flat_level_code == "3" ? "Y" : "N"
264
266
  end
265
267
 
266
268
  def storey_count
267
- nil
269
+ xpath(%w[Storeys])
268
270
  end
269
271
 
270
272
  def building_part_number
@@ -365,20 +367,51 @@ module ViewModel
365
367
  nil
366
368
  end
367
369
 
368
- def low_energy_lighting
369
- xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Percentage])
370
+ def fixed_lighting_outlets_count
371
+ @xml_doc.search("Fixed-Lights/Fixed-Light/Lighting-Outlets").map(&:content).map(&:to_i).sum
370
372
  end
371
373
 
372
- def fixed_lighting_outlets_count
373
- xpath(%w[Fixed-Lighting-Outlets-Count])
374
+ def format_fixed_light_array
375
+ @xml_doc
376
+ .search("Fixed-Lights/Fixed-Light")
377
+ .map do |part|
378
+ {
379
+ lighting_efficacy:
380
+ xpath(%w[Lighting-Efficacy], part),
381
+ lighting_outlets:
382
+ xpath(%w[Lighting-Outlets], part),
383
+ }
384
+ end
385
+ end
386
+
387
+ def low_energy_lighting
388
+ total_energy_outlet_count = []
389
+ low_energy_outlet_count = []
390
+
391
+ format_fixed_light_array.each do |outlet|
392
+ if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY
393
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
394
+ end
395
+ total_energy_outlet_count << outlet[:lighting_outlets].to_f
396
+ end
397
+
398
+ (low_energy_outlet_count.sum / total_energy_outlet_count.sum * 100).round
374
399
  end
375
400
 
376
401
  def low_energy_fixed_lighting_outlets_count
377
- xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Count])
402
+ low_energy_outlet_count = []
403
+
404
+ format_fixed_light_array.each do |outlet|
405
+ if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY
406
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
407
+ end
408
+ end
409
+
410
+ low_energy_outlet_count.sum
378
411
  end
379
412
 
380
413
  def open_fireplaces_count
381
- xpath(%w[Open-Fireplaces-Count])
414
+ xpath(%w[Open-Chimneys-Count])
382
415
  end
383
416
 
384
417
  def hot_water_description
@@ -438,7 +471,7 @@ module ViewModel
438
471
  end
439
472
 
440
473
  def wind_turbine_count
441
- xpath(%w[Wind-Turbines-Count])
474
+ @xml_doc.search("Wind-Turbines/Wind-Turbine").map(&:content).count
442
475
  end
443
476
 
444
477
  def unheated_corridor_length
@@ -8,7 +8,7 @@ module ViewModel
8
8
  @summary = Presenter::Sap::Summary.new(view_model)
9
9
  @report = Presenter::Sap::Report.new(view_model, schema_type, additional_data)
10
10
  @recommendation_report = Presenter::Sap::RecommendationReport.new(view_model)
11
- @hera = Presenter::Sap::Hera.new(view_model, schema_type)
11
+ @domestic_digest = Presenter::Sap::DomesticDigest.new(view_model, schema_type)
12
12
  end
13
13
 
14
14
  def type
@@ -31,10 +31,17 @@ module ViewModel
31
31
  @recommendation_report.to_hash
32
32
  end
33
33
 
34
+ def to_domestic_digest
35
+ @domestic_digest.to_domestic_digest
36
+ end
37
+
34
38
  def to_hera_hash
35
- @hera.to_hera_hash
39
+ to_domestic_digest
36
40
  end
37
41
 
42
+ extend Gem::Deprecate
43
+ deprecate :to_hera_hash, :to_domestic_digest, 2022, 9
44
+
38
45
  def get_view_model
39
46
  view_model
40
47
  end
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.21
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-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -1674,13 +1674,13 @@ files:
1674
1674
  - lib/presenter/export/commercial.rb
1675
1675
  - lib/presenter/export/domestic.rb
1676
1676
  - lib/presenter/export/statistics.rb
1677
+ - lib/presenter/rd_sap/domestic_digest.rb
1677
1678
  - lib/presenter/rd_sap/export_configuration.rb
1678
- - lib/presenter/rd_sap/hera.rb
1679
1679
  - lib/presenter/rd_sap/recommendation_report.rb
1680
1680
  - lib/presenter/rd_sap/report.rb
1681
1681
  - lib/presenter/rd_sap/summary.rb
1682
+ - lib/presenter/sap/domestic_digest.rb
1682
1683
  - lib/presenter/sap/export_configuration.rb
1683
- - lib/presenter/sap/hera.rb
1684
1684
  - lib/presenter/sap/recommendation_report.rb
1685
1685
  - lib/presenter/sap/report.rb
1686
1686
  - lib/presenter/sap/summary.rb
@@ -1863,14 +1863,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
1863
1863
  requirements:
1864
1864
  - - ">="
1865
1865
  - !ruby/object:Gem::Version
1866
- version: 2.7.0
1866
+ version: '3.1'
1867
1867
  required_rubygems_version: !ruby/object:Gem::Requirement
1868
1868
  requirements:
1869
1869
  - - ">="
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)