bcl 0.5.9 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +21 -0
  3. data/.rubocop.yml +8 -0
  4. data/CHANGELOG.md +79 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE.md +27 -0
  7. data/README.md +40 -0
  8. data/Rakefile +347 -0
  9. data/bcl.gemspec +48 -0
  10. data/lib/bcl/base_xml.rb +31 -15
  11. data/lib/bcl/component.rb +32 -16
  12. data/lib/bcl/component_from_spreadsheet.rb +37 -23
  13. data/lib/bcl/component_methods.rb +52 -38
  14. data/lib/bcl/core_ext.rb +31 -15
  15. data/lib/bcl/tar_ball.rb +31 -15
  16. data/lib/bcl/version.rb +32 -16
  17. data/lib/bcl.rb +37 -4
  18. data/schemas/v2/component_2012_11_08.xsd +291 -0
  19. data/schemas/v2/measure_2013_3_26.xsd +153 -0
  20. data/schemas/v3/common_bcl_v3.xsd +422 -0
  21. data/schemas/v3/component_v3.xsd +445 -0
  22. data/schemas/v3/measure_v3.xsd +496 -0
  23. metadata +102 -81
  24. data/lib/bcl/component_spreadsheet.rb +0 -287
  25. data/lib/bcl/master_taxonomy.rb +0 -528
  26. data/lib/files/downloads/40237ee0-5ea7-0130-ad9b-14109fdf0b37.tar.gz +0 -0
  27. data/lib/files/staged/components/Asphalt_Shingles_1_8_in/Asphalt_Shingles_1_8_in.tar.gz +0 -0
  28. data/lib/files/staged/components/Asphalt_Shingles_1_8_in/component.xml +0 -81
  29. data/lib/files/staged/components/Built_up_Roofing_3_8_in/Built_up_Roofing_3_8_in.tar.gz +0 -0
  30. data/lib/files/staged/components/Built_up_Roofing_3_8_in/component.xml +0 -76
  31. data/lib/files/staged/components/Metal_Surface_1_16_in/Metal_Surface_1_16_in.tar.gz +0 -0
  32. data/lib/files/staged/components/Metal_Surface_1_16_in/component.xml +0 -76
  33. data/lib/files/staged/components/Shingle_Backer_1_4_in/Shingle_Backer_1_4_in.tar.gz +0 -0
  34. data/lib/files/staged/components/Shingle_Backer_1_4_in/component.xml +0 -81
  35. data/lib/files/staged/components/Shingle_Backer_3_8_in/Shingle_Backer_3_8_in.tar.gz +0 -0
  36. data/lib/files/staged/components/Shingle_Backer_3_8_in/component.xml +0 -81
  37. data/lib/files/staged/components/Wood_Shingles_1_4_in/Wood_Shingles_1_4_in.tar.gz +0 -0
  38. data/lib/files/staged/components/Wood_Shingles_1_4_in/component.xml +0 -81
  39. data/lib/files/staged/gather/1/Asphalt_Shingles_1_8_in.tar.gz +0 -0
  40. data/lib/files/staged/gather/1/Built_up_Roofing_3_8_in.tar.gz +0 -0
  41. data/lib/files/staged/gather/1/Metal_Surface_1_16_in.tar.gz +0 -0
  42. data/lib/files/staged/gather/1/Shingle_Backer_1_4_in.tar.gz +0 -0
  43. data/lib/files/staged/gather/1/Shingle_Backer_3_8_in.tar.gz +0 -0
  44. data/lib/files/staged/gather/1/Wood_Shingles_1_4_in.tar.gz +0 -0
  45. data/lib/files/staged/gather/components_1.tar.gz +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Macumber
@@ -9,213 +9,234 @@ authors:
9
9
  - Andrew Parker
10
10
  - Katherine Fleming
11
11
  autorequire:
12
- bindir: bin
12
+ bindir: exe
13
13
  cert_chain: []
