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
data/bcl.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'bcl/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bcl'
7
+ spec.version = BCL::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ['Daniel Macumber', 'Nicholas Long', 'Andrew Parker', 'Katherine Fleming']
10
+ spec.email = 'Nicholas.Long@nrel.gov'
11
+
12
+ spec.homepage = 'http://bcl.nrel.gov'
13
+ spec.summary = 'Classes for creating component XML files and manageing measures for the BCL'
14
+ spec.description = 'This gem contains helper methods for generating the Component XML file needed to upload files to the Building Component Library. It also contains the classes needed for logging in via the api and uploading generating components and measures.'
15
+ spec.license = 'BSD'
16
+ spec.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/NREL/bcl-gem/issues',
18
+ 'changelog_uri' => 'https://github.com/NREL/bcl-gem/blob/develop/CHANGELOG.md',
19
+ # 'documentation_uri' => 'https://www.rubydoc.info/gems/openstudio-extension-gem/#{gem.version}',
20
+ 'source_code_uri' => "https://github.com/NREL/bcl-gem/tree/v#{spec.version}"
21
+ }
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.required_ruby_version = '~> 2.7.0'
31
+
32
+ spec.add_dependency 'builder', '3.2.4'
33
+ spec.add_dependency 'faraday', '~> 1.0.1'
34
+ spec.add_dependency 'minitar', '~> 0.9'
35
+
36
+ # Measure tester is not used in this project, but this will force dependencies to match versions
37
+ # requested by OpenStudio. This includes dependencies for running tests/CI
38
+ spec.add_dependency 'openstudio_measure_tester', '~> 0.3.1'
39
+ spec.add_dependency 'rexml', '3.2.5'
40
+ spec.add_dependency 'rubyzip', '~> 2.3.2'
41
+ spec.add_dependency 'spreadsheet', '1.2.9'
42
+ spec.add_dependency 'uuid', '~> 2.3.9'
43
+ spec.add_dependency 'yamler', '0.1.0'
44
+ spec.add_dependency 'zliby', '0.0.5'
45
+
46
+ spec.add_development_dependency 'rake', '~> 13.0'
47
+ spec.add_development_dependency 'rspec', '~> 3.9'
48
+ end
data/lib/bcl/base_xml.rb CHANGED
@@ -1,21 +1,37 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
- # All rights reserved.
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
4
6
  #
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.
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
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.
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
14
13
  #
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
- ######################################################################
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
19
35
 
20
36
  # KAF 2/13/2018
21
37
  # This functionality is being kept in case we need in to recreate weather files in the future
data/lib/bcl/component.rb CHANGED
@@ -1,21 +1,37 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
- # All rights reserved.
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
4
6
  #
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.
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
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.
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
14
13
  #
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
- ######################################################################
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
19
35
 
20
36
  # Provides programmatic access to the component.xsd schema needed for
21
37
  # generating the component information that will be uploaded to
@@ -384,4 +400,4 @@ module BCL
384
400
  xmlfile.close
385
401
  end
386
402
  end
387
- end # module BCL
403
+ end
@@ -1,21 +1,37 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
- # All rights reserved.
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
4
6
  #
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.
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
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.
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
14
13
  #
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
- ######################################################################
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
19
35
 
20
36
  # Converts a custom Excel spreadsheet format to BCL components for upload
21
37
 
@@ -30,8 +46,6 @@ module BCL
30
46
  class ComponentFromSpreadsheet
31
47
  @@changed = false
32
48
 
33
- public
34
-
35
49
  # initialize with Excel spreadsheet to read
36
50
  # seems to only be working with xls spreadsheets
37
51
  def initialize(xlsx_path, worksheet_names = ['all'])
@@ -80,14 +94,14 @@ module BCL
80
94
 
81
95
  puts " headers: #{component.headers}"
82
96
  component.headers.each do |header|
83
- if /description/i.match(header.name)
97
+ if /description/i.match?(header.name)
84
98
  name = values.delete_at(0) # name, uid already processed
85
99
  uid = values.delete_at(0)
86
100
  component_xml.comp_version_id = values.delete_at(0)
87
101
  description = values.delete_at(0)
88
102
  component_xml.modeler_description = values.delete_at(0)
89
103
  component_xml.description = description
90
- elsif /provenance/i.match(header.name)
104
+ elsif /provenance/i.match?(header.name)
91
105
  author = values.delete_at(0)
92
106
  datetime = values.delete_at(0)
