openstudio-analysis 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/openstudio-analysis.yml +40 -40
- data/.gitignore +21 -21
- data/.rubocop.yml +9 -9
- data/CHANGELOG.md +269 -265
- data/Gemfile +14 -14
- data/README.md +102 -102
- data/Rakefile +40 -40
- data/lib/openstudio/analysis/algorithm_attributes.rb +47 -47
- data/lib/openstudio/analysis/formulation.rb +857 -857
- data/lib/openstudio/analysis/server_api.rb +862 -862
- data/lib/openstudio/analysis/server_scripts.rb +108 -108
- data/lib/openstudio/analysis/support_files.rb +104 -104
- data/lib/openstudio/analysis/translator/datapoints.rb +454 -454
- data/lib/openstudio/analysis/translator/excel.rb +893 -893
- data/lib/openstudio/analysis/translator/workflow.rb +143 -143
- data/lib/openstudio/analysis/version.rb +12 -12
- data/lib/openstudio/analysis/workflow.rb +279 -279
- data/lib/openstudio/analysis/workflow_step.rb +523 -523
- data/lib/openstudio/analysis.rb +144 -144
- data/lib/openstudio/helpers/hash.rb +10 -10
- data/lib/openstudio/helpers/string.rb +36 -36
- data/lib/openstudio/helpers/utils.rb +36 -36
- data/lib/openstudio/weather/epw.rb +178 -178
- data/lib/openstudio-analysis.rb +47 -47
- data/openstudio-analysis.gemspec +38 -38
- data/update_license.rb +60 -60
- metadata +9 -9
@@ -1,178 +1,178 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
module OpenStudio
|
7
|
-
module Weather
|
8
|
-
class Epw
|
9
|
-
attr_accessor :filename
|
10
|
-
attr_reader :city
|
11
|
-
attr_reader :state
|
12
|
-
attr_reader :country
|
13
|
-
attr_accessor :data_type
|
14
|
-
attr_reader :wmo
|
15
|
-
attr_reader :lat
|
16
|
-
attr_reader :lon
|
17
|
-
attr_reader :gmt
|
18
|
-
attr_reader :elevation
|
19
|
-
attr_accessor :data_period
|
20
|
-
|
21
|
-
# access to all the weather data in array of arrays
|
22
|
-
attr_reader :header_data
|
23
|
-
attr_accessor :weather_data
|
24
|
-
|
25
|
-
def initialize(filename)
|
26
|
-
@filename = filename
|
27
|
-
@city = ''
|
28
|
-
@state = ''
|
29
|
-
@country = ''
|
30
|
-
@data_type = ''
|
31
|
-
@wmo = ''
|
32
|
-
@lat = ''
|
33
|
-
@lon = ''
|
34
|
-
@gmt = ''
|
35
|
-
@elevation = ''
|
36
|
-
@valid = false
|
37
|
-
|
38
|
-
@header_data = []
|
39
|
-
@weather_data = []
|
40
|
-
process_header
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.load(filename)
|
44
|
-
raise "EPW file does not exist: #{filename}" unless File.exist?(filename)
|
45
|
-
f = OpenStudio::Weather::Epw.new(filename)
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_kml(xml_builder_obj, url)
|
49
|
-
xml_builder_obj.Placemark do
|
50
|
-
xml_builder_obj.name @city
|
51
|
-
xml_builder_obj.visibility '0'
|
52
|
-
xml_builder_obj.description do
|
53
|
-
xml_builder_obj.cdata!('<img src="kml/ep_header8.png" width=180 align=right><br><table><tr><td colspan="2">'\
|
54
|
-
"<b>#{@city}</b></href></td></tr>\n" +
|
55
|
-
# "<tr><td></td><td><b>Data Type</td></tr>\n"+
|
56
|
-
"<tr><td></td><td>WMO <b>#{@wmo}</b></td></tr>\n" +
|
57
|
-
# "<tr><td></td><td>E 3� 15' N 36� 43'</td></tr>\n"+
|
58
|
-
# "<tr><td></td><td><b>25</b> m</td></tr>\n"+
|
59
|
-
"<tr><td></td><td>Time Zone GMT <b>#{@gmt}</b> hours</td></tr>\n" +
|
60
|
-
# "<tr><td></td><td>ASHRAE Std 169 Climate Zone <b>4A - Mixed - Humid</b></td></tr>\n"+
|
61
|
-
# "<tr><td></td><td>99% Heating DB=<b>3.1</b>, 1% Cooling DB=<b>33.2</b></td></tr>\n"+
|
62
|
-
# "<tr><td></td><td>HDD18 <b>1019</b>, CDD10 <b>2849</b></td></tr>\n"+
|
63
|
-
"<tr><td></td><td>URL #{url}</td></tr></table>")
|
64
|
-
end
|
65
|
-
xml_builder_obj.styleUrl '#weatherlocation'
|
66
|
-
xml_builder_obj.Point do
|
67
|
-
xml_builder_obj.altitudeMode 'absolute'
|
68
|
-
xml_builder_obj.coordinates "#{@lon},#{@lat},#{elevation}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def valid?
|
74
|
-
return @valid
|
75
|
-
end
|
76
|
-
|
77
|
-
def save_as(filename)
|
78
|
-
File.delete filename if File.exist? filename
|
79
|
-
FileUtils.mkdir_p(File.dirname(filename)) unless Dir.exist?(File.dirname(filename))
|
80
|
-
|
81
|
-
CSV.open(filename, 'wb') do |csv|
|
82
|
-
@header_data.each { |r| csv << r }
|
83
|
-
csv << [
|
84
|
-
'DATA PERIODS', @data_period[:count], @data_period[:records_per_hour], @data_period[:name],
|
85
|
-
@data_period[:start_day_of_week], @data_period[:start_date], @data_period[:end_date]
|
86
|
-
]
|
87
|
-
@weather_data.each { |r| csv << r }
|
88
|
-
end
|
89
|
-
|
90
|
-
true
|
91
|
-
end
|
92
|
-
|
93
|
-
# Append the weather data (after data periods) to the end of the weather file. This allows
|
94
|
-
# for the creation of multiyear weather files. Note that the date/order is not checked. It assumes
|
95
|
-
# that the data are being added at the end is the more recent data
|
96
|
-
#
|
97
|
-
# @param filename [String] Path to the file that will be appended
|
98
|
-
def append_weather_data(filename)
|
99
|
-
to_append = OpenStudio::Weather::Epw.load(filename)
|
100
|
-
|
101
|
-
prev_length = @weather_data.size
|
102
|
-
@weather_data += to_append.weather_data
|
103
|
-
|
104
|
-
prev_length + to_append.weather_data.size == @weather_data.size
|
105
|
-
end
|
106
|
-
|
107
|
-
def metadata_to_hash
|
108
|
-
{
|
109
|
-
city: @city,
|
110
|
-
state: @state,
|
111
|
-
country: @country,
|
112
|
-
data_type: @data_type,
|
113
|
-
wmo: @wmo,
|
114
|
-
latitude: @lat,
|
115
|
-
longitude: @lon,
|
116
|
-
elevation: @elevation
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
# initialize
|
123
|
-
def process_header
|
124
|
-
header_section = true
|
125
|
-
row_count = 0
|
126
|
-
|
127
|
-
CSV.foreach(@filename) do |row|
|
128
|
-
row_count += 1
|
129
|
-
|
130
|
-
if header_section
|
131
|
-
if row[0] =~ /data.periods/i
|
132
|
-
@data_period = {
|
133
|
-
count: row[1].to_i,
|
134
|
-
records_per_hour: row[2].to_i,
|
135
|
-
name: row[3],
|
136
|
-
start_day_of_week: row[4],
|
137
|
-
start_date: row[5],
|
138
|
-
end_date: row[6]
|
139
|
-
}
|
140
|
-
|
141
|
-
header_section = false
|
142
|
-
|
143
|
-
next
|
144
|
-
else
|
145
|
-
@header_data << row
|
146
|
-
end
|
147
|
-
else
|
148
|
-
@weather_data << row
|
149
|
-
end
|
150
|
-
|
151
|
-
# process only header row
|
152
|
-
# LOCATION,Adak Nas,AK,USA,TMY3,704540,51.88,-176.65,-10.0,5.0
|
153
|
-
if row_count == 1
|
154
|
-
@valid = true
|
155
|
-
|
156
|
-
@city = row[1].tr('/', '-')
|
157
|
-
@state = row[2]
|
158
|
-
@country = row[3]
|
159
|
-
@data_type = row[4]
|
160
|
-
if @data_type =~ /TMY3/i
|
161
|
-
@data_type = 'TMY3'
|
162
|
-
elsif @data_type =~ /TMY2/i
|
163
|
-
@data_type = 'TMY2'
|
164
|
-
elsif @data_type =~ /TMY/i
|
165
|
-
@data_type = 'TMY'
|
166
|
-
end
|
167
|
-
@wmo = row[5]
|
168
|
-
@wmo.nil? ? @wmo = 'wmoundefined' : @wmo = @wmo.to_i
|
169
|
-
@lat = row[6].to_f
|
170
|
-
@lon = row[7].to_f
|
171
|
-
@gmt = row[8].to_f
|
172
|
-
@elevation = row[9].to_f
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
module OpenStudio
|
7
|
+
module Weather
|
8
|
+
class Epw
|
9
|
+
attr_accessor :filename
|
10
|
+
attr_reader :city
|
11
|
+
attr_reader :state
|
12
|
+
attr_reader :country
|
13
|
+
attr_accessor :data_type
|
14
|
+
attr_reader :wmo
|
15
|
+
attr_reader :lat
|
16
|
+
attr_reader :lon
|
17
|
+
attr_reader :gmt
|
18
|
+
attr_reader :elevation
|
19
|
+
attr_accessor :data_period
|
20
|
+
|
21
|
+
# access to all the weather data in array of arrays
|
22
|
+
attr_reader :header_data
|
23
|
+
attr_accessor :weather_data
|
24
|
+
|
25
|
+
def initialize(filename)
|
26
|
+
@filename = filename
|
27
|
+
@city = ''
|
28
|
+
@state = ''
|
29
|
+
@country = ''
|
30
|
+
@data_type = ''
|
31
|
+
@wmo = ''
|
32
|
+
@lat = ''
|
33
|
+
@lon = ''
|
34
|
+
@gmt = ''
|
35
|
+
@elevation = ''
|
36
|
+
@valid = false
|
37
|
+
|
38
|
+
@header_data = []
|
39
|
+
@weather_data = []
|
40
|
+
process_header
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.load(filename)
|
44
|
+
raise "EPW file does not exist: #{filename}" unless File.exist?(filename)
|
45
|
+
f = OpenStudio::Weather::Epw.new(filename)
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_kml(xml_builder_obj, url)
|
49
|
+
xml_builder_obj.Placemark do
|
50
|
+
xml_builder_obj.name @city
|
51
|
+
xml_builder_obj.visibility '0'
|
52
|
+
xml_builder_obj.description do
|
53
|
+
xml_builder_obj.cdata!('<img src="kml/ep_header8.png" width=180 align=right><br><table><tr><td colspan="2">'\
|
54
|
+
"<b>#{@city}</b></href></td></tr>\n" +
|
55
|
+
# "<tr><td></td><td><b>Data Type</td></tr>\n"+
|
56
|
+
"<tr><td></td><td>WMO <b>#{@wmo}</b></td></tr>\n" +
|
57
|
+
# "<tr><td></td><td>E 3� 15' N 36� 43'</td></tr>\n"+
|
58
|
+
# "<tr><td></td><td><b>25</b> m</td></tr>\n"+
|
59
|
+
"<tr><td></td><td>Time Zone GMT <b>#{@gmt}</b> hours</td></tr>\n" +
|
60
|
+
# "<tr><td></td><td>ASHRAE Std 169 Climate Zone <b>4A - Mixed - Humid</b></td></tr>\n"+
|
61
|
+
# "<tr><td></td><td>99% Heating DB=<b>3.1</b>, 1% Cooling DB=<b>33.2</b></td></tr>\n"+
|
62
|
+
# "<tr><td></td><td>HDD18 <b>1019</b>, CDD10 <b>2849</b></td></tr>\n"+
|
63
|
+
"<tr><td></td><td>URL #{url}</td></tr></table>")
|
64
|
+
end
|
65
|
+
xml_builder_obj.styleUrl '#weatherlocation'
|
66
|
+
xml_builder_obj.Point do
|
67
|
+
xml_builder_obj.altitudeMode 'absolute'
|
68
|
+
xml_builder_obj.coordinates "#{@lon},#{@lat},#{elevation}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def valid?
|
74
|
+
return @valid
|
75
|
+
end
|
76
|
+
|
77
|
+
def save_as(filename)
|
78
|
+
File.delete filename if File.exist? filename
|
79
|
+
FileUtils.mkdir_p(File.dirname(filename)) unless Dir.exist?(File.dirname(filename))
|
80
|
+
|
81
|
+
CSV.open(filename, 'wb') do |csv|
|
82
|
+
@header_data.each { |r| csv << r }
|
83
|
+
csv << [
|
84
|
+
'DATA PERIODS', @data_period[:count], @data_period[:records_per_hour], @data_period[:name],
|
85
|
+
@data_period[:start_day_of_week], @data_period[:start_date], @data_period[:end_date]
|
86
|
+
]
|
87
|
+
@weather_data.each { |r| csv << r }
|
88
|
+
end
|
89
|
+
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
# Append the weather data (after data periods) to the end of the weather file. This allows
|
94
|
+
# for the creation of multiyear weather files. Note that the date/order is not checked. It assumes
|
95
|
+
# that the data are being added at the end is the more recent data
|
96
|
+
#
|
97
|
+
# @param filename [String] Path to the file that will be appended
|
98
|
+
def append_weather_data(filename)
|
99
|
+
to_append = OpenStudio::Weather::Epw.load(filename)
|
100
|
+
|
101
|
+
prev_length = @weather_data.size
|
102
|
+
@weather_data += to_append.weather_data
|
103
|
+
|
104
|
+
prev_length + to_append.weather_data.size == @weather_data.size
|
105
|
+
end
|
106
|
+
|
107
|
+
def metadata_to_hash
|
108
|
+
{
|
109
|
+
city: @city,
|
110
|
+
state: @state,
|
111
|
+
country: @country,
|
112
|
+
data_type: @data_type,
|
113
|
+
wmo: @wmo,
|
114
|
+
latitude: @lat,
|
115
|
+
longitude: @lon,
|
116
|
+
elevation: @elevation
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
# initialize
|
123
|
+
def process_header
|
124
|
+
header_section = true
|
125
|
+
row_count = 0
|
126
|
+
|
127
|
+
CSV.foreach(@filename) do |row|
|
128
|
+
row_count += 1
|
129
|
+
|
130
|
+
if header_section
|
131
|
+
if row[0] =~ /data.periods/i
|
132
|
+
@data_period = {
|
133
|
+
count: row[1].to_i,
|
134
|
+
records_per_hour: row[2].to_i,
|
135
|
+
name: row[3],
|
136
|
+
start_day_of_week: row[4],
|
137
|
+
start_date: row[5],
|
138
|
+
end_date: row[6]
|
139
|
+
}
|
140
|
+
|
141
|
+
header_section = false
|
142
|
+
|
143
|
+
next
|
144
|
+
else
|
145
|
+
@header_data << row
|
146
|
+
end
|
147
|
+
else
|
148
|
+
@weather_data << row
|
149
|
+
end
|
150
|
+
|
151
|
+
# process only header row
|
152
|
+
# LOCATION,Adak Nas,AK,USA,TMY3,704540,51.88,-176.65,-10.0,5.0
|
153
|
+
if row_count == 1
|
154
|
+
@valid = true
|
155
|
+
|
156
|
+
@city = row[1].tr('/', '-')
|
157
|
+
@state = row[2]
|
158
|
+
@country = row[3]
|
159
|
+
@data_type = row[4]
|
160
|
+
if @data_type =~ /TMY3/i
|
161
|
+
@data_type = 'TMY3'
|
162
|
+
elsif @data_type =~ /TMY2/i
|
163
|
+
@data_type = 'TMY2'
|
164
|
+
elsif @data_type =~ /TMY/i
|
165
|
+
@data_type = 'TMY'
|
166
|
+
end
|
167
|
+
@wmo = row[5]
|
168
|
+
@wmo.nil? ? @wmo = 'wmoundefined' : @wmo = @wmo.to_i
|
169
|
+
@lat = row[6].to_f
|
170
|
+
@lon = row[7].to_f
|
171
|
+
@gmt = row[8].to_f
|
172
|
+
@elevation = row[9].to_f
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
data/lib/openstudio-analysis.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
# Ruby libraries to include
|
7
|
-
require 'json'
|
8
|
-
require 'securerandom'
|
9
|
-
require 'logger'
|
10
|
-
require 'pathname'
|
11
|
-
require 'csv'
|
12
|
-
|
13
|
-
# gems to always include
|
14
|
-
require 'faraday'
|
15
|
-
require 'roo'
|
16
|
-
require 'erb'
|
17
|
-
require 'zip'
|
18
|
-
require 'semantic'
|
19
|
-
require 'semantic/core_ext'
|
20
|
-
|
21
|
-
require 'bcl'
|
22
|
-
|
23
|
-
# core
|
24
|
-
require 'openstudio/analysis/server_api'
|
25
|
-
require 'openstudio/analysis/version'
|
26
|
-
|
27
|
-
# analysis classes
|
28
|
-
require 'openstudio/analysis'
|
29
|
-
require 'openstudio/analysis/support_files'
|
30
|
-
require 'openstudio/analysis/formulation'
|
31
|
-
require 'openstudio/analysis/workflow'
|
32
|
-
require 'openstudio/analysis/workflow_step'
|
33
|
-
require 'openstudio/analysis/algorithm_attributes'
|
34
|
-
require 'openstudio/analysis/server_scripts'
|
35
|
-
|
36
|
-
# translators
|
37
|
-
require 'openstudio/analysis/translator/excel'
|
38
|
-
require 'openstudio/analysis/translator/datapoints'
|
39
|
-
require 'openstudio/analysis/translator/workflow'
|
40
|
-
|
41
|
-
# helpers / core_ext
|
42
|
-
require 'openstudio/helpers/string'
|
43
|
-
require 'openstudio/helpers/hash'
|
44
|
-
require 'openstudio/helpers/utils'
|
45
|
-
|
46
|
-
# weather file parsing
|
47
|
-
require 'openstudio/weather/epw'
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
# Ruby libraries to include
|
7
|
+
require 'json'
|
8
|
+
require 'securerandom'
|
9
|
+
require 'logger'
|
10
|
+
require 'pathname'
|
11
|
+
require 'csv'
|
12
|
+
|
13
|
+
# gems to always include
|
14
|
+
require 'faraday'
|
15
|
+
require 'roo'
|
16
|
+
require 'erb'
|
17
|
+
require 'zip'
|
18
|
+
require 'semantic'
|
19
|
+
require 'semantic/core_ext'
|
20
|
+
|
21
|
+
require 'bcl'
|
22
|
+
|
23
|
+
# core
|
24
|
+
require 'openstudio/analysis/server_api'
|
25
|
+
require 'openstudio/analysis/version'
|
26
|
+
|
27
|
+
# analysis classes
|
28
|
+
require 'openstudio/analysis'
|
29
|
+
require 'openstudio/analysis/support_files'
|
30
|
+
require 'openstudio/analysis/formulation'
|
31
|
+
require 'openstudio/analysis/workflow'
|
32
|
+
require 'openstudio/analysis/workflow_step'
|
33
|
+
require 'openstudio/analysis/algorithm_attributes'
|
34
|
+
require 'openstudio/analysis/server_scripts'
|
35
|
+
|
36
|
+
# translators
|
37
|
+
require 'openstudio/analysis/translator/excel'
|
38
|
+
require 'openstudio/analysis/translator/datapoints'
|
39
|
+
require 'openstudio/analysis/translator/workflow'
|
40
|
+
|
41
|
+
# helpers / core_ext
|
42
|
+
require 'openstudio/helpers/string'
|
43
|
+
require 'openstudio/helpers/hash'
|
44
|
+
require 'openstudio/helpers/utils'
|
45
|
+
|
46
|
+
# weather file parsing
|
47
|
+
require 'openstudio/weather/epw'
|
data/openstudio-analysis.gemspec
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
lib = File.expand_path('lib', __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'openstudio/analysis/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'openstudio-analysis'
|
7
|
-
s.version = OpenStudio::Analysis::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['Nicholas Long']
|
10
|
-
s.email = ['Nicholas.Long@nrel.gov']
|
11
|
-
|
12
|
-
s.homepage = 'http://openstudio.nrel.gov'
|
13
|
-
s.summary = 'Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the Cloud'
|
14
|
-
s.description = 'Basic classes for generating the files needed for OpenStudio-Server'
|
15
|
-
s.license = 'BSD'
|
16
|
-
|
17
|
-
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
-
end
|
20
|
-
s.bindir = 'exe'
|
21
|
-
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
s.require_paths = ['lib']
|
23
|
-
|
24
|
-
s.required_ruby_version = '~> 2.7.0'
|
25
|
-
|
26
|
-
s.add_dependency 'bcl', '~> 0.7.
|
27
|
-
s.add_dependency 'dencity', '~> 0.1.0'
|
28
|
-
s.add_dependency 'faraday', '~> 1.0.1'
|
29
|
-
s.add_dependency 'roo', '~> 2.8.3'
|
30
|
-
s.add_dependency 'rubyzip', '~> 2.3.0'
|
31
|
-
s.add_dependency 'semantic', '~> 1.4'
|
32
|
-
|
33
|
-
s.add_development_dependency 'json-schema', '~> 2.8.0'
|
34
|
-
s.add_development_dependency 'rake', '~> 13.0'
|
35
|
-
s.add_development_dependency 'rspec', '~> 3.9'
|
36
|
-
s.add_development_dependency 'rubocop', '~>
|
37
|
-
s.add_development_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
|
38
|
-
end
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'openstudio/analysis/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'openstudio-analysis'
|
7
|
+
s.version = OpenStudio::Analysis::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Nicholas Long']
|
10
|
+
s.email = ['Nicholas.Long@nrel.gov']
|
11
|
+
|
12
|
+
s.homepage = 'http://openstudio.nrel.gov'
|
13
|
+
s.summary = 'Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the Cloud'
|
14
|
+
s.description = 'Basic classes for generating the files needed for OpenStudio-Server'
|
15
|
+
s.license = 'BSD'
|
16
|
+
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
s.bindir = 'exe'
|
21
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
s.require_paths = ['lib']
|
23
|
+
|
24
|
+
s.required_ruby_version = '~> 2.7.0'
|
25
|
+
|
26
|
+
s.add_dependency 'bcl', '~> 0.7.1'
|
27
|
+
s.add_dependency 'dencity', '~> 0.1.0'
|
28
|
+
s.add_dependency 'faraday', '~> 1.0.1'
|
29
|
+
s.add_dependency 'roo', '~> 2.8.3'
|
30
|
+
s.add_dependency 'rubyzip', '~> 2.3.0'
|
31
|
+
s.add_dependency 'semantic', '~> 1.4'
|
32
|
+
|
33
|
+
s.add_development_dependency 'json-schema', '~> 2.8.0'
|
34
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
35
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
36
|
+
s.add_development_dependency 'rubocop', '~> 1.15.0'
|
37
|
+
s.add_development_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
|
38
|
+
end
|
data/update_license.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
ruby_regex = /^#.\*{79}.*#.\*{79}$/m
|
4
|
-
erb_regex = /^<%.*#.\*{79}.*#.\*{79}.%>$/m
|
5
|
-
js_regex = /^\/\* @preserve.*Copyright.*#.\*\//m
|
6
|
-
|
7
|
-
ruby_header_text = <<EOT
|
8
|
-
# *******************************************************************************
|
9
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
10
|
-
# See also https://openstudio.net/license
|
11
|
-
# *******************************************************************************
|
12
|
-
EOT
|
13
|
-
ruby_header_text.strip!
|
14
|
-
|
15
|
-
erb_header_text = <<EOT
|
16
|
-
<%
|
17
|
-
# *******************************************************************************
|
18
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
19
|
-
# See also https://openstudio.net/license
|
20
|
-
# *******************************************************************************
|
21
|
-
%>
|
22
|
-
EOT
|
23
|
-
erb_header_text.strip!
|
24
|
-
|
25
|
-
js_header_text = <<EOT
|
26
|
-
/* @preserve
|
27
|
-
* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. reserved.
|
28
|
-
* See also https://openstudio.net/license
|
29
|
-
*/
|
30
|
-
EOT
|
31
|
-
js_header_text.strip!
|
32
|
-
|
33
|
-
paths = [
|
34
|
-
{ glob: 'lib/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
35
|
-
{ glob: 'spec/openstudio/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
36
|
-
{ glob: 'spec/integration/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
37
|
-
|
38
|
-
# single files
|
39
|
-
{ glob: 'Rakefile', license: ruby_header_text, regex: ruby_regex },
|
40
|
-
{ glob: 'spec/spec_helper.rb', license: ruby_header_text, regex: ruby_regex }
|
41
|
-
]
|
42
|
-
|
43
|
-
paths.each do |path|
|
44
|
-
Dir[path[:glob]].each do |file|
|
45
|
-
puts "Updating license in file #{file}"
|
46
|
-
|
47
|
-
f = File.read(file)
|
48
|
-
if f =~ path[:regex]
|
49
|
-
puts ' License found -- updating'
|
50
|
-
File.open(file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) }
|
51
|
-
else
|
52
|
-
puts ' No license found -- adding'
|
53
|
-
if f =~ /#!/
|
54
|
-
puts ' CANNOT add license to file automatically, add it manually and it will update automatically in the future'
|
55
|
-
next
|
56
|
-
end
|
57
|
-
File.open(file, 'w') { |write| write << f.insert(0, path[:license] + "\n\n") }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ruby_regex = /^#.\*{79}.*#.\*{79}$/m
|
4
|
+
erb_regex = /^<%.*#.\*{79}.*#.\*{79}.%>$/m
|
5
|
+
js_regex = /^\/\* @preserve.*Copyright.*#.\*\//m
|
6
|
+
|
7
|
+
ruby_header_text = <<EOT
|
8
|
+
# *******************************************************************************
|
9
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
10
|
+
# See also https://openstudio.net/license
|
11
|
+
# *******************************************************************************
|
12
|
+
EOT
|
13
|
+
ruby_header_text.strip!
|
14
|
+
|
15
|
+
erb_header_text = <<EOT
|
16
|
+
<%
|
17
|
+
# *******************************************************************************
|
18
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
19
|
+
# See also https://openstudio.net/license
|
20
|
+
# *******************************************************************************
|
21
|
+
%>
|
22
|
+
EOT
|
23
|
+
erb_header_text.strip!
|
24
|
+
|
25
|
+
js_header_text = <<EOT
|
26
|
+
/* @preserve
|
27
|
+
* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. reserved.
|
28
|
+
* See also https://openstudio.net/license
|
29
|
+
*/
|
30
|
+
EOT
|
31
|
+
js_header_text.strip!
|
32
|
+
|
33
|
+
paths = [
|
34
|
+
{ glob: 'lib/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
35
|
+
{ glob: 'spec/openstudio/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
36
|
+
{ glob: 'spec/integration/**/*.rb', license: ruby_header_text, regex: ruby_regex },
|
37
|
+
|
38
|
+
# single files
|
39
|
+
{ glob: 'Rakefile', license: ruby_header_text, regex: ruby_regex },
|
40
|
+
{ glob: 'spec/spec_helper.rb', license: ruby_header_text, regex: ruby_regex }
|
41
|
+
]
|
42
|
+
|
43
|
+
paths.each do |path|
|
44
|
+
Dir[path[:glob]].each do |file|
|
45
|
+
puts "Updating license in file #{file}"
|
46
|
+
|
47
|
+
f = File.read(file)
|
48
|
+
if f =~ path[:regex]
|
49
|
+
puts ' License found -- updating'
|
50
|
+
File.open(file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) }
|
51
|
+
else
|
52
|
+
puts ' No license found -- adding'
|
53
|
+
if f =~ /#!/
|
54
|
+
puts ' CANNOT add license to file automatically, add it manually and it will update automatically in the future'
|
55
|
+
next
|
56
|
+
end
|
57
|
+
File.open(file, 'w') { |write| write << f.insert(0, path[:license] + "\n\n") }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|