bcl 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bcl.rb +2 -1
  3. data/lib/bcl/base_xml.rb +12 -4
  4. data/lib/bcl/component.rb +6 -6
  5. data/lib/bcl/component_from_spreadsheet.rb +13 -10
  6. data/lib/bcl/component_methods.rb +113 -417
  7. data/lib/bcl/component_spreadsheet.rb +3 -6
  8. data/lib/bcl/core_ext.rb +17 -16
  9. data/lib/bcl/master_taxonomy.rb +12 -14
  10. data/lib/bcl/tar_ball.rb +1 -1
  11. data/lib/bcl/version.rb +2 -2
  12. data/lib/files/Components.xls +0 -0
  13. data/lib/files/downloads/40237ee0-5ea7-0130-ad9b-14109fdf0b37.tar.gz +0 -0
  14. data/lib/files/staged/components/Asphalt_Shingles_1_8_in/Asphalt_Shingles_1_8_in.tar.gz +0 -0
  15. data/lib/files/staged/components/Asphalt_Shingles_1_8_in/component.xml +81 -0
  16. data/lib/files/staged/components/Built_up_Roofing_3_8_in/Built_up_Roofing_3_8_in.tar.gz +0 -0
  17. data/lib/files/staged/components/Built_up_Roofing_3_8_in/component.xml +76 -0
  18. data/lib/files/staged/components/Metal_Surface_1_16_in/Metal_Surface_1_16_in.tar.gz +0 -0
  19. data/lib/files/staged/components/Metal_Surface_1_16_in/component.xml +76 -0
  20. data/lib/files/staged/components/Shingle_Backer_1_4_in/Shingle_Backer_1_4_in.tar.gz +0 -0
  21. data/lib/files/staged/components/Shingle_Backer_1_4_in/component.xml +81 -0
  22. data/lib/files/staged/components/Shingle_Backer_3_8_in/Shingle_Backer_3_8_in.tar.gz +0 -0
  23. data/lib/files/staged/components/Shingle_Backer_3_8_in/component.xml +81 -0
  24. data/lib/files/staged/components/Wood_Shingles_1_4_in/Wood_Shingles_1_4_in.tar.gz +0 -0
  25. data/lib/files/staged/components/Wood_Shingles_1_4_in/component.xml +81 -0
  26. data/lib/files/staged/gather/1/Asphalt_Shingles_1_8_in.tar.gz +0 -0
  27. data/lib/files/staged/gather/1/Built_up_Roofing_3_8_in.tar.gz +0 -0
  28. data/lib/files/staged/gather/1/Metal_Surface_1_16_in.tar.gz +0 -0
  29. data/lib/files/staged/gather/1/Shingle_Backer_1_4_in.tar.gz +0 -0
  30. data/lib/files/staged/gather/1/Shingle_Backer_3_8_in.tar.gz +0 -0
  31. data/lib/files/staged/gather/1/Wood_Shingles_1_4_in.tar.gz +0 -0
  32. data/lib/files/staged/gather/components_1.tar.gz +0 -0
  33. metadata +32 -25
@@ -1,5 +1,5 @@
1
1
  ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
2
+ # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
3
  # All rights reserved.
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
@@ -44,7 +44,6 @@ module BCL
44
44
  @worksheets = []
45
45
 
46
46
  begin
47
-
48
47
  excel = WIN32OLE.new('Excel.Application')
49
48
 
50
49
  xlsx = excel.Workbooks.Open(@xlsx_path)
@@ -67,16 +66,13 @@ module BCL
67
66
  xlsx.Save
68
67
  puts '[ComponentSpreadsheet] Spreadsheet changes saved'
69
68
  end
70
-
71
69
  ensure
72
-
73
70
  excel.Quit
74
71
  WIN32OLE.ole_free(excel)
75
72
  excel.ole_free
76
73
  xlsx = nil
77
74
  excel = nil
78
75
  GC.start
79
-
80
76
  end
81
77
  end
82
78
 
@@ -171,6 +167,7 @@ module BCL
171
167
  filepath = values.delete_at(0)
172
168
  # not all components(rows) have all files; skip if filename "" or nil