14
- date: 2020-04-28 00:00:00.000000000 Z
14
+ date: 2021-08-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: archive-tar-minitar
17
+ name: builder
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ">="
20
+ - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 3.2.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 3.2.4
30
30
  - !ruby/object:Gem::Dependency
31
- name: builder
31
+ name: faraday
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ">="
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '0'
36
+ version: 1.0.1
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">="
41
+ - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 1.0.1
44
44
  - !ruby/object:Gem::Dependency
45
- name: faraday
45
+ name: minitar
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: '0.9'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ">="
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0'
57
+ version: '0.9'
58
58
  - !ruby/object:Gem::Dependency
59
- name: multi_json
59
+ name: openstudio_measure_tester
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ">="
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '0'
64
+ version: 0.3.1
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ">="
69
+ - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '0'
71
+ version: 0.3.1
72
+ - !ruby/object:Gem::Dependency
73
+ name: rexml
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '='
77
+ - !ruby/object:Gem::Version
78
+ version: 3.2.5
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 3.2.5
72
86
  - !ruby/object:Gem::Dependency
73
87
  name: rubyzip
74
88
  requirement: !ruby/object:Gem::Requirement
75
89
  requirements:
76
- - - ">="
90
+ - - "~>"
77
91
  - !ruby/object:Gem::Version
78
- version: '0'
92
+ version: 2.3.2
79
93
  type: :runtime
80
94
  prerelease: false
81
95
  version_requirements: !ruby/object:Gem::Requirement
82
96
  requirements:
83
- - - ">="
97
+ - - "~>"
84
98
  - !ruby/object:Gem::Version
85
- version: '0'
99
+ version: 2.3.2
100
+ - !ruby/object:Gem::Dependency
101
+ name: spreadsheet
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '='
105
+ - !ruby/object:Gem::Version
106
+ version: 1.2.9
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '='
112
+ - !ruby/object:Gem::Version
113
+ version: 1.2.9
86
114
  - !ruby/object:Gem::Dependency
87
115
  name: uuid
88
116
  requirement: !ruby/object:Gem::Requirement
89
117
  requirements:
90
- - - ">="
118
+ - - "~>"
91
119
  - !ruby/object:Gem::Version
92
- version: '0'
120
+ version: 2.3.9
93
121
  type: :runtime
94
122
  prerelease: false
95
123
  version_requirements: !ruby/object:Gem::Requirement
96
124
  requirements:
97
- - - ">="
125
+ - - "~>"
98
126
  - !ruby/object:Gem::Version
99
- version: '0'
127
+ version: 2.3.9
100
128
  - !ruby/object:Gem::Dependency
101
129
  name: yamler
102
130
  requirement: !ruby/object:Gem::Requirement
103
131
  requirements:
104
- - - ">="
132
+ - - '='
105
133
  - !ruby/object:Gem::Version
106
- version: '0'
134
+ version: 0.1.0
107
135
  type: :runtime
108
136
  prerelease: false
109
137
  version_requirements: !ruby/object:Gem::Requirement
110
138
  requirements:
111
- - - ">="
139
+ - - '='
112
140
  - !ruby/object:Gem::Version
113
- version: '0'
141
+ version: 0.1.0
114
142
  - !ruby/object:Gem::Dependency
115
143
  name: zliby
116
144
  requirement: !ruby/object:Gem::Requirement
117
145
  requirements:
118
- - - ">="
146
+ - - '='
119
147
  - !ruby/object:Gem::Version
120
- version: '0'
148
+ version: 0.0.5
121
149
  type: :runtime
122
150
  prerelease: false
123
151
  version_requirements: !ruby/object:Gem::Requirement
124
152
  requirements:
125
- - - ">="
153
+ - - '='
126
154
  - !ruby/object:Gem::Version
127
- version: '0'
155
+ version: 0.0.5
128
156
  - !ruby/object:Gem::Dependency
129
- name: rexml
157
+ name: rake
130
158
  requirement: !ruby/object:Gem::Requirement
