buildingsync 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/continuous_integration.yml +146 -0
  3. data/.gitignore +33 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +10 -0
  6. data/CHANGELOG.md +50 -0
  7. data/Gemfile +31 -0
  8. data/Jenkinsfile +10 -0
  9. data/LICENSE.md +29 -0
  10. data/README.md +105 -0
  11. data/Rakefile +77 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/buildingsync.gemspec +37 -0
  15. data/config.rb.in +26 -0
  16. data/doc_templates/LICENSE.md +29 -0
  17. data/doc_templates/README.md.erb +42 -0
  18. data/doc_templates/copyright_erb.txt +38 -0
  19. data/doc_templates/copyright_js.txt +5 -0
  20. data/doc_templates/copyright_ruby.txt +36 -0
  21. data/lib/buildingsync.rb +43 -0
  22. data/lib/buildingsync/all_resource_total.rb +54 -0
  23. data/lib/buildingsync/audit_date.rb +54 -0
  24. data/lib/buildingsync/constants.rb +49 -0
  25. data/lib/buildingsync/contact.rb +54 -0
  26. data/lib/buildingsync/extension.rb +57 -0
  27. data/lib/buildingsync/generator.rb +584 -0
  28. data/lib/buildingsync/get_bcl_weather_file.rb +326 -0
  29. data/lib/buildingsync/helpers/Model.hvac.rb +216 -0
  30. data/lib/buildingsync/helpers/helper.rb +494 -0
  31. data/lib/buildingsync/helpers/xml_get_set.rb +215 -0
  32. data/lib/buildingsync/makers/phase_zero_base.osw +178 -0
  33. data/lib/buildingsync/makers/workflow_maker.json +811 -0
  34. data/lib/buildingsync/makers/workflow_maker.rb +581 -0
  35. data/lib/buildingsync/makers/workflow_maker_base.rb +167 -0
  36. data/lib/buildingsync/model_articulation/building.rb +1119 -0
  37. data/lib/buildingsync/model_articulation/building_and_system_types.json +121 -0
  38. data/lib/buildingsync/model_articulation/building_section.rb +190 -0
  39. data/lib/buildingsync/model_articulation/building_system.rb +49 -0
  40. data/lib/buildingsync/model_articulation/envelope_system.rb +102 -0
  41. data/lib/buildingsync/model_articulation/exterior_floor_system_type.rb +64 -0
  42. data/lib/buildingsync/model_articulation/facility.rb +439 -0
  43. data/lib/buildingsync/model_articulation/foundation_system_type.rb +64 -0
  44. data/lib/buildingsync/model_articulation/hvac_system.rb +395 -0
  45. data/lib/buildingsync/model_articulation/lighting_system.rb +102 -0
  46. data/lib/buildingsync/model_articulation/loads_system.rb +287 -0
  47. data/lib/buildingsync/model_articulation/location_element.rb +129 -0
  48. data/lib/buildingsync/model_articulation/measure.rb +57 -0
  49. data/lib/buildingsync/model_articulation/roof_system_type.rb +64 -0
  50. data/lib/buildingsync/model_articulation/service_hot_water_system.rb +87 -0
  51. data/lib/buildingsync/model_articulation/site.rb +242 -0
  52. data/lib/buildingsync/model_articulation/spatial_element.rb +343 -0
  53. data/lib/buildingsync/model_articulation/wall_system_type.rb +64 -0
  54. data/lib/buildingsync/report.rb +217 -0
  55. data/lib/buildingsync/resource_use.rb +55 -0
  56. data/lib/buildingsync/scenario.rb +622 -0
  57. data/lib/buildingsync/selection_tool.rb +98 -0
  58. data/lib/buildingsync/time_series.rb +85 -0
  59. data/lib/buildingsync/translator.rb +167 -0
  60. data/lib/buildingsync/utility.rb +67 -0
  61. data/lib/buildingsync/version.rb +45 -0
  62. metadata +223 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5149ec80301b45d4d0c933059ebdfbb18f1ba987d604d3df5cf6c7b8f4d10b8