173
169
  next if filename == '' || filename.nil?
170
+
174
171
  # skip the file if it doesn't exist at the specified location
175
172
  unless File.exist?(filepath)
176
173
  puts "[ComponentSpreadsheet] ERROR #{filepath} -> File does not exist, will not be included in component xml"
@@ -179,7 +176,7 @@ module BCL
179
176
  component_xml.add_file(software_program, version, filepath, filename, filetype)
180
177
 
181
178
  else
182
- fail "Unknown section #{header.name}"
179
+ raise "Unknown section #{header.name}"
183
180
 
184
181
  end
185
182
  end
@@ -1,5 +1,5 @@
1
1
  ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
2
+ # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
3
  # All rights reserved.
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
@@ -19,28 +19,29 @@
19
19
 
20
20
  class String
21
21
  def to_underscore
22
- gsub('OpenStudio','Openstudio')
23
- .gsub('EnergyPlus','Energyplus')
24
- .gsub(/::/, '/')
25
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
26
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
27
- .tr('-', '_')
28
- .tr(' ', '_')
29
- .squeeze('_')
30
- .downcase
22
+ gsub('OpenStudio', 'Openstudio')
23
+ .gsub('EnergyPlus', 'Energyplus')
24
+ .gsub(/::/, '/')
25
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
26
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
27
+ .tr('-', '_')
28
+ .tr(' ', '_')
29
+ .squeeze('_')
30
+ .downcase
31
31
  end
32
32
 
33
33
  def to_bool
34
- return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
35
- return false if self == false || self =~ (/(false|f|no|n|0)$/i)
36
- fail "invalid value for Boolean: '#{self}'"
34
+ return true if self == true || self =~ /(true|t|yes|y|1)$/i
35
+ return false if self == false || self =~ /(false|f|no|n|0)$/i
36
+
37
+ raise "invalid value for Boolean: '#{self}'"
37
38
  end
38
39
 
39
40
  # simple method to create titles -- very custom to catch known inflections
40
41
  def titleize
41
- arr = %w(a an the by to)
42
- upcase_arr = %w(DX EDA AEDG LPD COP)
43
- r = gsub('_', ' ').gsub(/\w+/) do |match|
42
+ arr = ['a', 'an', 'the', 'by', 'to']
43
+ upcase_arr = ['DX', 'EDA', 'AEDG', 'LPD', 'COP']
44
+ r = tr('_', ' ').gsub(/\w+/) do |match|
44
45
  match_result = match
45
46
  if upcase_arr.include?(match.upcase)
46
47
  match_result = upcase_arr[upcase_arr.index(match.upcase)]
@@ -1,5 +1,5 @@
1
1
  ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
2
+ # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
3
  # All rights reserved.
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
@@ -87,9 +87,7 @@ module BCL
87
87
 
88
88
  # save the current taxonomy
89
89
  def save_as_current_taxonomy(path = nil)
90
- unless path
91
- path = current_taxonomy_path
92
- end
90
+ path ||= current_taxonomy_path
93
91
  puts "Saving current taxonomy to #{path}"
94
92
  # this is really not JSON... it is a persisted format of ruby
95
93
  File.open(path, 'w') do |file|
@@ -132,9 +130,9 @@ module BCL
132
130
  # sort the terms as they come out
133
131
  result = terms.uniq
134
132
  if !@sort_alphabetical
135
- result = result.sort { |x, y| x.row <=> y.row }
133
+ result = result.sort_by(&:row)
136
134
  else
137
- result = result.sort { |x, y| x.name <=> y.name }
135
+ result = result.sort_by(&:name)
138
136
  end
139
137
 
140
138
  result
@@ -206,7 +204,7 @@ module BCL
206
204
  # check header
207
205
  header_error = validate_terms_header(terms_worksheet)
208
206
  if header_error
209
- fail 'Header Error on Terms Worksheet'
207
+ raise 'Header Error on Terms Worksheet'
210
208
  end
211
209
 
212
210
  # add root tag
@@ -283,7 +281,7 @@ module BCL
283
281
  else
284
282
  unless terms_worksheet.Columns(col).Rows(2).Value == test_arr[col - 1]['name']