93
107
  if datetime.nil?
@@ -97,10 +111,10 @@ module BCL
97
111
 
98
112
  comment = values.delete_at(0)
99
113
  component_xml.add_provenance(author.to_s, datetime.strftime('%Y-%m-%d'), comment.to_s)
100
- elsif /tag/i.match(header.name)
114
+ elsif /tag/i.match?(header.name)
101
115
  value = values.delete_at(0)
102
116
  component_xml.add_tag(value)
103
- elsif /attribute/i.match(header.name)
117
+ elsif /attribute/i.match?(header.name)
104
118
  value = values.delete_at(0)
105
119
  name = header.children[0]
106
120
  units = ''
@@ -109,7 +123,7 @@ module BCL
109
123
  units = match_data[2].strip
110
124
  end
111
125
  component_xml.add_attribute(name, value, units)
112
- elsif /source/i.match(header.name)
126
+ elsif /source/i.match?(header.name)
113
127
  manufacturer = values.delete_at(0)
114
128
  model = values.delete_at(0)
115
129
  serial_no = values.delete_at(0)
@@ -120,7 +134,7 @@ module BCL
120
134
  component_xml.source_serial_no = serial_no
121
135
  component_xml.source_year = year
122
136
  component_xml.source_url = url
123
- elsif /file/i.match(header.name)
137
+ elsif /file/i.match?(header.name)
124
138
  software_program = values.delete_at(0)
125
139
  version = values.delete_at(0)
126
140
  filename = values.delete_at(0)
@@ -1,21 +1,37 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2019, Alliance for Sustainable Energy.
3
- # All rights reserved.
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
4
6
  #
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.
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
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.
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
14
13
  #
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
- ######################################################################
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
19
35
 
20
36
  module BCL
21
37
  class ComponentMethods
@@ -93,13 +109,13 @@ module BCL
93
109
  bni = ''
94
110
  junkout = res['set-cookie'].split(';')
95
111
  junkout.each do |line|
96
- if line =~ /BNES_SESS/
112
+ if line.match?(/BNES_SESS/)
97
113
  bnes = line.match(/(BNES_SESS.*)/)[0]
98
114
  end
99
115
  end
100
116
 
101
117
  junkout.each do |line|
102
- if line =~ /BNI/
118
+ if line.match?(/BNI/)
103
119
  bni = line.match(/(BNI.*)/)[0]
104
120
  end
105
121
  end
@@ -107,7 +123,7 @@ module BCL
107
123
  # puts "DATA: #{data}"
108
124
  session_name = ''
109
125
  sessid = ''
110
- json = MultiJson.load(res.body)
126
+ json = JSON.parse(res.body)
111
127
  json.each do |key, val|
112
128
  if key == 'session_name'
113
129
  session_name = val
@@ -184,7 +200,7 @@ module BCL
184
200
  valid = false
185
201
  else
186
202
  puts ' 200 - Successful Upload'
187
- result = MultiJson.load api_response.body
203
+ result = JSON.parse api_response.body
188
204
  valid = true
189
205
  end
190
206
  when '404'
@@ -192,12 +208,12 @@ module BCL
192
208
  puts ' - check these common causes first:'
193
209
  puts " - you are trying to update content that doesn't exist"
194
210
  puts " - you are not an 'administrator member' of the group you're trying to upload to"
195
- result = MultiJson.load api_response.body
211
+ result = JSON.parse api_response.body
196
212
  valid = false
197
213
  when '406'
198
214
  puts " Error Code: #{api_response.code}"
199
215
  # try to parse the response a bit
200
- error = MultiJson.load api_response.body
216
+ error = JSON.parse api_response.body
201
217
  puts "temp error: #{error}"
202
218
  if error.key?('form_errors')
203
219
  if error['form_errors'].key?('field_tar_file')
@@ -267,7 +283,7 @@ module BCL
267
283
  path = '/api/content.json'
268
284
  headers = { 'Content-Type' => 'application/json', 'X-CSRF-Token' => @access_token, 'Cookie' => @session }
269
285
 
270
- res = @http.post(path, MultiJson.dump(data), headers)
286
+ res = @http.post(path, JSON.dump(data), headers)
271
287
 
272
288
  valid, json = evaluate_api_response(res)
273
289
 
@@ -293,13 +309,13 @@ module BCL
293
309
  version_id = nil
294
310
  if uuid.nil?