4
+ data.tar.gz: e67bd524c2f3386313ea3a0089a8f49cf8b5b4c0eb6cd832014c692b5c8b3f08
5
+ SHA512:
6
+ metadata.gz: 07db8576a601b662692cb5a10e6386b951acb27788af712ed383e7eae60f4489830e57066bab1b260fc6fa74fe63c27cdc6c0e2b713f96014e88c8682913c5dc
7
+ data.tar.gz: 481a3639e0aa4437a3fbe6f6e7bf9bde57f530f2a021cd3a10b49393b5360932e5fdf9df3bd14f8614242254d75bd8466aa269f0b561af0f1096a04377e46472
@@ -0,0 +1,146 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+
7
+ jobs:
8
+ model_articulation_tests:
9
+ name: Model Articulation Tests
10
+ container: nrel/openstudio:3.0.1
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout Code
14
+ uses: actions/checkout@v2
15
+ - name: Setup
16
+ run: |
17
+ gem install bundler
18
+ bundle install
19
+ - name: Building Section Spec
20
+ run: bundle exec rspec spec/tests/model_articulation_test/building_section_spec.rb
21
+ if: always()
22
+ - name: Building Spec
23
+ run: bundle exec rspec spec/tests/model_articulation_test/building_spec.rb
24
+ if: always()
25
+ - name: Envelope System Spec
26
+ run: bundle exec rspec spec/tests/model_articulation_test/envelope_system_spec.rb
27
+ if: always()
28
+ - name: Facility Spec
29
+ run: bundle exec rspec spec/tests/model_articulation_test/facility_spec.rb
30
+ if: always()
31
+ - name: HVAC System Spec
32
+ run: bundle exec rspec spec/tests/model_articulation_test/hvac_system_spec.rb
33
+ if: always()
34
+ - name: Loads System Spec
35
+ run: bundle exec rspec spec/tests/model_articulation_test/loads_system_spec.rb
36
+ if: always()
37
+ - name: Lighting System Spec
38
+ run: bundle exec rspec spec/tests/model_articulation_test/lighting_system_type_spec.rb
39
+ if: always()
40
+ - name: SHW System Spec
41
+ run: bundle exec rspec spec/tests/model_articulation_test/service_hot_water_system_spec.rb
42
+ if: always()
43
+ - name: Site Spec
44
+ run: bundle exec rspec spec/tests/model_articulation_test/site_spec.rb
45
+ if: always()
46
+ - name: Hospital Occupancy Type Spec
47
+ run: bundle exec rspec spec/tests/model_articulation_test/hospital_occupancy_type_spec.rb
48
+ if: always()
49
+ - name: Occupancy Types Spec
50
+ run: bundle exec rspec spec/tests/model_articulation_test/occupancy_types_spec.rb
51
+ if: always()
52
+ # Fails sometimes due to connection issues, so we exclude it here
53
+ # - name: Weather File Download
54
+ # run: bundle exec rspec spec/tests/model_articulation_test/weather_file_download_spec.rb
55
+ # if: always()
56
+
57
+ translator_tests:
58
+ name: Translator Tests
59
+ container: nrel/openstudio:3.0.1
60
+ runs-on: ubuntu-latest
61
+ steps:
62
+ - name: Checkout Code
63
+ uses: actions/checkout@v2
64
+ - name: Setup
65
+ run: |
66
+ gem install bundler
67
+ bundle install
68
+ - name: Translator Example Spec
69
+ run: bundle exec rspec spec/tests/translator_spec.rb
70
+ if: always()
71
+ - name: Translator Sizing Run Spec
72
+ run: bundle exec rspec spec/tests/translator_sizing_run_spec.rb
73
+ if: always()
74
+ - name: Translator Scenario Generation Specs
75
+ run: bundle exec rspec spec/tests/translator_scenario_generation_spec.rb
76
+ if: always()
77
+ - name: Translator Scenario Simulation Spec
78
+ run: bundle exec rspec spec/tests/translator_scenario_simulations_spec.rb
79
+ if: always()
80
+
81
+ report_and_scenario_tests:
82
+ name: Report and Scenario Tests
83
+ container: nrel/openstudio:3.0.1
84
+ runs-on: ubuntu-latest
85
+ steps:
86
+ - name: Checkout Code
87
+ uses: actions/checkout@v2
88
+ - name: Setup
89
+ run: |
90
+ gem install bundler
91
+ bundle install
92
+ - name: Report Spec
93
+ run: bundle exec rspec spec/tests/report_spec.rb
94
+ if: always()
95
+ - name: Utility Spec
96
+ run: bundle exec rspec spec/tests/utility_spec.rb
97
+ if: always()
98
+ - name: Scenario Spec
99
+ run: bundle exec rspec spec/tests/scenario_spec.rb
100
+ if: always()
101
+ - name: TimeSeries Spec
102
+ run: bundle exec rspec spec/tests/time_series_spec.rb
103
+ if: always()
104
+ - name: ResourceUse Spec
105
+ run: bundle exec rspec spec/tests/resource_use_spec.rb
106
+ if: always()
107
+ - name: AllResourceTotal Spec
108
+ run: bundle exec rspec spec/tests/all_resource_total_spec.rb
109
+ if: always()
110
+ - name: WorkflowMaker Spec
111
+ run: bundle exec rspec spec/tests/workflow_maker_spec.rb
112
+ if: always()
113
+
114
+ other_specs:
115
+ name: Other Tests
116
+ container: nrel/openstudio:3.0.1
117
+ runs-on: ubuntu-latest
118
+ steps:
119
+ - name: Checkout Code
120
+ uses: actions/checkout@v2
121
+ - name: Setup
122
+ run: |
123
+ gem install bundler
124
+ bundle install
125
+ - name: BuildingSync Spec
126
+ run: bundle exec rspec spec/tests/building_sync_spec.rb
127
+ if: always()
128
+ - name: EPW Test Spec
129
+ run: bundle exec rspec spec/tests/epw_test_spec.rb
130
+ if: always()
131
+ - name: Constants Spec
132
+ run: bundle exec rspec spec/tests/constants_spec.rb
133
+ if: always()
134
+ - name: Generator Spec
135
+ run: bundle exec rspec spec/tests/generator_spec.rb
136
+ if: always()
137
+ - name: Helper Spec
138
+ run: bundle exec rspec spec/tests/helper_spec.rb
139
+ if: always()
140
+ - name: XMLGetSet Spec
141
+ run: bundle exec rspec spec/tests/xml_get_set_spec.rb
142
+ if: always()
143
+ # selection tool is not working with ASHRAE level 1.5 yet
144
+ # - name: Selection Tool Spec
145
+ # run: bundle exec rspec spec/tests/selection_tool_spec.rb
146
+ # if: always()
@@ -0,0 +1,33 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.ruby-version
4
+ /.python-version
5
+ /Gemfile.lock
6
+ /gems
7
+ /_yardoc/
8
+ /coverage/
9
+ /doc/
10
+ /pkg/
11
+ /spec/reports/
12
+ /tmp/
13
+ /spec/output/
14
+ /SR1
15
+ /SRvt
16
+ .DS_Store
17
+
18
+ # rspec failure tracking
19
+ .rspec_status
20
+
21
+ # Ignore IDE files
22
+ /.idea
23
+ *.rubocop-http*
24
+
25
+ # measures tests
26
+ lib/measures/.rubocop.yml
27
+ lib/measures/test_results/*
28
+
29
+ spec/files/filecomparison/in.idf
30
+ spec/files/filecomparison/in.osm
31
+ spec/weather/weather_file.json
32
+
33
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ Exclude:
3
+ - gems/**/*
4
+ - measures/**/*
5
+ - spec/files/**/measures/**/*
6
+
7
+
8
+ inherit_from:
9
+ - http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
10
+
@@ -0,0 +1,50 @@
1
+ # BuildingSync Gem
2
+
3
+ ## Version 0.2.0
4
+
5
+ This is released as a minor version since we are so early stage, even though it has many breaking changes. Most of the 'high-level API' (translator) remains.
6
+
7
+ - Added many BuildingSync specific classes:
8
+ - AllResourceTotal
9
+ - AuditDate
10
+ - Contact
11
+ - Report
12
+ - ResourceUse
13
+ - Scenario
14
+ - TimeSeries
15
+ - Utility
16
+
17
+ - Major modifications to:
18
+ - WorkflowMaker
19
+ - Building
20
+ - BuildingSection
21
+ - Facility
22
+ - HVACSystem
23
+ - LightingSystem
24
+ - LoadsSystem
25
+ - Site
26
+ - SpatialElement
27
+ - Translator
28
+
29
+ - Added / modified modules / classes:
30
+ - Generator
31
+ - Helper
32
+ - XmlGetSet: many useful functions to get / set XML data given a base_xml
33
+ - LocationElement
34
+
35
+ - Removed Classes:
36
+ - ModelMakerBase
37
+ - ModelMaker
38
+ - MeteredEnergy
39
+
40
+ - Added `constants.rb`
41
+ - Renamed `bldg_and_system_types.json1` -> `building_and_system_types.json`
42
+ - Removed redundant / unused XML files
43
+ - Updated files to comply with specific BSync versions (v2.1.0, v2.2.0)
44
+ - Significantly more testing
45
+
46
+ ## Version 0.1.0
47
+
48
+ * Initial release
49
+ * Support Level 0 (walkthrough), Level 1, and simplified Level 2 energy audits specified by ASHRAE Standard 211-2018.
50
+ * Support Office, Retail, and Hotel Building Types
data/Gemfile ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ # Local gems are useful when developing and integrating the various dependencies.
8
+ # To favor the use of local gems, set the following environment variable:
9
+ # Mac: export FAVOR_LOCAL_GEMS=1
10
+ # Windows: set FAVOR_LOCAL_GEMS=1
11
+ # Note that if allow_local is true, but the gem is not found locally, then it will
12
+ # checkout the latest version (develop) from github.
13
+ allow_local = ENV['FAVOR_LOCAL_GEMS']
14
+
15
+ if allow_local && File.exist?('../openstudio-common-measures-gem')
16
+ gem 'openstudio-common-measures', path: '../openstudio-common-measures-gem'
17
+ else
18
+ gem 'openstudio-common-measures', github: 'NREL/openstudio-common-measures-gem', tag: 'v0.2.1'
19
+ end
20
+
21
+ if allow_local && File.exist?('../openstudio-model-articulation-gem')
22
+ gem 'openstudio-model-articulation', path: '../openstudio-model-articulation-gem'
23
+ else
24
+ gem 'openstudio-model-articulation', github: 'NREL/openstudio-model-articulation-gem', tag: 'v0.2.1'
25
+ end
26
+
27
+ if allow_local && File.exist?('../openstudio-ee-gem')
28
+ gem 'openstudio-ee', path: '../openstudio-ee-gem'
29
+ else
30
+ gem 'openstudio-ee', github: 'NREL/openstudio-ee-gem', tag: 'v0.2.1'
31
+ end
@@ -0,0 +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
+ building_sync_gems()
9
+
10
+ }
@@ -0,0 +1,29 @@
1
+ OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC. All rights reserved.
2
+ BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC. All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted
5
+ provided that the following conditions are met:
6
+
7
+ (1) Redistributions of source code must retain the above copyright notice, this list of conditions
8
+ and the following disclaimer.
9
+
10
+ (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11
+ and the following disclaimer in the documentation and/or other materials provided with the distribution.
12
+
13
+ (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse
14
+ or promote products derived from this software without specific prior written permission from the
15
+ respective party.
16
+
17
+ (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other
18
+ derivative works may not use the "OpenStudio" or "BuildingSync" trademarks, "OS", "os", "BSync" or any
19
+ other confusingly similar designation without specific prior written permission from Alliance for
20
+ Sustainable Energy, LLC.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
23
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT,
25
+ OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
27
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,105 @@
1
+ # BuildingSync
2
+
3
+ The BuildingSync-Gem is a repository of helpers for reading and writing BuildingSync XML files, and for using that data to drive energy simulations of the subject building. See full documentation on [RubyDoc](https://www.rubydoc.info/github/BuildingSync/BuildingSync-gem).
4
+
5
+ All of the following are supported:
6
+
7
+ * convert BuildingSync XML file into:
8
+
9
+ * an OpenStudio Baseline model
10
+
11
+ * an OpenStudio workflow for each scenario defined in the XML file
12
+
13
+ * enables simulation of the baseline model and all workflows and
14
+
15
+ * insert simulation results back into the Building XML file.
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'buildingsync'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install 'buildingsync'
32
+
33
+ ## Usage
34
+
35
+ All of the features described above are provided by the translator class, as shown in the following sample code:
36
+
37
+ ```ruby
38
+ building_sync_xml_file_path = 'path/to/bsync.xml'
39
+ out_path = 'path/to/output_dir'
40
+
41
+ # initializing the translator
42
+ translator = BuildingSync::Translator.new(building_sync_xml_file_path, out_path)
43
+
44
+ # generating the OpenStudio Model and writing the osm file.
45
+ # path/to/output_dir/SR and path/to/output_dir/in.osm created
46
+ translator.setup_and_sizing_run
47
+
48
+ # generating the OpenStudio workflows and writing the osw files
49
+ # auc:Scenario elements with measures are turned into new simulation dirs
50
+ # path/to/output_dir/scenario_name
51
+ translator.write_osws
52
+
53
+
54
+ # run all simulations
55
+ translator.run_osws
56
+
57
+ # gather the results for all scenarios found in out_path,
58
+ # such as annual and monthly data for different energy
59
+ # sources (electricity, natural gas, etc.)
60
+ translator.gather_results(out_path)
61
+
62
+ # Add in UserDefinedFields, which contain information about the
63
+ # OpenStudio model run
64
+ translator.prepare_final_xml
65
+
66
+ # write results to xml
67
+ # default file name is 'results.xml'
68
+ file_name = 'abc-123.xml'
69
+ translator.save_xml(file_name)
70
+ ```
71
+ ## Testing
72
+
73
+ Check out the repository and then execute:
74
+
75
+ $ bundle install
76
+
77
+ $ bundle exec rake
78
+
79
+ ## Documentation
80
+
81
+ The documentation of the BuildingSync-Gem is done with Yard (https://yardoc.org)
82
+ To generate the documentation locally do the following:
83
+
84
+ $ gem install yard
85
+
86
+ $ yardoc - README.md
87
+
88
+ ## Updating published documentation
89
+ Publish documentation for each release:
90
+
91
+ 1. Tag release on GitHub
92
+ 1. Go to [rubydoc.info](https://www.rubydoc.info) and click `Add Project` in the upper right
93
+ 1. Input the git address: `git://github/BuildingSync/BuildingSync-gem.git`
94
+ 1. Input the release tag for the desired version, eg: `v0.2.0`
95
+ 1. Click `Go`
96
+ 1. Profit
97
+
98
+ # Releasing
99
+
100
+ 1. Update CHANGELOG.md
101
+ 1. Run `bundle exec rake rubocop:auto_correct`
102
+ 1. Update version in `/lib/buildingsync/version.rb`
103
+ 1. Create PR to main, after tests and reviews complete, then merge
104
+ 1. Locally - from the main branch, run `bundle exec rake release`
105
+ 1. On GitHub, go to the releases page and update the latest release tag. Name it “Version x.y.z” and copy the CHANGELOG entry into the description box.
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # *******************************************************************************
4
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
5
+ # All rights reserved.
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # (1) Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # (3) Neither the name of the copyright holder nor the names of any contributors
17
+ # may be used to endorse or promote products derived from this software without
18
+ # specific prior written permission from the respective party.
19
+ #
20
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
21
+ # of modifications or other derivative works may not use the "OpenStudio"
22
+ # trademark, "OS", "os", or any other confusingly similar designation without
23
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
24
+ #
25
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
26
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
29
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
30
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
32
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+ # *******************************************************************************
37
+
38
+ require 'bundler/gem_tasks'
39
+ require 'rspec/core/rake_task'
40
+
41
+ RSpec::Core::RakeTask.new(:spec)
42
+
43
+ require 'rubocop/rake_task'
44
+ RuboCop::RakeTask.new
45
+
46
+ # Load in the rake tasks from the base extension gem
47
+ require 'openstudio/extension/rake_task'
48
+ require 'openstudio/model_articulation'
49
+ rake_task = OpenStudio::Extension::RakeTask.new
50
+ rake_task.set_extension_class(OpenStudio::ModelArticulation::Extension)
51
+
52
+ desc 'Convert tabs to spaces'
53
+ task :remove_tabs do
54
+ Dir['examples/**/*.xml', 'BuildingSync.xsd'].each do |file|
55
+ puts " Cleaning #{file}"
56
+ doc = Nokogiri.XML(File.read(file)) do |config|
57
+ config.default_xml.noblanks
58
+ end
59
+
60
+ doc.xpath('//comment()').each do |node|
61
+ if node.text.match?(/XMLSpy/)
62
+ node.remove
63
+ end
64
+ end
65
+
66
+ File.open(file, 'w') { |f| f << doc.to_xml(indent: 2) }
67
+ end
68
+
69
+ if File.exist? 'BuildingSync.json'
70
+ f = JSON.parse(File.read('BuildingSync.json'))
71
+ File.open('BuildingSync.json', 'w') do |file|
72
+ file << JSON.pretty_generate(f)
73
+ end
74
+ end
75
+ end
76
+
77
+ task default: :spec