285
283
  if test_arr[col - 1]['strict']
286
- fail "[ERROR] Header does not match: #{col}: '#{terms_worksheet.Columns(col).Rows(2).Value} <> #{test_arr[col - 1]['name']}'"
284
+ raise "[ERROR] Header does not match: #{col}: '#{terms_worksheet.Columns(col).Rows(2).Value} <> #{test_arr[col - 1]['name']}'"
287
285
  else
288
286
  puts "[WARNING] Header does not match: #{col}: '#{terms_worksheet.Columns(col).Rows(2).Value} <> #{test_arr[col - 1]['name']}'"
289
287
  end
@@ -388,7 +386,7 @@ module BCL
388
386
 
389
387
  def sort_tag(tag)
390
388
  # tag.terms = tag.terms.sort {|x, y| x.level_hierarchy <=> y.level_hierarchy}
391
- tag.child_tags = tag.child_tags.sort { |x, y| x.level_hierarchy <=> y.level_hierarchy }
389
+ tag.child_tags = tag.child_tags.sort_by(&:level_hierarchy)
392
390
  tag.child_tags.each { |child_tag| sort_tag(child_tag) }
393
391
 
394
392
  # tag.terms = tag.terms.sort {|x, y| x.name <=> y.name}
@@ -436,13 +434,13 @@ module BCL
436
434
  end
437
435
 
438
436
  unless term.data_type.nil?
439
- valid_types = %w(double integer enum file string autocomplete)
437
+ valid_types = ['double', 'integer', 'enum', 'file', 'string', 'autocomplete']
440
438
  if (term.data_type.downcase != term.data_type) || !valid_types.include?(term.data_type)
441
439
  puts "[ERROR] Term '#{term.name}' does not have a valid data type with '#{term.data_type}'"
442
440
  end
443
441
 
444
- if term.data_type.downcase == 'enum'
445
- if term.enums.nil? || term.enums == '' || term.enums.downcase == 'no enum found'
442
+ if term.data_type.casecmp('enum').zero?
443
+ if term.enums.nil? || term.enums == '' || term.enums.casecmp('no enum found').zero?
446
444
  puts "[ERROR] Term '#{term.name}' does not have valid enumerations"
447
445
  end
448
446
  end
@@ -460,7 +458,7 @@ module BCL
460
458
  # write term to xml
461
459
  def write_terms_to_xml(tag, xml, output_type)
462
460
  terms = get_terms(tag)
463
- if terms.size > 0
461
+ unless terms.empty?
464
462
  terms.each do |term|
465
463
  xml.term do
466
464
  xml.name term.name
@@ -516,7 +514,7 @@ module BCL
516
514
 
517
515
  level += 1
518
516
 
519
- if tag.child_tags.size == 0
517
+ if tag.child_tags.empty?
520
518
  write_terms_to_xml(tag, xml, output_type)
521
519
  end
522
520
 
@@ -1,5 +1,5 @@
1
1
  ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
2
+ # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
3
  # All rights reserved.
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
@@ -1,5 +1,5 @@
1
1
  ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
2
+ # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
3
  # All rights reserved.
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
@@ -18,5 +18,5 @@
18
18
  ######################################################################
19
19
 
20
20
  module BCL
21
- VERSION = '0.5.8'
21
+ VERSION = '0.5.9'.freeze
22
22
  end
