lib/openstudio/analysis/formulation.rb in openstudio-analysis-1.0.0.rc19 vs lib/openstudio/analysis/formulation.rb in openstudio-analysis-1.0.0
- old
+ new
@@ -1,5 +1,40 @@
+# *******************************************************************************
+# OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC.
+# All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# (1) Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# (2) Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# (3) Neither the name of the copyright holder nor the names of any contributors
+# may be used to endorse or promote products derived from this software without
+# specific prior written permission from the respective party.
+#
+# (4) Other than as required in clauses (1) and (2), distributions in any form
+# of modifications or other derivative works may not use the "OpenStudio"
+# trademark, "OS", "os", or any other confusingly similar designation without
+# specific prior written permission from Alliance for Sustainable Energy, LLC.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
+# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# *******************************************************************************
+
# OpenStudio formulation class handles the generation of the OpenStudio Analysis format.
module OpenStudio
module Analysis
SeedModel = Struct.new(:file)
WeatherFile = Struct.new(:file)
@@ -162,13 +197,13 @@
# silly catch for if weather_file is not set
wf = nil
if @weather_file[:file]
wf = @weather_file
- elsif @weather_files.size > 0
+ elsif !@weather_files.empty?
# get the first EPW file (not the first file)
- wf = @weather_files.find { |w| File.extname(w[:file]).downcase == '.epw' }
+ wf = @weather_files.find { |w| File.extname(w[:file]).casecmp('.epw').zero? }
end
if wf
h[:analysis][:weather_file] = {
file_type: File.extname(wf[:file]).delete('.').upcase,
@@ -347,31 +382,31 @@
puts 'Adding Support Files: Worker Initialization Scripts'
@worker_inits.each_with_index do |f, index|
ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
puts " Adding #{f[:file]} as #{ordered_file_name}"
- zf.add(f[:file].sub(f[:file], "./lib/worker_initialize/#{ordered_file_name}"), f[:file])
+ zf.add(f[:file].sub(f[:file], "./scripts/worker_initialization//#{ordered_file_name}"), f[:file])
if f[:metadata][:args]
arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
file = Tempfile.new('arg')
file.write(f[:metadata][:args])
- zf.add("./lib/worker_initialize/#{arg_file}", file)
+ zf.add("./scripts/worker_initialization/#{arg_file}", file)
file.close
end
end
puts 'Adding Support Files: Worker Finalization Scripts'
@worker_finalizes.each_with_index do |f, index|
ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
puts " Adding #{f[:file]} as #{ordered_file_name}"
- zf.add(f[:file].sub(f[:file], "./lib/worker_finalize/#{ordered_file_name}"), f[:file])
+ zf.add(f[:file].sub(f[:file], "./scripts/worker_finalization/#{ordered_file_name}"), f[:file])
if f[:metadata][:args]
arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
file = Tempfile.new('arg')
file.write(f[:metadata][:args])
- zf.add("./lib/worker_finalize/#{arg_file}", file)
+ zf.add("./scripts/worker_finalization/#{arg_file}", file)
file.close
end
end
## Measures