131
159
  requirements:
132
- - - ">="
160
+ - - "~>"
133
161
  - !ruby/object:Gem::Version
134
- version: '0'
135
- type: :runtime
162
+ version: '13.0'
163
+ type: :development
136
164
  prerelease: false
137
165
  version_requirements: !ruby/object:Gem::Requirement
138
166
  requirements:
139
- - - ">="
167
+ - - "~>"
140
168
  - !ruby/object:Gem::Version
141
- version: '0'
169
+ version: '13.0'
142
170
  - !ruby/object:Gem::Dependency
143
- name: spreadsheet
171
+ name: rspec
144
172
  requirement: !ruby/object:Gem::Requirement
145
173
  requirements:
146
- - - ">="
174
+ - - "~>"
147
175
  - !ruby/object:Gem::Version
148
- version: '0'
149
- type: :runtime
176
+ version: '3.9'
177
+ type: :development
150
178
  prerelease: false
151
179
  version_requirements: !ruby/object:Gem::Requirement
152
180
  requirements:
153
- - - ">="
181
+ - - "~>"
154
182
  - !ruby/object:Gem::Version
155
- version: '0'
183
+ version: '3.9'
156
184
  description: This gem contains helper methods for generating the Component XML file
157
185
  needed to upload files to the Building Component Library. It also contains the classes
158
- needed for logging in via the api and uploading generating components
186
+ needed for logging in via the api and uploading generating components and measures.
159
187
  email: Nicholas.Long@nrel.gov
160
188
  executables: []
161
189
  extensions: []
162
190
  extra_rdoc_files: []
163
191
  files:
192
+ - ".gitignore"
193
+ - ".rubocop.yml"
194
+ - CHANGELOG.md
195
+ - Gemfile
196
+ - LICENSE.md
197
+ - README.md
198
+ - Rakefile
199
+ - bcl.gemspec
164
200
  - lib/bcl.rb
165
201
  - lib/bcl/base_xml.rb
166
202
  - lib/bcl/component.rb
167
203
  - lib/bcl/component_from_spreadsheet.rb
168
204
  - lib/bcl/component_methods.rb
169
- - lib/bcl/component_spreadsheet.rb
170
205
  - lib/bcl/core_ext.rb
171
206
  - lib/bcl/current_taxonomy.json
172
207
  - lib/bcl/current_taxonomy.xml
173
- - lib/bcl/master_taxonomy.rb
174
208
  - lib/bcl/tar_ball.rb
175
209
  - lib/bcl/version.rb
176
210
  - lib/files/Components.xls
177
- - lib/files/downloads/40237ee0-5ea7-0130-ad9b-14109fdf0b37.tar.gz
178
- - lib/files/staged/components/Asphalt_Shingles_1_8_in/Asphalt_Shingles_1_8_in.tar.gz
179
- - lib/files/staged/components/Asphalt_Shingles_1_8_in/component.xml
180
- - lib/files/staged/components/Built_up_Roofing_3_8_in/Built_up_Roofing_3_8_in.tar.gz
181
- - lib/files/staged/components/Built_up_Roofing_3_8_in/component.xml
182
- - lib/files/staged/components/Metal_Surface_1_16_in/Metal_Surface_1_16_in.tar.gz
183
- - lib/files/staged/components/Metal_Surface_1_16_in/component.xml
184
- - lib/files/staged/components/Shingle_Backer_1_4_in/Shingle_Backer_1_4_in.tar.gz
185
- - lib/files/staged/components/Shingle_Backer_1_4_in/component.xml
186
- - lib/files/staged/components/Shingle_Backer_3_8_in/Shingle_Backer_3_8_in.tar.gz
187
- - lib/files/staged/components/Shingle_Backer_3_8_in/component.xml
188
- - lib/files/staged/components/Wood_Shingles_1_4_in/Wood_Shingles_1_4_in.tar.gz
189
- - lib/files/staged/components/Wood_Shingles_1_4_in/component.xml
190
- - lib/files/staged/gather/1/Asphalt_Shingles_1_8_in.tar.gz
191
- - lib/files/staged/gather/1/Built_up_Roofing_3_8_in.tar.gz
192
- - lib/files/staged/gather/1/Metal_Surface_1_16_in.tar.gz
193
- - lib/files/staged/gather/1/Shingle_Backer_1_4_in.tar.gz
194
- - lib/files/staged/gather/1/Shingle_Backer_3_8_in.tar.gz
195
- - lib/files/staged/gather/1/Wood_Shingles_1_4_in.tar.gz
196
- - lib/files/staged/gather/components_1.tar.gz
211
+ - schemas/v2/component_2012_11_08.xsd
212
+ - schemas/v2/measure_2013_3_26.xsd
213
+ - schemas/v3/common_bcl_v3.xsd
214
+ - schemas/v3/component_v3.xsd
215
+ - schemas/v3/measure_v3.xsd
197
216
  homepage: http://bcl.nrel.gov
198
217
  licenses:
199
- - LGPL
200
- metadata: {}
218
+ - BSD
219
+ metadata:
220
+ bug_tracker_uri: https://github.com/NREL/bcl-gem/issues
221
+ changelog_uri: https://github.com/NREL/bcl-gem/blob/develop/CHANGELOG.md
222
+ source_code_uri: https://github.com/NREL/bcl-gem/tree/v0.7.1
201
223
  post_install_message:
202
224
  rdoc_options: []
203
225
  require_paths:
204
226
  - lib
205
227
  required_ruby_version: !ruby/object:Gem::Requirement
206
228
  requirements:
207
- - - ">="
229
+ - - "~>"
208
230
  - !ruby/object:Gem::Version
209
- version: 1.9.3
231
+ version: 2.7.0
210
232
  required_rubygems_version: !ruby/object:Gem::Requirement
211
233
  requirements:
212
234
  - - ">="
213
235
  - !ruby/object:Gem::Version
214
236
  version: '0'
215
237
  requirements: []
216
- rubyforge_project:
217
- rubygems_version: 2.4.5.1
238
+ rubygems_version: 3.1.4
218
239
  signing_key:
219
240
  specification_version: 4
220
- summary: Classes for creating component XML files for the BCL
241
+ summary: Classes for creating component XML files and manageing measures for the BCL
221
242
  test_files: []
