bcl 0.5.7.pre → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
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.7.pre
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Macumber
@@ -9,184 +9,182 @@ authors:
9
9
  - Andrew Parker
10
10
  - Katherine Fleming
11
11
  autorequire:
12
- bindir: bin
12
+ bindir: exe
13
13
  cert_chain: []
14
- date: 2017-10-10 00:00:00.000000000 Z
14
+ date: 2021-02-15 00:00:00.000000000 Z
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: uuid
18
- requirement: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
16
  - !ruby/object:Gem::Dependency
31
17
  name: builder
32
18
  requirement: !ruby/object:Gem::Requirement
33
19
  requirements:
34
- - - ">="
20
+ - - '='
35
21
  - !ruby/object:Gem::Version
36
- version: '0'
22
+ version: 3.2.4
37
23
  type: :runtime
38
24
  prerelease: false
39
25
  version_requirements: !ruby/object:Gem::Requirement
40
26
  requirements:
41
- - - ">="
27
+ - - '='
42
28
  - !ruby/object:Gem::Version
43
- version: '0'
29
+ version: 3.2.4
44
30
  - !ruby/object:Gem::Dependency
45
- name: zliby
31
+ name: faraday
46
32
  requirement: !ruby/object:Gem::Requirement
47
33
  requirements:
48
- - - ">="
34
+ - - "~>"
49
35
  - !ruby/object:Gem::Version
50
- version: '0'
36
+ version: 1.0.1
51
37
  type: :runtime
52
38
  prerelease: false
53
39
  version_requirements: !ruby/object:Gem::Requirement
54
40
  requirements:
55
- - - ">="
41
+ - - "~>"
56
42
  - !ruby/object:Gem::Version
57
- version: '0'
43
+ version: 1.0.1
58
44
  - !ruby/object:Gem::Dependency
59
- name: archive-tar-minitar
45
+ name: minitar
60
46
  requirement: !ruby/object:Gem::Requirement
61
47
  requirements:
62
- - - ">="
48
+ - - "~>"
63
49
  - !ruby/object:Gem::Version
64
- version: '0'
50
+ version: '0.9'
65
51
  type: :runtime
66
52
  prerelease: false
67
53
  version_requirements: !ruby/object:Gem::Requirement
68
54
  requirements:
69
- - - ">="
55
+ - - "~>"
70
56
  - !ruby/object:Gem::Version
71
- version: '0'
57
+ version: '0.9'
72
58
  - !ruby/object:Gem::Dependency
73
- name: multi_json
59
+ name: openstudio_measure_tester
74
60
  requirement: !ruby/object:Gem::Requirement
75
61
  requirements:
76
- - - ">="
62
+ - - "~>"
77
63
  - !ruby/object:Gem::Version
78
- version: '0'
64
+ version: 0.3.0
79
65
  type: :runtime
80
66
  prerelease: false
81
67
  version_requirements: !ruby/object:Gem::Requirement
82
68
  requirements:
83
- - - ">="
69
+ - - "~>"
84
70
  - !ruby/object:Gem::Version
85
- version: '0'
71
+ version: 0.3.0
86
72
  - !ruby/object:Gem::Dependency
87
- name: yamler
73
+ name: rexml
88
74
  requirement: !ruby/object:Gem::Requirement
89
75
  requirements:
90
- - - ">="
76
+ - - '='
91
77
  - !ruby/object:Gem::Version
92
- version: '0'
78
+ version: 3.2.4
93
79
  type: :runtime
94
80
  prerelease: false
95
81
  version_requirements: !ruby/object:Gem::Requirement
96
82
  requirements:
97
- - - ">="
83
+ - - '='
98
84
  - !ruby/object:Gem::Version
99
- version: '0'
85
+ version: 3.2.4
100
86
  - !ruby/object:Gem::Dependency
101
- name: faraday
87
+ name: rubyzip
102
88
  requirement: !ruby/object:Gem::Requirement
103
89
  requirements:
104
- - - ">="
90
+ - - "~>"
105
91
  - !ruby/object:Gem::Version
106
- version: '0'
92
+ version: 2.3.0
107
93
  type: :runtime
108
94
  prerelease: false
109
95
  version_requirements: !ruby/object:Gem::Requirement
110
96
  requirements:
111
- - - ">="
97
+ - - "~>"
112
98
  - !ruby/object:Gem::Version
113
- version: '0'
99
+ version: 2.3.0
114
100
  - !ruby/object:Gem::Dependency
115
- name: roo
101
+ name: spreadsheet
116
102
  requirement: !ruby/object:Gem::Requirement