295
311
  puts File.extname(filename_and_path).downcase
296
- if filename_and_path =~ /^.*.tar.gz$/i
312
+ if filename_and_path.match?(/^.*.tar.gz$/i)
297
313
  uuid, version_id = uuid_vid_from_tarball(filename_and_path)
298
314
  puts "Parsed uuid out of tar.gz file with value #{uuid}"
299
315
  end
300
316
  else
301
317
  # verify the uuid via regex
302
- unless uuid =~ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
318
+ unless uuid.match?(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
303
319
  raise "uuid of #{uuid} is invalid"
304
320
  end
305
321
  end
@@ -310,7 +326,7 @@ module BCL
310
326
  path = '/api/content.json'
311
327
  headers = { 'Content-Type' => 'application/json', 'X-CSRF-Token' => @access_token, 'Cookie' => @session }
312
328
 
313
- res = @http.post(path, MultiJson.dump(data), headers)
329
+ res = @http.post(path, JSON.dump(data), headers)
314
330
 
315
331
  valid, json = evaluate_api_response(res)
316
332
 
@@ -362,7 +378,7 @@ module BCL
362
378
  xml_file = REXML::Document.new entry.read
363
379
 
364
380
  # pull out some information
365
- if entry.name =~ /component/
381
+ if entry.name.match?(/component/)
366
382
  u = xml_file.elements['component/uid']
367
383
  v = xml_file.elements['component/version_id']
368
384
  else
@@ -392,7 +408,7 @@ module BCL
392
408
  xml_to_parse = File.new(path_to_xml)
393
409
  xml_file = REXML::Document.new xml_to_parse
394
410
 
395
- if path_to_xml.to_s.split('/').last =~ /component.xml/
411
+ if path_to_xml.to_s.split('/').last.match?(/component.xml/)
396
412
  u = xml_file.elements['component/uid']
397
413
  v = xml_file.elements['component/version_id']
398
414
  else
@@ -432,7 +448,7 @@ module BCL
432
448
  end
433
449
 
434
450
  def search_by_uuid(uuid, vid = nil)
435
- full_url = '/api/search/*.json'
451
+ full_url = '/api/search.json'
436
452
  action = nil
437
453
 
438
454
  # add api_version
@@ -443,10 +459,9 @@ module BCL
443
459
 
444
460
  # uuid
445
461
  full_url += "&fq[]=ss_uuid:#{uuid}"
446
- # puts "search url: #{full_url}"
447
462
 
448
463
  res = @http.get(full_url)
449
- res = MultiJson.load(res.body)
464
+ res = JSON.parse res.body
450
465
 
451
466
  if res['result'].count > 0
452
467
  # found content, check version
@@ -514,7 +529,7 @@ module BCL
514
529
  puts "search url: #{full_url}"
515
530
  res = @http.get(full_url)
516
531
  # return unparsed
517
- MultiJson.load(res.body, symbolize_keys: true)
532
+ JSON.parse res.body, symbolize_names: true
518
533
  else
519
534
  # iterate over result pages
520
535
  # modify filter_str for show_rows=200 for maximum returns
@@ -535,11 +550,11 @@ module BCL
535
550
  puts "search url: #{full_url_all}"
536
551
  response = @http.get(full_url_all)
537
552
  # parse here so you can build results array
538
- res = MultiJson.load(response.body)
553
+ res = JSON.parse response.body, symbolize_names: true
539
554
 
540
- if res['result'].count > 0
555
+ if res[:result].count > 0
541
556
  pagecnt += 1
542
- res['result'].each do |r|
557
+ res[:result].each do |r|
543
558
  results << r
544
559
  end
545
560
  else
@@ -547,8 +562,7 @@ module BCL
547
562
  end
548
563
  end
549
564
  # return unparsed b/c that is what is expected
550
- formatted_results = { 'result' => results }
551
- results_to_return = MultiJson.load(MultiJson.dump(formatted_results), symbolize_keys: true)
565
+ return { result: results }
552
566
  end
553
567
  end
554
568
 
@@ -620,7 +634,7 @@ module BCL
620
634
 
621
635
  settings
622
636
  end
623
- end # class ComponentMethods
637
+ end
624
638
 
625
639
  # TODO: make this extend the component_xml class (or create a super class around components)
626
640
 
@@ -682,4 +696,4 @@ module BCL
682
696
 
683
697
  Dir.chdir(current_dir)
684
698
  end
685
- end # module BCL
699
+ end