@@ -1,287 +0,0 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # Converts a custom Excel spreadsheet format to BCL components for upload
21
- # Format of the Excel spreadsheet is documented in /doc/ComponentSpreadsheet.docx
22
-
23
- if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
24
- begin
25
- # apparently this is not a gem (todo: need to remove and replace with roo)
26
- require 'win32ole'
27
- mod = WIN32OLE
28
- $have_win32ole = true
29
- rescue NameError
30
- # do not have win32ole
31
- end
32
- end
33
-
34
- module BCL
35
- class ComponentSpreadsheet
36
- public
37
-
38
- # WINDOWS ONLY SECTION BECAUSE THIS USES WIN32OLE
39
- if $have_win32ole
40
-
41
- # initialize with Excel spreadsheet to read
42
- def initialize(xlsx_path, worksheet_names = ['all'])
43
- @xlsx_path = Pathname.new(xlsx_path).realpath.to_s
44
- @worksheets = []
45
-
46
- begin
47
- excel = WIN32OLE.new('Excel.Application')
48
-
49
- xlsx = excel.Workbooks.Open(@xlsx_path)
50
-
51
- # by default, operate on all worksheets
52
- if worksheet_names == ['all']
53
- xlsx.Worksheets.each do |xlsx_worksheet|
54
- parse_xlsx_worksheet(xlsx_worksheet)
55
- end
56
- else # if specific worksheets are specified, operate on them
57
- worksheet_names.each do |worksheet_name|
58
- parse_xlsx_worksheet(xlsx.Worksheets(worksheet_name))
59
- end
60
- end
61
-
62
- # save spreadsheet if changes have been made
63
- if xlsx.saved == true
64
- # puts "[ComponentSpreadsheet] Spreadsheet unchanged; not saving"
65
- else
66
- xlsx.Save
67
- puts '[ComponentSpreadsheet] Spreadsheet changes saved'
68
- end
69
- ensure
70
- excel.Quit
71
- WIN32OLE.ole_free(excel)
72
- excel.ole_free
73
- xlsx = nil
74
- excel = nil
75
- GC.start
76
- end
77
- end
78
-
79
- else # if $have_win32ole
80
-
81
- # parse the master taxonomy document
82
- def initialize(_xlsx_path)
83
- puts "ComponentSpreadsheet class requires 'win32ole' to parse the component spreadsheet."
84
- puts 'ComponentSpreadsheet may also be stored and loaded from JSON if your platform does not support win32ole.'
85
- end
86
-
87
- end # if $have_win32ole
88
-
89
- def save(save_path, chunk_size = 1000, delete_old_gather = false)
90
- # load master taxonomy to validate components
91
- taxonomy = BCL::MasterTaxonomy.new
92
-
93
- # FileUtils.rm_rf(save_path) if File.exists?(save_path) and File.directory?(save_path)
94
-
95
- @worksheets.each do |worksheet|
96
- worksheet.components.each do |component|
97
- component_xml = Component.new("#{save_path}/components")
98
- component_xml.name = component.name
99
- component_xml.uid = component.uid
100
- component_xml.comp_version_id = component.version_id
101
-
102
- # this tag is how we know where this goes in the taxonomy
103
- component_xml.add_tag(worksheet.name)
104
-
105
- values = component.values[0]
106
- component.headers.each do |header|
107
- if /description/i.match(header.name)
108
-
109
- name = values.delete_at(0)
110
- uid = values.delete_at(0)
111
- version_id = values.delete_at(0)
112
- description = values.delete_at(0)
113
- fidelity_level = values.delete_at(0).to_int
114
- # name, uid, and version_id already processed
115
- component_xml.description = description
116
- component_xml.fidelity_level = fidelity_level
117
-
118
- elsif /provenance/i.match(header.name)
119
-
120
- author = values.delete_at(0)
121
- datetime = values.delete_at(0)
122
- if datetime.nil?
123
- # puts "[ComponentSpreadsheet] WARNING missing the date in the datetime column in the spreadsheet - assuming today"
124
- datetime = DateTime.new
125
- else
126
- datetime = DateTime.parse(datetime)
127
- end
128
-
129
- comment = values.delete_at(0)
130
- component_xml.add_provenance(author.to_s, datetime.to_s, comment.to_s)
131
-
132
- elsif /tag/i.match(header.name)
133
-
134
- value = values.delete_at(0)
135
- component_xml.add_tag(value)
136
-
137
- elsif /attribute/i.match(header.name)
138
-
139
- value = values.delete_at(0)
140
- name = header.children[0]
141
- units = ''
142
- if match_data = /(.*)\((.*)\)/.match(name)
143
- name = match_data[1].strip
144
- units = match_data[2].strip
145
- end
146
- component_xml.add_attribute(name, value, units)
147
-
148
- elsif /source/i.match(header.name)
149
-
150
- manufacturer = values.delete_at(0)
151
- model = values.delete_at(0)
152
- serial_no = values.delete_at(0)
153
- year = values.delete_at(0)
154
- url = values.delete_at(0)
155
- component_xml.source_manufacturer = manufacturer
156
- component_xml.source_model = model
157
- component_xml.source_serial_no = serial_no
158
- component_xml.source_year = year
159
- component_xml.source_url = url
160
-
161
- elsif /file/i.match(header.name)
162
-
163
- software_program = values.delete_at(0)
164
- version = values.delete_at(0)
165
- filename = values.delete_at(0)
166
- filetype = values.delete_at(0)
167
- filepath = values.delete_at(0)
168
- # not all components(rows) have all files; skip if filename "" or nil
169
- next if filename == '' || filename.nil?
170
-
171
- # skip the file if it doesn't exist at the specified location
172
- unless File.exist?(filepath)
173
- puts "[ComponentSpreadsheet] ERROR #{filepath} -> File does not exist, will not be included in component xml"
174
- next # go to the next file
175
- end
176
- component_xml.add_file(software_program, version, filepath, filename, filetype)
177
-
178
- else
179
- raise "Unknown section #{header.name}"
180
-
181
- end
182
- end
183
-
184
- taxonomy.check_component(component_xml)
185
-
186
- component_xml.save_tar_gz(false)
187
- end
188
- end
189
-
190
- BCL.gather_components(save_path, chunk_size, delete_old_gather)
191
- end
192
-
193
- private
194
-
195
- def parse_xlsx_worksheet(xlsx_worksheet)
196
- worksheet = WorksheetStruct.new
197
- worksheet.name = xlsx_worksheet.Range('A1').Value
198
- worksheet.components = []
199
- puts "[ComponentSpreadsheet] Starting parsing components of type #{worksheet.name}"
200
-
201
- # find number of rows, first column should be name, should not be empty
202
- num_rows = 1
203
- loop do
204
- test = xlsx_worksheet.Range("A#{num_rows}").Value
205
- if test.nil? || test.empty?
206
- num_rows -= 1
207
- break
208
- end
209
- num_rows += 1
210
- end
211
-
212
- # scan number of columns
213
- headers = []
214
- header = nil
215
- max_col = nil
216
- xlsx_worksheet.Columns.each do |col|
217
- value1 = col.Rows('1').Value
218
- value2 = col.Rows('2').Value
219
-
220
- if !value1.nil? && !value1.empty?
221
- unless header.nil?
222
- headers << header
223
- end
224
- header = HeaderStruct.new
225
- header.name = value1
226
- header.children = []
227
- end
228
-
229
- if !value2.nil? && !value2.empty?
230
- unless header.nil?
231
- header.children << value2
232
- end
233
- end
234
-
235
- if (value1.nil? || value1.empty?) && (value2.nil? || value2.empty?)
236
- break
237
- end
238
-
239
- matchdata = /^\$(.+):/.match(col.Address)
240
- max_col = matchdata[1]
241
- end
242
-
243
- unless header.nil?
244
- headers << header
245
- end
246
-
247
- unless headers.empty?
248
- headers[0].name = 'description'
249
- end
250
-
251
- puts " Found #{num_rows - 2} components"
252
-
253
- components = []
254
- for i in 3..num_rows do
255
- component = ComponentStruct.new
256
- component.row = i
257
-
258
- # get name
259
- component.name = xlsx_worksheet.Range("A#{i}").value
260
-
261
- # get uid, if empty set it
262
- component.uid = xlsx_worksheet.Range("B#{i}").value
263
- if component.uid.nil? || component.uid.empty?
264
- component.uid = UUID.new.generate
265
- puts "#{component.name} uid missing; creating new one"
266
- xlsx_worksheet.Range("B#{i}").value = component.uid
267
- end
268
-
269
- # get version_id, if empty set it
270
- component.version_id = xlsx_worksheet.Range("C#{i}").value
271
- if component.version_id.nil? || component.version_id.empty?
272
- component.version_id = UUID.new.generate
273
- puts "#{component.name} version id missing; creating new one"
274
- xlsx_worksheet.Range("C#{i}").value = component.version_id
275
- end
276
-
277
- component.headers = headers
278
- component.values = xlsx_worksheet.Range("A#{i}:#{max_col}#{i}").value
279
- worksheet.components << component
280
- end
281
-
282
- @worksheets << worksheet
283
-
284
- puts "[ComponentSpreadsheet] Finished parsing components of type #{worksheet.name}"
285
- end
286
- end
287
- end # module BCL