117
103
  requirements:
118
- - - ">="
104
+ - - '='
119
105
  - !ruby/object:Gem::Version
120
- version: '0'
106
+ version: 1.2.6
121
107
  type: :runtime
122
108
  prerelease: false
123
109
  version_requirements: !ruby/object:Gem::Requirement
124
110
  requirements:
125
- - - ">="
111
+ - - '='
126
112
  - !ruby/object:Gem::Version
127
- version: '0'
113
+ version: 1.2.6
128
114
  - !ruby/object:Gem::Dependency
129
- name: nokogiri
115
+ name: uuid
130
116
  requirement: !ruby/object:Gem::Requirement
131
117
  requirements:
132
- - - ">="
118
+ - - "~>"
133
119
  - !ruby/object:Gem::Version
134
- version: '0'
120
+ version: 2.3.9
135
121
  type: :runtime
136
122
  prerelease: false
137
123
  version_requirements: !ruby/object:Gem::Requirement
138
124
  requirements:
139
- - - ">="
125
+ - - "~>"
140
126
  - !ruby/object:Gem::Version
141
- version: '0'
127
+ version: 2.3.9
142
128
  - !ruby/object:Gem::Dependency
143
- name: rubyzip
129
+ name: yamler
144
130
  requirement: !ruby/object:Gem::Requirement
145
131
  requirements:
146
- - - ">="
132
+ - - '='
147
133
  - !ruby/object:Gem::Version
148
- version: '0'
134
+ version: 0.1.0
149
135
  type: :runtime
150
136
  prerelease: false
151
137
  version_requirements: !ruby/object:Gem::Requirement
152
138
  requirements:
153
- - - ">="
139
+ - - '='
154
140
  - !ruby/object:Gem::Version
155
- version: '0'
141
+ version: 0.1.0
156
142
  - !ruby/object:Gem::Dependency
157
- name: rubyXL
143
+ name: zliby
158
144
  requirement: !ruby/object:Gem::Requirement
159
145
  requirements:
160
- - - ">="
146
+ - - '='
161
147
  - !ruby/object:Gem::Version
162
- version: '0'
148
+ version: 0.0.5
163
149
  type: :runtime
164
150
  prerelease: false
165
151
  version_requirements: !ruby/object:Gem::Requirement
166
152
  requirements:
167
- - - ">="
153
+ - - '='
168
154
  - !ruby/object:Gem::Version
169
- version: '0'
155
+ version: 0.0.5
170
156
  description: This gem contains helper methods for generating the Component XML file
171
157
  needed to upload files to the Building Component Library. It also contains the classes
172
- needed for logging in via the api and uploading generating components
158
+ needed for logging in via the api and uploading generating components and measures.
173
159
  email: Nicholas.Long@nrel.gov
174
160
  executables: []
175
161
  extensions: []
176
162
  extra_rdoc_files: []
177
163
  files:
164
+ - ".gitignore"
165
+ - ".rubocop.yml"
166
+ - CHANGELOG.md
167
+ - Gemfile
168
+ - License.txt
169
+ - README.md
170
+ - Rakefile
171
+ - bcl.gemspec
178
172
  - lib/bcl.rb
179
173
  - lib/bcl/base_xml.rb
180
174
  - lib/bcl/component.rb
181
175
  - lib/bcl/component_from_spreadsheet.rb
182
176
  - lib/bcl/component_methods.rb
183
- - lib/bcl/component_spreadsheet.rb
184
177
  - lib/bcl/core_ext.rb
185
178
  - lib/bcl/current_taxonomy.json
186
179
  - lib/bcl/current_taxonomy.xml
187
- - lib/bcl/master_taxonomy.rb
188
180
  - lib/bcl/tar_ball.rb
189
181
  - lib/bcl/version.rb
182
+ - lib/files/Components.xls
183
+ - schemas/v2/component_2012_11_08.xsd
184
+ - schemas/v2/measure_2013_3_26.xsd
185
+ - schemas/v3/common_bcl_v3.xsd
186
+ - schemas/v3/component_v3.xsd
187
+ - schemas/v3/measure_v3.xsd
190
188
  homepage: http://bcl.nrel.gov
191
189
  licenses:
192
190
  - LGPL
@@ -197,18 +195,17 @@ require_paths:
197
195
  - lib
198
196
  required_ruby_version: !ruby/object:Gem::Requirement
199
197
  requirements:
200
- - - ">="
198
+ - - "~>"
201
199
  - !ruby/object:Gem::Version
