epb_view_models 1.0.10 → 1.0.11

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: 70fe31a8b4317370e678562b7ce01baa5db0b8e48b8b185197c88285731a476b
4
- data.tar.gz: 73542839d5a7ac83b87698248308e46faa5397f94c8a63758ebdfd4a93f42a22
3
+ metadata.gz: f71a412d77bf50228e2736594bce2312c64b088dc80a7e0708b3606fcb9f3e2c
4
+ data.tar.gz: 4d2e94eafa908f2a26ea7aa09e2940fa2461ded527a620f0ebf6a29d9a34281e
5
5
  SHA512:
6
- metadata.gz: 27154cc9e7eb4e48f595042cf2e100093647307e62fd6552f57d9e782d5926232fa67d0cb07c0f8767582fe6e123ec165db33efe62b7ca2fd73e237af87e9107
7
- data.tar.gz: 2d05b80c15f37828f1da3ac56857843e21fc33b138c9bfd8109e7a74f9defb64042155a3a84fc6343e99ffea5353cc157f5d8ef6337ac2be30de29036e1c4b94
6
+ metadata.gz: 82cb7dcc22da7a1d5033a65a3cd57ec67827a7dcbf31bcc45cc328de2746a376457feb120143cdc22a6f6367acb2bf5a722bb55044308d4f4cfe1bd1734914e1
7
+ data.tar.gz: 54c8b796430bb11ff37474b65b80db256fbddccdb88d516404baab6b720ff86c8ecbd2ad703bece026a0b61d0f3f75dfd0c3342100c4ee56c0bdce9d1027462a
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "1.0.10"
8
+ VERSION = "1.0.11"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -2,7 +2,7 @@ module ViewModelDomain
2
2
  class XsdArguments
3
3
  attr_reader :simple_type, :assessment_type, :xsd_dir_path, :gem_path
4
4
 
5
- def initialize(simple_type:, assessment_type:, xsd_dir_path: "/api/schemas/xml/**/", gem_path: "")
5
+ def initialize(simple_type:, assessment_type:, xsd_dir_path: "", gem_path: "")
6
6
  @simple_type = simple_type
7
7
  @assessment_type = assessment_type
8
8
  @xsd_dir_path = xsd_dir_path
@@ -2,6 +2,9 @@ module ViewModelGateway
2
2
  class XsdFilesGateway
3
3
  attr_reader :simple_type, :assessment_type, :xsd_dir_path, :glob_path
4
4
 
5
+ API_PATH = "api/schemas/xml/".freeze
6
+ XSD_DEFAULT_PATH = "/api/schemas/xml/**/".freeze
7
+
5
8
  def initialize(domain_arguments)
6
9
  @simple_type = domain_arguments.simple_type
7
10
  @assessment_type = domain_arguments.assessment_type
@@ -10,20 +13,23 @@ module ViewModelGateway
10
13
  end
11
14
 
12
15
  def schema_version(file)
13
- api_path = "api/schemas/xml/"
14
- api_path_start = file.index(api_path) + api_path.length
16
+ api_path_start = file.index(API_PATH) + API_PATH.length
15
17
  schema_version = file[api_path_start..].split("/").first
16
18
  sap_defnied_in_rdsap_dir?(file) ? "#{schema_version}/SAP" : schema_version
17
19
  end
18
20
 
19
21
  def xsd_files
20
- files = case @assessment_type.downcase
21
- when "sap"
22
- sap_xsd_files
23
- when "rdsap"
24
- rdsap_xsd_files
25
- when "cepc"
26
- cepc_xsd_files
22
+ files = if @xsd_dir_path.nil? || @xsd_dir_path.empty?
23
+ case @assessment_type.downcase
24
+ when "sap"
25
+ sap_xsd_files
26
+ when "rdsap"
27
+ rdsap_xsd_files
28
+ when "cepc"
29
+ cepc_xsd_files
30
+ end
31
+ else
32
+ Dir.glob("#{@dir_path}#{@xsd_dir_path}")
27
33
  end
28
34
 
29
35
  raise ViewModelBoundary::XsdFilesNotFound, "No xsd files were found in #{@glob_path} directory" if files.nil? || files.empty?
@@ -38,17 +44,17 @@ module ViewModelGateway
38
44
  end
39
45
 
40
46
  def sap_xsd_files
41
- @glob_path = "#{@dir_path + xsd_dir_path}*-Domains.xsd"
47
+ @glob_path = "#{@dir_path + XSD_DEFAULT_PATH}*-Domains.xsd"
42
48
  Dir.glob(@glob_path)
43
49
  end
44
50
 
45
51
  def rdsap_xsd_files
46
- @glob_path = "#{@dir_path + xsd_dir_path}*-Domains.xsd"
52
+ @glob_path = "#{@dir_path + XSD_DEFAULT_PATH}*-Domains.xsd"
47
53
  Dir.glob(@glob_path)
48
54
  end
49
55
 
50
56
  def cepc_xsd_files
51
- @glob_path = "#{@dir_path + xsd_dir_path}Reported-Data.xsd"
57
+ @glob_path = "#{@dir_path + XSD_DEFAULT_PATH}Reported-Data.xsd"
52
58
  Dir.glob(@glob_path)
53
59
  end
54
60
  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.10
4
+ version: 1.0.11
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-10-12 00:00:00.000000000 Z
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri