openstudio-extension 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +29 -26
  3. data/.rspec +3 -3
  4. data/.rubocop.yml +10 -9
  5. data/CHANGELOG.md +16 -0
  6. data/Gemfile +6 -6
  7. data/Jenkinsfile +10 -10
  8. data/README.md +251 -250
  9. data/Rakefile +119 -119
  10. data/bin/console +14 -14
  11. data/bin/setup +8 -8
  12. data/doc_templates/LICENSE.md +26 -26
  13. data/doc_templates/README.md.erb +41 -41
  14. data/doc_templates/copyright_erb.txt +35 -35
  15. data/doc_templates/copyright_js.txt +3 -3
  16. data/doc_templates/copyright_ruby.txt +33 -33
  17. data/init_templates/README.md +37 -37
  18. data/init_templates/gemspec.txt +32 -32
  19. data/init_templates/openstudio_module.rb +50 -50
  20. data/init_templates/spec.rb +47 -47
  21. data/init_templates/spec_helper.rb +49 -49
  22. data/init_templates/template_gemfile.txt +17 -17
  23. data/init_templates/template_rakefile.txt +15 -15
  24. data/init_templates/version.rb +40 -40
  25. data/lib/files/openstudio-extension-gem-test.ddy +536 -536
  26. data/lib/files/openstudio-extension-gem-test.epw +8768 -8768
  27. data/lib/files/openstudio-extension-gem-test.stat +554 -554
  28. data/lib/measures/openstudio_extension_test_measure/LICENSE.md +26 -26
  29. data/lib/measures/openstudio_extension_test_measure/README.md +26 -26
  30. data/lib/measures/openstudio_extension_test_measure/README.md.erb +41 -41
  31. data/lib/measures/openstudio_extension_test_measure/measure.rb +72 -72
  32. data/lib/measures/openstudio_extension_test_measure/measure.xml +83 -83
  33. data/lib/measures/openstudio_extension_test_measure/resources/os_lib_helper_methods.rb +399 -399
  34. data/lib/measures/openstudio_extension_test_measure/tests/{OpenStudioExtensionTestMeasure_Test.rb → openstudio_extension_test_measure_test.rb} +74 -75
  35. data/lib/openstudio-extension.rb +1 -1
  36. data/lib/openstudio/extension.rb +234 -229
  37. data/lib/openstudio/extension/core/CreateResults.rb +886 -886
  38. data/lib/openstudio/extension/core/check_air_sys_temps.rb +190 -190
  39. data/lib/openstudio/extension/core/check_calibration.rb +155 -155
  40. data/lib/openstudio/extension/core/check_cond_zns.rb +84 -84
  41. data/lib/openstudio/extension/core/check_domestic_hot_water.rb +334 -334
  42. data/lib/openstudio/extension/core/check_envelope_conductance.rb +453 -453
  43. data/lib/openstudio/extension/core/check_eui_by_end_use.rb +162 -162
  44. data/lib/openstudio/extension/core/check_eui_reasonableness.rb +135 -135
  45. data/lib/openstudio/extension/core/check_fan_pwr.rb +98 -98
  46. data/lib/openstudio/extension/core/check_internal_loads.rb +393 -393
  47. data/lib/openstudio/extension/core/check_mech_sys_capacity.rb +226 -226
  48. data/lib/openstudio/extension/core/check_mech_sys_efficiency.rb +326 -326
  49. data/lib/openstudio/extension/core/check_mech_sys_part_load_eff.rb +464 -464
  50. data/lib/openstudio/extension/core/check_mech_sys_type.rb +139 -139
  51. data/lib/openstudio/extension/core/check_part_loads.rb +451 -451
  52. data/lib/openstudio/extension/core/check_placeholder.rb +75 -75
  53. data/lib/openstudio/extension/core/check_plant_cap.rb +123 -123
  54. data/lib/openstudio/extension/core/check_plant_temps.rb +159 -159
  55. data/lib/openstudio/extension/core/check_plenum_loads.rb +87 -87
  56. data/lib/openstudio/extension/core/check_pump_pwr.rb +108 -108
  57. data/lib/openstudio/extension/core/check_sch_coord.rb +241 -241
  58. data/lib/openstudio/extension/core/check_schedules.rb +311 -311
  59. data/lib/openstudio/extension/core/check_simultaneous_heating_and_cooling.rb +158 -158
  60. data/lib/openstudio/extension/core/check_supply_air_and_thermostat_temp_difference.rb +148 -148
  61. data/lib/openstudio/extension/core/check_weather_files.rb +132 -132
  62. data/lib/openstudio/extension/core/deer_vintages.rb +311 -311
  63. data/lib/openstudio/extension/core/os_lib_aedg_measures.rb +491 -491
  64. data/lib/openstudio/extension/core/os_lib_cofee.rb +258 -258
  65. data/lib/openstudio/extension/core/os_lib_constructions.rb +378 -378
  66. data/lib/openstudio/extension/core/os_lib_geometry.rb +1022 -1022
  67. data/lib/openstudio/extension/core/os_lib_helper_methods.rb +399 -399
  68. data/lib/openstudio/extension/core/os_lib_hvac.rb +2171 -2171
  69. data/lib/openstudio/extension/core/os_lib_lighting_and_equipment.rb +214 -214
  70. data/lib/openstudio/extension/core/os_lib_model_generation.rb +817 -817
  71. data/lib/openstudio/extension/core/os_lib_model_simplification.rb +1049 -1049
  72. data/lib/openstudio/extension/core/os_lib_outdoorair_and_infiltration.rb +165 -165
  73. data/lib/openstudio/extension/core/os_lib_reporting.rb +4651 -4651
  74. data/lib/openstudio/extension/core/os_lib_reporting_qaqc.rb +200 -200
  75. data/lib/openstudio/extension/core/os_lib_schedules.rb +963 -963
  76. data/lib/openstudio/extension/rake_task.rb +159 -149
  77. data/lib/openstudio/extension/runner.rb +667 -644
  78. data/lib/openstudio/extension/runner_config.rb +114 -0
  79. data/lib/openstudio/extension/version.rb +40 -40
  80. data/openstudio-extension.gemspec +34 -33
  81. metadata +39 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4e2f50a7956aab9ba887ed122f081f9d1a593e9
4
- data.tar.gz: 9883f17cccdb73a1f70ca70806c4a529f4d5837a
3
+ metadata.gz: 571493376dd8bdb8c6668ffb60d27deaca08b7a1
4
+ data.tar.gz: e3a1267d5fd9b6487b4a4743dfcdfec5ea8b443f
5
5
  SHA512:
6
- metadata.gz: f41334de4ba12a02b02ba8c8963f912793c0885d922532f1b21af10656a368ab84baee8cdca6d9e75ec96cfd8d2dac35ccbf008201c2043c10717f5824058251
7
- data.tar.gz: 78bd29c60ef04bef8e792095e4c919435e35f5f41fa3f9cd7a4dd64ed85c7d2184dbafaa367ea54bb4b8e5f57c06d0d7e5ed2f20e4519a24de9b9146d47d7739
6
+ metadata.gz: 2e7fd0a1d49000a784c7e11c48ea8572d1dbf1019a232f563714779c6eddda37418d85b91ffe4ea73f151cfd0553b44e06cc1a790396dd715f4908f9ee88b2e9
7
+ data.tar.gz: 58a792d63d3e1b5fdc9d686695bbf39db5d84bebeb3e62c2f38846b99db4a5ee619e730911290c084acc4a09778ca10fca58133963e7983717f730643b97b708
data/.gitignore CHANGED
@@ -1,26 +1,29 @@
1
- /.bundle/
2
- /.yardoc
3
- /.ruby-version
4
- /Gemfile.lock
5
- /gems
6
- /_yardoc/
7
- /coverage/
8
- /doc/
9
- /pkg/
10
- /spec/reports/
11
- /spec/test/
12
- /tmp/
13
- /test/
14
- /lib/measures/test_results
15
- /lib/measures/.rubocop*
16
-
17
- # rspec failure tracking
18
- .rspec_status
19
-
20
- # Ignore IDE files
21
- /.idea
22
- *.rubocop-http*
23
-
24
- # measures tests
25
- lib/measures/.rubocop.yml
26
- lib/measures/test_results/*
1
+ /.bundle/
2
+ /.yardoc
3
+ /.ruby-version
4
+ /Gemfile.lock
5
+ /gems
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /spec/test/
12
+ /tmp/
13
+ /test/
14
+ /lib/measures/test_results
15
+ /lib/measures/.rubocop*
16
+
17
+ # rspec failure tracking
18
+ .rspec_status
19
+
20
+ # Ignore IDE files
21
+ /.idea
22
+ *.rubocop-http*
23
+
24
+ # measures tests
25
+ lib/measures/.rubocop.yml
26
+ lib/measures/test_results/*
27
+
28
+ # runner conf
29
+ runner.conf
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,9 +1,10 @@
1
- AllCops:
2
- Exclude:
3
- - gems/**/*
4
- - lib/measures/**/*
5
- - lib/openstudio/extension/core/**/*
6
-
7
- inherit_from:
8
- - http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
9
-
1
+ AllCops:
2
+ Exclude:
3
+ - gems/**/*
4
+ - init_templates/**/*
5
+ - lib/measures/**/resources/*
6
+ - lib/openstudio/extension/core/**/*
7
+
8
+ inherit_from:
9
+ - http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
10
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # OpenStudio Extension Gem
2
+
3
+ ## Version 0.1.3
4
+
5
+ * Move runner configuration options to runner initializer. Allow user to set the number of parallel simulations, max number of simulations, run the simulations (true/false), and verbose output.
6
+ * Add a runner.conf file that can be used to define how the run_osw(s) behaves.
7
+ * Add rake task to initialize the runner.conf (e.g., rake openstudio:runner:init)
8
+
9
+ ## Version 0.1.2
10
+
11
+ * Support for BuildingSync gem
12
+ * Add run_osws capability
13
+
14
+ ## Version 0.1.1
15
+
16
+ * Initial release
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source 'http://rubygems.org'
2
-
3
- # Specify your gem's dependencies in openstudio-extension.gemspec
4
- gemspec
5
-
6
- gem 'simplecov', github: 'NREL/simplecov'
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in openstudio-extension.gemspec
4
+ gemspec
5
+
6
+ gem 'simplecov', github: 'NREL/simplecov'
data/Jenkinsfile CHANGED
@@ -1,10 +1,10 @@
1
- //Jenkins pipelines are stored in shared libaries. Please see: https://github.com/tijcolem/nrel_cbci_jenkins_libs
2
-
3
- @Library('cbci_shared_libs') _
4
-
5
- // Build for PR to develop branch only.
6
- if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) { // check if set
7
-
8
- openstudio_extension_gems()
9
-
10
- }
1
+ //Jenkins pipelines are stored in shared libaries. Please see: https://github.com/tijcolem/nrel_cbci_jenkins_libs
2
+
3
+ @Library('cbci_shared_libs') _
4
+
5
+ // Build for PR to develop branch only.
6
+ if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) { // check if set
7
+
8
+ openstudio_extension_gems()
9
+
10
+ }
data/README.md CHANGED
@@ -1,250 +1,251 @@
1
- # OpenStudio Extension Gem
2
-
3
- This gem repository serves as a base for single purpose repositories that host API methods, CLI tools, and OpenStudio measures which leverage those methods and tools. Other derivative extension gem repositories will depend on this repository and inherit/mix-in needed functionality. The repository is formatted as a gem to allow for semantic versioning via Bundle. The repository includes methods for testing, documentation, and build tasks.
4
-
5
- ## Overview
6
-
7
- The OpenStudio Extension Gem contains methods and patterns to extend OpenStudio. It is a template that can be used to create other extension gems.
8
-
9
- Derivative extension gems should include this gem to access common functionality, such as:
10
- * OpenStudio CLI functionality such as list_measures and update_measures
11
- * adding documentation and license files to measures
12
- * adding core resource files to measures
13
- * pushing measures to BCL
14
-
15
- Extension gems will contain a small group of related measures. Each extension gem will be the unique location to find these measures, and will be responsible for
16
- testing and maintaining the measures as well as pushing them to BCL.
17
-
18
- ## Usage
19
-
20
- The ```openstudio-extension``` gem is meant to be used as a base for creating new gems to use with OpenStudio. The intention is to standardize best practices and common patterns in one location rather than try to synchronize them across many independent gems.
21
-
22
- Existing gems such as ```openstudio-standards``` and ```openstudio-workflow``` may be refactored to depend on ```openstudio-extension``` in the future. The immediate use of ```openstudio-extension``` will be for new gems. New gems that may be considered a part of OpenStudio and potentially distributed with OpenStudio in the future should be named as ```openstudio-#{gem-name}```, e.g. ```openstudio-model-articulation``` is a gem to implement model articulation methods for OpenStudio.
23
- Other gems that extend OpenStudio for specific applications or other domains should be named separately, e.g. ```buildingsync``` is an extension of OpenStudio specifically for use with BuildingSync files.
24
-
25
- Each OpenStudio extension gem should define its own module name to ensure that there are no code collisions with other extension gems. If the gem name is prefixed with ```openstudio-``` then the module name can be nested under the OpenStudio module.
26
-
27
- | openstudio-model-articulation | buildingsync |
28
- |------------------------------------------------------------------------------------------------------------- |----------------------------------------------------------------------------- |
29
- | module OpenStudio module ModelArticulation class ModelArticulation < OpenStudio::Extension::Extension | module BuildingSync class BuildingSync < OpenStudio::Extension::Extension |
30
-
31
-
32
- ## Installation
33
-
34
- To use this and other extension gems, you will need Ruby 2.2.4 and OpenStudio 2.7.1 or greater.
35
-
36
- ### Windows Installation
37
- Install Ruby using the [RubyInstaller](https://rubyinstaller.org/downloads/archives/) for [Ruby 2.2.4 (x64)](https://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.2.4-x64.exe).
38
-
39
- Install Devkit using the [mingw64](https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe) installer.
40
-
41
- Check the ruby installation returns the correct Ruby version (2.2.4):
42
- ```
43
- ruby -v
44
- ```
45
-
46
- Install bundler from the command line
47
- ```
48
- gem install bundler -v 1.17
49
- ```
50
-
51
- Install OpenStudio. Create a file ```C:\ruby-2.2.4-x64-mingw32\lib\ruby\site_ruby\openstudio.rb``` and point it to your OpenStudio installation by editing the contents. E.g.:
52
-
53
- ```ruby
54
- require 'C:\openstudio-2.7.1\Ruby\openstudio.rb'
55
- ```
56
-
57
- Verify your OpenStudio and Ruby configuration:
58
- ```
59
- ruby -e "require 'openstudio'" -e "puts OpenStudio::Model::Model.new"
60
- ```
61
-
62
- ### Mac Installation
63
- It is recommended that you install [rbenv](https://github.com/rbenv/rbenv) to easily manage difference versions of Ruby.
64
- rbenv can be installed via [Homebrew](https://brew.sh/):
65
- ```
66
- brew install rbenv
67
- rbenv init
68
- rbenv install 2.2.4
69
- ```
70
-
71
- Also install bundler
72
- ```
73
- gem install bundler -v 1.17
74
- ```
75
-
76
- Install [OpenStudio](https://www.openstudio.net/downloads).
77
-
78
- Add the RUBYLIB environment variable to your `bash_profile` (or similar) file. It should point to the Ruby folder within the OpenStudio Application you just downloaded (replace 2.7.2 with the version you are using):
79
- ```
80
- export RUBYLIB=/Applications/OpenStudio-2.7.2/Ruby
81
- ```
82
-
83
-
84
- ## Contents
85
- The OpenStudio Extension Gem (this repo) contains methods that can be shared across and extended by other derivative extension gems.
86
-
87
- ### Directory Structure
88
-
89
- Extension gem and the derivative extension gem should have the following directory structure:
90
-
91
- ├── doc_templates
92
-
93
- ├── init_templates
94
-
95
- ├── lib
96
-
97
- │       ├── data
98
-
99
- │       ├── files
100
-
101
- │       ├── measures
102
-
103
- │       └── openstudio
104
-
105
- │                └── extension
106
-
107
- │                          └── core
108
-
109
- └── spec
110
-                ├── files
111
-
112
-                └── openstudio
113
-
114
-                          └── core
115
-
116
- `doc_templates` contains copyright and license file templates that can be copied and added to each measure.
117
- The derivative extension gems should have their own doc_templates directory.
118
-
119
- `init_templates` are used with the `init-new-gem` rake task to create a derivative extension gem directory structure.
120
-
121
- `lib` contains data
122
- * `data` contains custom data for the gem
123
- * `files` contains files referenced by measures or workflows
124
- * `measures` contains the measures included in the gem.
125
- * `openstudio` and `openstudio\extension` contain the code related to this gem.
126
- * `openstudio\extension\core` contains core resource files shared across a variety of measures.
127
-
128
- Your gem should list its gem dependencies (including ```openstudio-extension```) in its gemspec file. This is what is used to determine dependencies for consumers of your gem.
129
- You should only list actual dependencies of your gem in the gemspec. You can list specific sources for your gems (e.g. on github, local file) in your Gemfile. If you are writing an application rather than a gem, you can only have a Gemfile. You do not need a gemspec unless you are releasing your code as a gem.
130
- Once you have included ```openstudio-extension``` as a dependency of your gem, you can inherit common rake tasks into your application's Rakefile.
131
-
132
- ### Core Library
133
- The `core` folder located at `lib\openstudio\extension` contains core resource files shared across a variety of measures. The files should be edited in the OpenStudio-extension-gem, and the rake task (`bundle exec rake openstudio:measures:copy_resources`) should be used to update the measures that depend on them.
134
- Note that this folder is for 'core' functionality; if a measure's requires a new one-off function, this should be developed in place, within the measure's `resources` folder.
135
-
136
- Having a single repository for all measures, such as the OpenStudio-measures repo, can be cumbersome to test and keep up to date.
137
- In this new framework, each extension gem will contain one or more related measures. The gem will be the new 'home' of these measures, and the repo owner will be responsible for testing and keeping the measures up to date.
138
-
139
- In the short term, in order to preserve the PAT/OS App functionality, resource files will still be copied directly into the measures, and these measures will be pushed to BCL.
140
-
141
- ### Rake Tasks
142
- Common Rake Tasks that are available to derivative extension gems include:
143
- | Rake Task | Description |
144
- | --------- | ----------- |
145
- | openstudio:list_measures | List all measures in the calling gem |
146
- | openstudio:measures:add_license | Add License File to measures in the calling gem |
147
- | openstudio:measures:add_readme | Add README.md.erb file if it and the README markdown file do not already exist for a measure |
148
- | openstudio:measures:copy_resources | Copy the resources files to individual measures in the calling gem |
149
- | openstudio:measures:update_copyright | Update copyright on measure files in the calling gem |
150
- | openstudio:stage_bcl | Copy the measures to a location that can be uploaded to BCL |
151
- | openstudio:push_bcl | Upload measures from the specified location to the BCL |
152
- | openstudio:test_with_docker | Use openstudio docker image to run tests |
153
- | openstudio:test_with_openstudio | Use openstudio system ruby to run tests |
154
- | openstudio:update_measures | Run the CLI task to check for measure updates and update the measure xml files |
155
-
156
- These can all be invoked from the derivative gem by running the following command in a terminal:
157
-
158
- ``` bundle exec rake <name_of_rake_task>```
159
-
160
- To list all available rake tasks:
161
-
162
- ``` bundle exec rake -T ```
163
-
164
- ## Derivative Extension Gems
165
-
166
- The following table contains all current extension gems.
167
-
168
- | Name | Gem Name | Repo |
169
- | ------ | ---------- | ------ |
170
- | OpenStudio Extension Gem | openstudio-extension | https://github.com/NREL/OpenStudio-extension-gem |
171
- | OpenStudio Common Measures Gem | openstudio-common-measures | https://github.com/NREL/openstudio-common-measures-gem |
172
- | OpenStudio Model Articulation Gem | openstudio-model-articulation | https://github.com/NREL/openstudio-model-articulation-gem |
173
- | OpenStudio AEDG Gem | openstudio-aedg | https://github.com/NREL/openstudio-aedg-gem |
174
- | OpenStudio District Systems Gem | openstudio-district-systems | https://github.com/NREL/openstudio-district-systems-gem |
175
- | UrbanOpt GeoJSON Gem | urbanopt-geojson | https://github.com/urbanopt/urbanopt-geojson-gem |
176
- | BuildingSync Gem | buildingsync | https://github.com/BuildingSync/BuildingSync-gem |
177
-
178
- ### Initializing a new Extension Gem
179
- The OpenStudio-extension gem can be used to easily initialize a new derivative extension gem.
180
-
181
- * First, call the rake task:
182
- ```ruby
183
- bundle exec rake init_new_gem
184
- ```
185
- * Enter the name of the gem repository (use dashes between words and the repo name should end with '-gem')
186
- * Enter the location of the directory where the gem directory should be created
187
- The rake task will create the gem directory and stub out the required files.
188
-
189
- * You can then obtain a github repository and commit the newly created gem directory to it
190
-
191
- ### Coding Conventions
192
- * Name your extension gem repo: OpenStudio-<gem name in lowercase>-gem. Use dashes between words. Example: OpenStudio-extension-gem
193
- * Name the actual gem: openstudio-<gem name in lowercase>. 'openstudio' should be lowercase. Use dashes between words. Example: openstudio-extension
194
- * Use lowercase snake_case for methods and variables.
195
- * Use CamelCase for classes and modules. (Keep acronyms like HTTP, RFC, XML uppercase.)
196
- * All files and classes should have underscores (no dashes) and (lowercase snake_case)
197
- * Dashes should be used in module names
198
-
199
- ### Pushing to BCL
200
- Use the rake tasks listed above to stage and push measures to BCL.
201
- **Note of warning**: Use caution when pushing to the BCL. Public and private measures could be pushed to BCL from within an extension gem, even though the extension gem repo may be private.
202
-
203
- TODO: Add warning to rake task and lists what gems will be pushed
204
- TODO: Check that license files, etc. are present in each measure before pushing to BCL
205
-
206
- ## Include in a project
207
-
208
- Add this line to your application's Gemfile:
209
-
210
- ```ruby
211
- gem 'openstudio-extension'
212
- ```
213
-
214
- And then execute:
215
-
216
- $ bundle install
217
- $ bundle update
218
-
219
- Or install it yourself as:
220
-
221
- $ gem install 'openstudio-extension'
222
-
223
- # Releasing the gem
224
-
225
- * Update change log
226
- * Update version in `/lib/openstudio/extension/version.rb`
227
- * Merge down to master
228
- * run `rake release` from master
229
-
230
- # TODO
231
-
232
- - [ ] Finalize documentation on naming conventions, etc
233
- - [X] Add test measure
234
- - [X] Rake task ```openstudio:update_measures```
235
- - [X] Rake task ```openstudio:test_with_openstudio```
236
- - [ ] Rake task ```stage_bcl``` _DLM: BCL gem should be a development dependency only until we can reduce its dependencies and remove native dependencies? should probably put it into a special group so we can bundle without it in openstudio-gems._
237
- - [ ] Rake task ```push_bcl``` _DLM: how do we want to test this?
238
- - [X] Get all rake tasks working on Travis
239
- - [ ] Capture useful output from Travis (measure dashboard results, log files, zip of build products, etc) and put it somewhere (s3? naming convention?)
240
- - [X] ```Extension::openstudio_extension_version``` _DLM: should we rename? should people overwrite this in their class?_
241
- - [X] ```Extension::measures_dir``` _DLM: I think this can have a default implementation, right? If something does not need to be overridden should it be a module method rather than a class one? KAF: this is in rake task for now
242
- - [X] ```Extension::list_measures``` _DLM: I think this can have a default implementation, right?_KAF: In Rake task for now
243
- - [ ] ```Extension::files_dir``` _DLM: I think this can have a default implementation, right?_
244
- - [ ] ```Extension::minimum_openstudio_version``` _DLM: should we rename? should people overwrite this in their class?_
245
- - [X] ```Runner::initialize``` _DLM: should say that the path argument should be for a dir with a Gemfile right?_
246
- - [X] ```Runner::configure_osw``` _DLM: should take in an OSW, add paths to all measure and file dirs for loaded OpenStudio Extensions, write out configured OSW_
247
- - [ ] Run rubocop on all of the core files and remove exclusion from .rubocop.yml file.
248
- - [ ] Cleanup task after running tests (may need to be in the OpenStudio Measure Tester)
249
- - [ ] Add a `rake init new_ext_gem` to Rakefile
250
- - [ ] Add tests to the extension/core
1
+ # OpenStudio Extension Gem
2
+
3
+ This gem repository serves as a base for single purpose repositories that host API methods, CLI tools, and OpenStudio measures which leverage those methods and tools. Other derivative extension gem repositories will depend on this repository and inherit/mix-in needed functionality. The repository is formatted as a gem to allow for semantic versioning via Bundle. The repository includes methods for testing, documentation, and build tasks.
4
+
5
+ ## Overview
6
+
7
+ The OpenStudio Extension Gem contains methods and patterns to extend OpenStudio. It is a template that can be used to create other extension gems.
8
+
9
+ Derivative extension gems should include this gem to access common functionality, such as:
10
+ * OpenStudio CLI functionality such as list_measures and update_measures
11
+ * adding documentation and license files to measures
12
+ * adding core resource files to measures
13
+ * pushing measures to BCL
14
+
15
+ Extension gems will contain a small group of related measures. Each extension gem will be the unique location to find these measures, and will be responsible for
16
+ testing and maintaining the measures as well as pushing them to BCL.
17
+
18
+ ## Usage
19
+
20
+ The ```openstudio-extension``` gem is meant to be used as a base for creating new gems to use with OpenStudio. The intention is to standardize best practices and common patterns in one location rather than try to synchronize them across many independent gems.
21
+
22
+ Existing gems such as ```openstudio-standards``` and ```openstudio-workflow``` may be refactored to depend on ```openstudio-extension``` in the future. The immediate use of ```openstudio-extension``` will be for new gems. New gems that may be considered a part of OpenStudio and potentially distributed with OpenStudio in the future should be named as ```openstudio-#{gem-name}```, e.g. ```openstudio-model-articulation``` is a gem to implement model articulation methods for OpenStudio.
23
+ Other gems that extend OpenStudio for specific applications or other domains should be named separately, e.g. ```buildingsync``` is an extension of OpenStudio specifically for use with BuildingSync files.
24
+
25
+ Each OpenStudio extension gem should define its own module name to ensure that there are no code collisions with other extension gems. If the gem name is prefixed with ```openstudio-``` then the module name can be nested under the OpenStudio module.
26
+
27
+ | openstudio-model-articulation | buildingsync |
28
+ |------------------------------------------------------------------------------------------------------------- |----------------------------------------------------------------------------- |
29
+ | module OpenStudio module ModelArticulation class ModelArticulation < OpenStudio::Extension::Extension | module BuildingSync class BuildingSync < OpenStudio::Extension::Extension |
30
+
31
+
32
+ ## Installation
33
+
34
+ To use this and other extension gems, you will need Ruby 2.2.4 and OpenStudio 2.7.1 or greater.
35
+
36
+ ### Windows Installation
37
+ Install Ruby using the [RubyInstaller](https://rubyinstaller.org/downloads/archives/) for [Ruby 2.2.4 (x64)](https://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.2.4-x64.exe).
38
+
39
+ Install Devkit using the [mingw64](https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe) installer.
40
+
41
+ Check the ruby installation returns the correct Ruby version (2.2.4):
42
+ ```
43
+ ruby -v
44
+ ```
45
+
46
+ Install bundler from the command line
47
+ ```
48
+ gem install bundler -v 1.17
49
+ ```
50
+
51
+ Install OpenStudio. Create a file ```C:\ruby-2.2.4-x64-mingw32\lib\ruby\site_ruby\openstudio.rb``` and point it to your OpenStudio installation by editing the contents. E.g.:
52
+
53
+ ```ruby
54
+ require 'C:\openstudio-2.7.1\Ruby\openstudio.rb'
55
+ ```
56
+
57
+ Verify your OpenStudio and Ruby configuration:
58
+ ```
59
+ ruby -e "require 'openstudio'" -e "puts OpenStudio::Model::Model.new"
60
+ ```
61
+
62
+ ### Mac Installation
63
+ It is recommended that you install [rbenv](https://github.com/rbenv/rbenv) to easily manage difference versions of Ruby.
64
+ rbenv can be installed via [Homebrew](https://brew.sh/):
65
+ ```
66
+ brew install rbenv
67
+ rbenv init
68
+ rbenv install 2.2.4
69
+ ```
70
+
71
+ Also install bundler
72
+ ```
73
+ gem install bundler -v 1.17
74
+ ```
75
+
76
+ Install [OpenStudio](https://www.openstudio.net/downloads).
77
+
78
+ Add the RUBYLIB environment variable to your `bash_profile` (or similar) file. It should point to the Ruby folder within the OpenStudio Application you just downloaded (replace 2.7.2 with the version you are using):
79
+ ```
80
+ export RUBYLIB=/Applications/OpenStudio-2.7.2/Ruby
81
+ ```
82
+
83
+
84
+ ## Contents
85
+ The OpenStudio Extension Gem (this repo) contains methods that can be shared across and extended by other derivative extension gems.
86
+
87
+ ### Directory Structure
88
+
89
+ Extension gem and the derivative extension gem should have the following directory structure:
90
+
91
+ ├── doc_templates
92
+
93
+ ├── init_templates
94
+
95
+ ├── lib
96
+
97
+ │       ├── data
98
+
99
+ │       ├── files
100
+
101
+ │       ├── measures
102
+
103
+ │       └── openstudio
104
+
105
+ │                └── extension
106
+
107
+ │                          └── core
108
+
109
+ └── spec
110
+                ├── files
111
+
112
+                └── openstudio
113
+
114
+                          └── core
115
+
116
+ `doc_templates` contains copyright and license file templates that can be copied and added to each measure.
117
+ The derivative extension gems should have their own doc_templates directory.
118
+
119
+ `init_templates` are used with the `init-new-gem` rake task to create a derivative extension gem directory structure.
120
+
121
+ `lib` contains data
122
+ * `data` contains custom data for the gem
123
+ * `files` contains files referenced by measures or workflows
124
+ * `measures` contains the measures included in the gem.
125
+ * `openstudio` and `openstudio\extension` contain the code related to this gem.
126
+ * `openstudio\extension\core` contains core resource files shared across a variety of measures.
127
+
128
+ Your gem should list its gem dependencies (including ```openstudio-extension```) in its gemspec file. This is what is used to determine dependencies for consumers of your gem.
129
+ You should only list actual dependencies of your gem in the gemspec. You can list specific sources for your gems (e.g. on github, local file) in your Gemfile. If you are writing an application rather than a gem, you can only have a Gemfile. You do not need a gemspec unless you are releasing your code as a gem.
130
+ Once you have included ```openstudio-extension``` as a dependency of your gem, you can inherit common rake tasks into your application's Rakefile.
131
+
132
+ ### Core Library
133
+ The `core` folder located at `lib\openstudio\extension` contains core resource files shared across a variety of measures. The files should be edited in the OpenStudio-extension-gem, and the rake task (`bundle exec rake openstudio:measures:copy_resources`) should be used to update the measures that depend on them.
134
+ Note that this folder is for 'core' functionality; if a measure's requires a new one-off function, this should be developed in place, within the measure's `resources` folder.
135
+
136
+ Having a single repository for all measures, such as the OpenStudio-measures repo, can be cumbersome to test and keep up to date.
137
+ In this new framework, each extension gem will contain one or more related measures. The gem will be the new 'home' of these measures, and the repo owner will be responsible for testing and keeping the measures up to date.
138
+
139
+ In the short term, in order to preserve the PAT/OS App functionality, resource files will still be copied directly into the measures, and these measures will be pushed to BCL.
140
+
141
+ ### Rake Tasks
142
+ Common Rake Tasks that are available to derivative extension gems include:
143
+ | Rake Task | Description |
144
+ | --------- | ----------- |
145
+ | openstudio:list_measures | List all measures in the calling gem |
146
+ | openstudio:measures:add_license | Add License File to measures in the calling gem |
147
+ | openstudio:measures:add_readme | Add README.md.erb file if it and the README markdown file do not already exist for a measure |
148
+ | openstudio:measures:copy_resources | Copy the resources files to individual measures in the calling gem |
149
+ | openstudio:measures:update_copyright | Update copyright on measure files in the calling gem |
150
+ | rake openstudio:runner:init | Create a runner.conf file running simulations |
151
+ | openstudio:stage_bcl | Copy the measures to a location that can be uploaded to BCL |
152
+ | openstudio:push_bcl | Upload measures from the specified location to the BCL |
153
+ | openstudio:test_with_docker | Use openstudio docker image to run tests |
154
+ | openstudio:test_with_openstudio | Use openstudio system ruby to run tests |
155
+ | openstudio:update_measures | Run the CLI task to check for measure updates and update the measure xml files |
156
+
157
+ These can all be invoked from the derivative gem by running the following command in a terminal:
158
+
159
+ ``` bundle exec rake <name_of_rake_task>```
160
+
161
+ To list all available rake tasks:
162
+
163
+ ``` bundle exec rake -T ```
164
+
165
+ ## Derivative Extension Gems
166
+
167
+ The following table contains all current extension gems.
168
+
169
+ | Name | Gem Name | Repo |
170
+ | ------ | ---------- | ------ |
171
+ | OpenStudio Extension Gem | openstudio-extension | https://github.com/NREL/OpenStudio-extension-gem |
172
+ | OpenStudio Common Measures Gem | openstudio-common-measures | https://github.com/NREL/openstudio-common-measures-gem |
173
+ | OpenStudio Model Articulation Gem | openstudio-model-articulation | https://github.com/NREL/openstudio-model-articulation-gem |
174
+ | OpenStudio AEDG Gem | openstudio-aedg | https://github.com/NREL/openstudio-aedg-gem |
175
+ | OpenStudio District Systems Gem | openstudio-district-systems | https://github.com/NREL/openstudio-district-systems-gem |
176
+ | UrbanOpt GeoJSON Gem | urbanopt-geojson | https://github.com/urbanopt/urbanopt-geojson-gem |
177
+ | BuildingSync Gem | buildingsync | https://github.com/BuildingSync/BuildingSync-gem |
178
+
179
+ ### Initializing a new Extension Gem
180
+ The OpenStudio-extension gem can be used to easily initialize a new derivative extension gem.
181
+
182
+ * First, call the rake task:
183
+ ```ruby
184
+ bundle exec rake init_new_gem
185
+ ```
186
+ * Enter the name of the gem repository (use dashes between words and the repo name should end with '-gem')
187
+ * Enter the location of the directory where the gem directory should be created
188
+ The rake task will create the gem directory and stub out the required files.
189
+
190
+ * You can then obtain a github repository and commit the newly created gem directory to it
191
+
192
+ ### Coding Conventions
193
+ * Name your extension gem repo: OpenStudio-<gem name in lowercase>-gem. Use dashes between words. Example: OpenStudio-extension-gem
194
+ * Name the actual gem: openstudio-<gem name in lowercase>. 'openstudio' should be lowercase. Use dashes between words. Example: openstudio-extension
195
+ * Use lowercase snake_case for methods and variables.
196
+ * Use CamelCase for classes and modules. (Keep acronyms like HTTP, RFC, XML uppercase.)
197
+ * All files and classes should have underscores (no dashes) and (lowercase snake_case)
198
+ * Dashes should be used in module names
199
+
200
+ ### Pushing to BCL
201
+ Use the rake tasks listed above to stage and push measures to BCL.
202
+ **Note of warning**: Use caution when pushing to the BCL. Public and private measures could be pushed to BCL from within an extension gem, even though the extension gem repo may be private.
203
+
204
+ TODO: Add warning to rake task and lists what gems will be pushed
205
+ TODO: Check that license files, etc. are present in each measure before pushing to BCL
206
+
207
+ ## Include in a project
208
+
209
+ Add this line to your application's Gemfile:
210
+
211
+ ```ruby
212
+ gem 'openstudio-extension'
213
+ ```
214
+
215
+ And then execute:
216
+
217
+ $ bundle install
218
+ $ bundle update
219
+
220
+ Or install it yourself as:
221
+
222
+ $ gem install 'openstudio-extension'
223
+
224
+ # Releasing the gem
225
+
226
+ * Update change log
227
+ * Update version in `/lib/openstudio/extension/version.rb`
228
+ * Merge down to master
229
+ * run `rake release` from master
230
+
231
+ # TODO
232
+
233
+ - [X] Finalize documentation on naming conventions, etc
234
+ - [X] Add test measure
235
+ - [X] Rake task ```openstudio:update_measures```
236
+ - [X] Rake task ```openstudio:test_with_openstudio```
237
+ - [ ] Rake task ```stage_bcl``` _DLM: BCL gem should be a development dependency only until we can reduce its dependencies and remove native dependencies? should probably put it into a special group so we can bundle without it in openstudio-gems._
238
+ - [ ] Rake task ```push_bcl``` _DLM: how do we want to test this?
239
+ - [X] Get all rake tasks working on Travis
240
+ - [ ] Capture useful output from Travis (measure dashboard results, log files, zip of build products, etc) and put it somewhere (s3? naming convention?)
241
+ - [X] ```Extension::openstudio_extension_version``` _DLM: should we rename? should people overwrite this in their class?_
242
+ - [X] ```Extension::measures_dir``` _DLM: I think this can have a default implementation, right? If something does not need to be overridden should it be a module method rather than a class one? KAF: this is in rake task for now
243
+ - [X] ```Extension::list_measures``` _DLM: I think this can have a default implementation, right?_KAF: In Rake task for now
244
+ - [ ] ```Extension::files_dir``` _DLM: I think this can have a default implementation, right?_
245
+ - [ ] ```Extension::minimum_openstudio_version``` _DLM: should we rename? should people overwrite this in their class?_
246
+ - [X] ```Runner::initialize``` _DLM: should say that the path argument should be for a dir with a Gemfile right?_
247
+ - [X] ```Runner::configure_osw``` _DLM: should take in an OSW, add paths to all measure and file dirs for loaded OpenStudio Extensions, write out configured OSW_
248
+ - [ ] Run rubocop on all of the core files and remove exclusion from .rubocop.yml file.
249
+ - [ ] Cleanup task after running tests (may need to be in the OpenStudio Measure Tester)
250
+ - [X] Add a `rake init new_ext_gem` to Rakefile
251
+ - [ ] Add tests to the extension/core