202
- version: 1.9.3
200
+ version: 2.7.0
203
201
  required_rubygems_version: !ruby/object:Gem::Requirement
204
202
  requirements:
205
- - - ">"
203
+ - - ">="
206
204
  - !ruby/object:Gem::Version
207
- version: 1.3.1
205
+ version: '0'
208
206
  requirements: []
209
- rubyforge_project:
210
- rubygems_version: 2.4.5
207
+ rubygems_version: 3.1.4
211
208
  signing_key:
212
209
  specification_version: 4
213
- summary: Classes for creating component XML files for the BCL
210
+ summary: Classes for creating component XML files and manageing measures for the BCL
214
211
  test_files: []
@@ -1,290 +0,0 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, 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
-
48
- excel = WIN32OLE.new('Excel.Application')
49
-
50
- xlsx = excel.Workbooks.Open(@xlsx_path)
51
-
52
- # by default, operate on all worksheets
53
- if worksheet_names == ['all']
54
- xlsx.Worksheets.each do |xlsx_worksheet|
55
- parse_xlsx_worksheet(xlsx_worksheet)
56
- end
57
- else # if specific worksheets are specified, operate on them
58
- worksheet_names.each do |worksheet_name|
59
- parse_xlsx_worksheet(xlsx.Worksheets(worksheet_name))
60
- end
61
- end
62
-
63
- # save spreadsheet if changes have been made
64
- if xlsx.saved == true
65
- # puts "[ComponentSpreadsheet] Spreadsheet unchanged; not saving"
66
- else
67
- xlsx.Save
68
- puts '[ComponentSpreadsheet] Spreadsheet changes saved'
69
- end
70
-
71
- ensure
72
-
73
- excel.Quit
74
- WIN32OLE.ole_free(excel)
75
- excel.ole_free
76
- xlsx = nil
77
- excel = nil
78
- GC.start
79
-
80
- end
81
- end
82
-
83
- else # if $have_win32ole
84
-
85
- # parse the master taxonomy document
86
- def initialize(_xlsx_path)
87
- puts "ComponentSpreadsheet class requires 'win32ole' to parse the component spreadsheet."
88
- puts 'ComponentSpreadsheet may also be stored and loaded from JSON if your platform does not support win32ole.'
89
- end
90
-
91
- end # if $have_win32ole
92
-
93
- def save(save_path, chunk_size = 1000, delete_old_gather = false)
94
- # load master taxonomy to validate components
95
- taxonomy = BCL::MasterTaxonomy.new
96
-
97
- # FileUtils.rm_rf(save_path) if File.exists?(save_path) and File.directory?(save_path)
98
-
99
- @worksheets.each do |worksheet|
100
- worksheet.components.each do |component|
101
- component_xml = Component.new("#{save_path}/components")
102
- component_xml.name = component.name
103
- component_xml.uid = component.uid
104
- component_xml.comp_version_id = component.version_id
105
-
106
- # this tag is how we know where this goes in the taxonomy
107
- component_xml.add_tag(worksheet.name)
108
-
109
- values = component.values[0]
110
- component.headers.each do |header|
111
- if /description/i.match(header.name)
112
-
113
- name = values.delete_at(0)
114
- uid = values.delete_at(0)
115
- version_id = values.delete_at(0)
116
- description = values.delete_at(0)
117
- fidelity_level = values.delete_at(0).to_int
118
- # name, uid, and version_id already processed
119
- component_xml.description = description
120
- component_xml.fidelity_level = fidelity_level
121
-
122
- elsif /provenance/i.match(header.name)
123
-
124
- author = values.delete_at(0)
125
- datetime = values.delete_at(0)
126
- if datetime.nil?
127
- # puts "[ComponentSpreadsheet] WARNING missing the date in the datetime column in the spreadsheet - assuming today"
128
- datetime = DateTime.new
129
- else
130
- datetime = DateTime.parse(datetime)
131
- end
132
-
133
- comment = values.delete_at(0)
134
- component_xml.add_provenance(author.to_s, datetime.to_s, comment.to_s)
135
-
136
- elsif /tag/i.match(header.name)
137
-
138
- value = values.delete_at(0)
139
- component_xml.add_tag(value)
140
-
141
- elsif /attribute/i.match(header.name)
142
-
143
- value = values.delete_at(0)
144
- name = header.children[0]
145
- units = ''
146
- if match_data = /(.*)\((.*)\)/.match(name)
147
- name = match_data[1].strip
148
- units = match_data[2].strip
149
- end
150
- component_xml.add_attribute(name, value, units)
151
-
152
- elsif /source/i.match(header.name)
153
-
154
- manufacturer = values.delete_at(0)
155
- model = values.delete_at(0)
156
- serial_no = values.delete_at(0)
157
- year = values.delete_at(0)
158
- url = values.delete_at(0)
159
- component_xml.source_manufacturer = manufacturer
160
- component_xml.source_model = model
161
- component_xml.source_serial_no = serial_no
162
- component_xml.source_year = year
163
- component_xml.source_url = url
164
-
165
- elsif /file/i.match(header.name)
166
-
167
- software_program = values.delete_at(0)
168
- version = values.delete_at(0)
169
- filename = values.delete_at(0)
170
- filetype = values.delete_at(0)
171
- filepath = values.delete_at(0)
172
- # not all components(rows) have all files; skip if filename "" or nil
173
- next if filename == '' || filename.nil?
174
- # skip the file if it doesn't exist at the specified location
175
- unless File.exist?(filepath)
176
- puts "[ComponentSpreadsheet] ERROR #{filepath} -> File does not exist, will not be included in component xml"
177
- next # go to the next file
178
- end
179
- component_xml.add_file(software_program, version, filepath, filename, filetype)
180
-
181
- else
182
- fail "Unknown section #{header.name}"
183
-
184
- end
185
- end
186
-
187
- taxonomy.check_component(component_xml)
188
-
189
- component_xml.save_tar_gz(false)
190
- end
191
- end
192
-
193
- BCL.gather_components(save_path, chunk_size, delete_old_gather)
194
- end
195
-
196
- private
197
-
198
- def parse_xlsx_worksheet(xlsx_worksheet)
199
- worksheet = WorksheetStruct.new
200
- worksheet.name = xlsx_worksheet.Range('A1').Value
201
- worksheet.components = []
202
- puts "[ComponentSpreadsheet] Starting parsing components of type #{worksheet.name}"
203
-
204
- # find number of rows, first column should be name, should not be empty
205
- num_rows = 1
206
- loop do
207
- test = xlsx_worksheet.Range("A#{num_rows}").Value
208
- if test.nil? || test.empty?
209
- num_rows -= 1
210
- break
211
- end
212
- num_rows += 1
213
- end
214
-
215
- # scan number of columns
216
- headers = []
217
- header = nil
218
- max_col = nil
219
- xlsx_worksheet.Columns.each do |col|
220
- value1 = col.Rows('1').Value
221
- value2 = col.Rows('2').Value
222
-
223
- if !value1.nil? && !value1.empty?
224
- unless header.nil?
225
- headers << header
226
- end
227
- header = HeaderStruct.new
228
- header.name = value1
229
- header.children = []
230
- end
231
-
232
- if !value2.nil? && !value2.empty?
233
- unless header.nil?
234
- header.children << value2
235
- end
236
- end
237
-
238
- if (value1.nil? || value1.empty?) && (value2.nil? || value2.empty?)
239
- break
240
- end
241
-
242
- matchdata = /^\$(.+):/.match(col.Address)
243
- max_col = matchdata[1]
244
- end
245
-
246
- unless header.nil?
247
- headers << header
248
- end
249
-
250
- unless headers.empty?
251
- headers[0].name = 'description'
252
- end
253
-
254
- puts " Found #{num_rows - 2} components"
255
-
256
- components = []
257
- for i in 3..num_rows do
258
- component = ComponentStruct.new
259
- component.row = i
260
-
261
- # get name
262
- component.name = xlsx_worksheet.Range("A#{i}").value
263
-
264
- # get uid, if empty set it
265
- component.uid = xlsx_worksheet.Range("B#{i}").value
266
- if component.uid.nil? || component.uid.empty?
267
- component.uid = UUID.new.generate
268
- puts "#{component.name} uid missing; creating new one"
269
- xlsx_worksheet.Range("B#{i}").value = component.uid
270
- end
271
-
272
- # get version_id, if empty set it
273
- component.version_id = xlsx_worksheet.Range("C#{i}").value
274
- if component.version_id.nil? || component.version_id.empty?
275
- component.version_id = UUID.new.generate
276
- puts "#{component.name} version id missing; creating new one"
277
- xlsx_worksheet.Range("C#{i}").value = component.version_id
278
- end
279
-
280
- component.headers = headers
281
- component.values = xlsx_worksheet.Range("A#{i}:#{max_col}#{i}").value
282
- worksheet.components << component
283
- end
284
-
285
- @worksheets << worksheet
286
-
287
- puts "[ComponentSpreadsheet] Finished parsing components of type #{worksheet.name}"
288
- end
289
- end
290
- end # module BCL