Binary file
@@ -0,0 +1,81 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
3
+ <name>Asphalt Shingles - 1/8 in.</name>
4
+ <uid>c32e4780-c88c-012f-b24b-0026b9d40ccf</uid>
5
+ <version_id>65bae990-7926-0130-b658-0026b9d40ccf</version_id>
6
+ <description>Material from a data set created from ASHRAE HOF 2005 and ASHRAE 90.1-2004 Appendix A</description>
7
+ <modeler_description>3.0</modeler_description>
8
+ <provenances>
9
+ <provenance>
10
+ <author>aparker</author>
11
+ <datetime>2012-09-26</datetime>
12
+ <comment>From EnergyPlus 7.1 DataSet ASHRAE_2005_HOF_Materials.idf; Dataset was created from ASHRAE Handbook of Fundamentals, 2005, Chapter 25, Table 4.</comment>
13
+ </provenance>
14
+ </provenances>
15
+ <tags>
16
+ <tag>Material.Opaque.Roofing</tag>
17
+ </tags>
18
+ <attributes>
19
+ <attribute>
20
+ <name>Category</name>
21
+ <value>Shingles</value>
22
+ <datatype>string</datatype>
23
+ </attribute>
24
+ <attribute>
25
+ <name>Thickness</name>
26
+ <value>3.175</value>
27
+ <datatype>float</datatype>
28
+ <units>mm</units>
29
+ </attribute>
30
+ <attribute>
31
+ <name>Conductivity</name>
32
+ <value>0.04</value>
33
+ <datatype>float</datatype>
34
+ <units>W/m*K</units>
35
+ </attribute>
36
+ <attribute>
37
+ <name>Resistance</name>
38
+ <value>0.07937499999999999</value>
39
+ <datatype>float</datatype>
40
+ <units>m^2*K/W</units>
41
+ </attribute>
42
+ <attribute>
43
+ <name>Density</name>
44
+ <value>1120.0</value>
45
+ <datatype>float</datatype>
46
+ <units>kg/m^3</units>
47
+ </attribute>
48
+ <attribute>
49
+ <name>Specific Heat</name>
50
+ <value>1260.0</value>
51
+ <datatype>float</datatype>
52
+ <units>J/kg*K</units>
53
+ </attribute>
54
+ <attribute>
55
+ <name>Typical Application</name>
56
+ <value>Exterior Wall</value>
57
+ <datatype>string</datatype>
58
+ </attribute>
59
+ <attribute>
60
+ <name>Typical Application</name>
61
+ <value>Exterior Roof</value>
62
+ <datatype>string</datatype>
63
+ </attribute>
64
+ <attribute>
65
+ <name>Typical Application</name>
66
+ <value>Attic Roof</value>
67
+ <datatype>string</datatype>
68
+ </attribute>
69
+ <attribute>
70
+ <name>OpenStudio Type</name>
71
+ <value>OS:Material</value>
72
+ <datatype>string</datatype>
73
+ </attribute>
74
+ </attributes>
75
+ <source>
76
+ </source>
77
+ <files>
78
+ </files>
79
+ <costs>
80
+ </costs>
81
+ </component>
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
3
+ <name>Built-up Roofing - 3/8 in.</name>
4
+ <uid>c32853e0-c88c-012f-b247-0026b9d40ccf</uid>
5
+ <version_id>65b7dc50-7926-0130-b654-0026b9d40ccf</version_id>
6
+ <description>Material from a data set created from ASHRAE HOF 2005 and ASHRAE 90.1-2004 Appendix A</description>
7
+ <modeler_description>3.0</modeler_description>
8
+ <provenances>
9
+ <provenance>
10
+ <author>aparker</author>
11
+ <datetime>2012-09-26</datetime>
12
+ <comment>From EnergyPlus 7.1 DataSet ASHRAE_2005_HOF_Materials.idf; Dataset was created from ASHRAE Handbook of Fundamentals, 2005, Chapter 25, Table 4.</comment>
13
+ </provenance>
14
+ </provenances>
15
+ <tags>
16
+ <tag>Material.Opaque.Roofing</tag>
17
+ </tags>
18
+ <attributes>
19
+ <attribute>
20
+ <name>Category</name>
21
+ <value>Built-Up Roofing</value>
22
+ <datatype>string</datatype>
23
+ </attribute>
24
+ <attribute>
25
+ <name>Thickness</name>
26
+ <value>9.524999999999999</value>
27
+ <datatype>float</datatype>
28
+ <units>mm</units>
29
+ </attribute>
30
+ <attribute>
31
+ <name>Conductivity</name>
32
+ <value>0.16</value>
33
+ <datatype>float</datatype>
34
+ <units>W/m*K</units>
35
+ </attribute>
36
+ <attribute>
37
+ <name>Resistance</name>
38
+ <value>0.05953125000000001</value>
39
+ <datatype>float</datatype>
40
+ <units>m^2*K/W</units>
41
+ </attribute>
42
+ <attribute>
43
+ <name>Density</name>
44
+ <value>1120.0</value>
45
+ <datatype>float</datatype>
46
+ <units>kg/m^3</units>
47
+ </attribute>
48
+ <attribute>
49
+ <name>Specific Heat</name>
50
+ <value>1459.9999999999998</value>
51
+ <datatype>float</datatype>
52
+ <units>J/kg*K</units>
53
+ </attribute>
54
+ <attribute>
55
+ <name>Typical Application</name>
56
+ <value>Exterior Roof</value>
57
+ <datatype>string</datatype>
58
+ </attribute>
59
+ <attribute>
60
+ <name>Typical Application</name>
61
+ <value>Attic Roof</value>
62
+ <datatype>string</datatype>
63
+ </attribute>
64
+ <attribute>
65
+ <name>OpenStudio Type</name>
66
+ <value>OS:Material</value>
67
+ <datatype>string</datatype>
68
+ </attribute>
69
+ </attributes>
70
+ <source>
71
+ </source>
72
+ <files>
73
+ </files>
74
+ <costs>
75
+ </costs>
76
+ </component>
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
3
+ <name>Metal Surface - 1/16 in.</name>
4
+ <uid>c32baf60-c88c-012f-b249-0026b9d40ccf</uid>
5
+ <version_id>65b962f0-7926-0130-b656-0026b9d40ccf</version_id>
6
+ <description>Material from a data set created from ASHRAE HOF 2005 and ASHRAE 90.1-2004 Appendix A</description>
7
+ <modeler_description>3.0</modeler_description>
8
+ <provenances>
9
+ <provenance>
10
+ <author>aparker</author>
11
+ <datetime>2012-09-26</datetime>
12
+ <comment>From EnergyPlus 7.1 DataSet ASHRAE_2005_HOF_Materials.idf; Dataset was created from ASHRAE Handbook of Fundamentals, 2005, Chapter 25, Table 4.</comment>
13
+ </provenance>
14
+ </provenances>
15
+ <tags>
16
+ <tag>Material.Opaque.Roofing</tag>
17
+ </tags>
18
+ <attributes>
19
+ <attribute>
20
+ <name>Category</name>
21
+ <value>Metal Roofing</value>
22
+ <datatype>string</datatype>
23
+ </attribute>
24
+ <attribute>
25
+ <name>Thickness</name>
26
+ <value>1.5875</value>
27
+ <datatype>float</datatype>
28
+ <units>mm</units>
29
+ </attribute>
30
+ <attribute>
31
+ <name>Conductivity</name>
32
+ <value>45.28000000000001</value>
33
+ <datatype>float</datatype>
34
+ <units>W/m*K</units>
35
+ </attribute>
36
+ <attribute>
37
+ <name>Resistance</name>
38
+ <value>3.505962897526502e-05</value>
39
+ <datatype>float</datatype>
40
+ <units>m^2*K/W</units>
41
+ </attribute>
42
+ <attribute>
43
+ <name>Density</name>
44
+ <value>7824.0</value>
45
+ <datatype>float</datatype>
46
+ <units>kg/m^3</units>
47
+ </attribute>
48
+ <attribute>
49
+ <name>Specific Heat</name>
50
+ <value>499.99999999999994</value>
51
+ <datatype>float</datatype>
52
+ <units>J/kg*K</units>
53
+ </attribute>
54
+ <attribute>
55
+ <name>Typical Application</name>
56
+ <value>Exterior Roof</value>
57
+ <datatype>string</datatype>
58
+ </attribute>
59
+ <attribute>
60
+ <name>Typical Application</name>
61
+ <value>Attic Roof</value>
62
+ <datatype>string</datatype>
63
+ </attribute>
64
+ <attribute>
65
+ <name>OpenStudio Type</name>
66
+ <value>OS:Material</value>
67
+ <datatype>string</datatype>
68
+ </attribute>
69
+ </attributes>
70
+ <source>
71
+ </source>
72
+ <files>
73
+ </files>
74
+ <costs>
75
+ </costs>
76
+ </component>