oslg 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0535a05d35fee722c018380a21e3253ce9764058b7092a80ac4904426c9fa243
4
- data.tar.gz: 5919cb3f5ecb420a53c54b5740bf72177077cacb0a3a2cce65647ba12a8b4094
3
+ metadata.gz: 6a72f075eb3b3eb995fe06471af5b8e2bfd56326cc6dd944fd1ee7711d8d14c9
4
+ data.tar.gz: bb2f2143fb8a93f34b5e5b28dc7729d591a0869a05490b77b1165a5dacc23d99
5
5
  SHA512:
6
- metadata.gz: 432dfef35fa88b722c2dff388ebe8f999e4a9bad0aaa987b495006c968572dac98773f5a7659866c3955620622b5b89a3c5544bdad1f577d3feba5bf51796fa5
7
- data.tar.gz: 2696ecd29f72652774d0b6cf5db41a3e4b81af54c4d9a2cd8b64669500085c5d06914744ac061b42e878e3f27c6ac89387b094aeaf08f87b477fd9e2a2e8bef3
6
+ metadata.gz: 5d982229010b326f43b64324eb40811431140a000493f732b773a0736a63d0ffa661455eb2d77fc751beee2a7c05cf411f8bdcd218ccd75a3a9e527e6f29d0cd
7
+ data.tar.gz: aaaf89b502bf30d4091c8eb91e4003a79b6c4b84392611454ee23d3399dc6d4dca680f43afc86128146bff7fba21096147d06dfeca34fcb371bbb7907a2537e3
@@ -39,7 +39,7 @@ jobs:
39
39
  docker exec -t test bundle exec rake
40
40
  docker kill test
41
41
  test_330x:
42
- runs-on: ubuntu-18.04
42
+ runs-on: ubuntu-20.04
43
43
  steps:
44
44
  - name: Check out repository
45
45
  uses: actions/checkout@v2
@@ -55,7 +55,7 @@ jobs:
55
55
  docker exec -t test bundle exec rake
56
56
  docker kill test
57
57
  test_340x:
58
- runs-on: ubuntu-18.04
58
+ runs-on: ubuntu-20.04
59
59
  steps:
60
60
  - name: Check out repository
61
61
  uses: actions/checkout@v2
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # oslg
2
2
 
3
- A logger module for _picky_ [OpenStudio](https://openstudio-sdk-documentation.s3.amazonaws.com/index.html) [Measure](https://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/) developers who wish to select what gets logged to which target (e.g. OpenStudio _runner_ vs custom JSON file). Add:
3
+ A logger module for _picky_ [OpenStudio](https://openstudio.net) [Measure](https://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/) developers who wish to select what gets logged to which target (e.g. OpenStudio _runner_ vs custom JSON file). Add:
4
4
 
5
5
  ```
6
6
  gem "oslg", git: "https://github.com/rd2/oslg", branch: "main"
7
7
  ```
8
8
 
9
- ... in a measure's development environment "Gemfile", and then run:
9
+ ... in a v2.1 [bundled](https://bundler.io) _Measure_ development environment "Gemfile" (or instead as a _gemspec_ dependency), and then run:
10
10
 
11
11
  ```
12
- bundle install
12
+ bundle install (or 'bundle update')
13
13
  ```
14
14
 
15
15
  ### OpenStudio & EnergyPlus
@@ -21,7 +21,7 @@ In most cases, critical (and many non-critical) OpenStudio anomalies will be cau
21
21
  As a Ruby module, one can access __oslg__ by _extending_ a measure module or class:
22
22
 
23
23
  ```
24
- module Modu
24
+ module M
25
25
  extend OSlg
26
26
  ...
27
27
  end
@@ -39,56 +39,56 @@ FATAL
39
39
 
40
40
  DEBUG messages aren't benign at all, but are certainly less informative for the typical Measure user.
41
41
 
42
- Initially, __oslg__ sets 2x internal variable states: `level` (INFO) and `status` (< DEBUG). The variable `level` is a user-set threshold below which less severe logs (e.g. DEBUG) are ignored. For instance, if `level` were _reset_ to DEBUG (e.g. `Modu.reset(Modu::DEBUG)`), then all DEBUG messages would also be logged. The variable `status` is reset with each new log entry if the latter's log level is more severe than its predecessor (e.g. `status == Modu::FATAL` if there is a single log entry registered as FATAL). To check the curent __oslg__ `status` (true or false):
42
+ Initially, __oslg__ sets 2x internal variable states: `level` (INFO) and `status` (< DEBUG). The variable `level` is a user-set threshold below which less severe logs (e.g. DEBUG) are ignored. For instance, if `level` were _reset_ to DEBUG (e.g. `M.reset(M::DEBUG)`), then all DEBUG messages would also be logged. The variable `status` is reset with each new log entry if the latter's log level is more severe than its predecessor (e.g. `status == M::FATAL` if there is a single log entry registered as FATAL). To check the curent __oslg__ `status` (true or false):
43
43
 
44
44
  ```
45
- Modu.debug?
46
- Modu.warn?
47
- Modu.error?
48
- Modu.fatal?
45
+ M.debug?
46
+ M.warn?
47
+ M.error?
48
+ M.fatal?
49
49
  ```
50
50
 
51
- It's sometimes not a bad idea to rely on a _clean_ slate (e.g. within RSpecs). This flushes out all previous logs and resets `level` (INFO) and `status` (< DEBUG) - use with caution in production code!
51
+ It's sometimes not a bad idea to rely on a _clean_ slate (e.g. within RSpecs). The following flushes out all previous logs and resets `level` (INFO) and `status` (< DEBUG) - use with caution in production code!
52
52
 
53
53
  ```
54
- Modu.clean!
54
+ M.clean!
55
55
  ```
56
56
 
57
57
  EnergyPlus will run, with e.g. out-of-range material or fluid properties, while logging ERROR messages in the process. It remains up to users to decide what to do with simulation results. We recommend something similar with __oslg__. For instance, we suggest logging as __FATAL__ any error that should halt measure processes and prevent OpenStudio from launching an EnergyPlus simulation. This could be missing or poorly-defined OpenStudio files.
58
58
 
59
59
  ```
60
- Modu.log(Modu::FATAL, "Missing input JSON file")
60
+ M.log(M::FATAL, "Missing input JSON file")
61
61
  ```
62
62
 
63
63
  Consider logging non-fatal __ERROR__ messages when encountering invalid OpenStudio file entries, i.e. well-defined, yet invalid vis-à-vis EnergyPlus limitations. The invalid object could be simply ignored, while the measure pursues its (otherwise valid) calculations ... with OpenStudio ultimately launching an EnergyPlus simulation. If a simulation indeed ran (ultimately a go/no-go decision made by the EnergyPlus simulation engine), it would be up to users to decide if simulation results were valid or useful, given the context - maybe based on __oslg__ logged messages. In short, non-fatal ERROR logs should ideally point to bad input users can fix.
64
64
 
65
65
  ```
66
- Modu.log(Modu::ERROR, "Measure won't process MASSLESS materials")
66
+ M.log(M::ERROR, "Measure won't process MASSLESS materials")
67
67
  ```
68
68
 
69
69
  A __WARNING__ could be triggered from inherit limitations of the underlying measure scope or methodology (something users may have little knowledge of beforehand). For instance, surfaces the size of dinner plates are often artifacts of poor 3D model design. It's usually not a good idea to have such small surfaces in an OpenStudio model, but neither OpenStudio nor EnergyPlus will necessarily warn users of such occurrences. It's up to users to decide on the suitable course of action.
70
70
 
71
71
  ```
72
- Modu.log(Modu::WARN, "Surface area < 100cm2")
72
+ M.log(M::WARN, "Surface area < 100cm2")
73
73
  ```
74
74
 
75
75
  There's also the possibility of logging __INFO__-rmative messages for users, e.g. the final state of a measure variable before exiting.
76
76
 
77
77
  ```
78
- Modu.log(Modu::INFO, "Envelope compliant to prescriptive code requirements")
78
+ M.log(M::INFO, "Envelope compliant to prescriptive code requirements")
79
79
  ```
80
80
 
81
81
  Finally, a number of sanity checks are likely warranted to ensure Ruby doesn't crash (e.g., invalid access to uninitialized variables), especially for lower-level functions. We suggest implementing safe fallbacks when this occurs, but __DEBUG__ errors could nonetheless be triggered to signal a bug.
82
82
 
83
83
  ```
84
- Modu.log(Modu::DEBUG, "Hash? expecting Array (method)")
84
+ M.log(M::DEBUG, "Hash? expecting Array (method)")
85
85
  ```
86
86
 
87
87
  All log entries are stored in a single Ruby _Array_, with each individual log entry as a Ruby _Hash_ with 2x _keys_ ```:level``` and ```:message```, e.g.:
88
88
 
89
89
  ```
90
- Modu.logs.each do |log|
91
- puts "Uh-oh: #{log[:message]}" if log[:level] > Modu::INFO
90
+ M.logs.each do |log|
91
+ puts "Uh-oh: #{log[:message]}" if log[:level] > M::INFO
92
92
  end
93
93
  ```
94
94
 
@@ -100,19 +100,19 @@ Typically, developers would first catch bad input, log an error message and poss
100
100
 
101
101
  ```
102
102
  unless var.is_a?(Array)
103
- Modu.log(Modu::DEBUG, "#{var.class}? expecting Array (method)")
103
+ M.log(M::DEBUG, "#{var.class}? expecting Array (method)")
104
104
  return false
105
105
  end
106
106
  ```
107
107
 
108
- The following are __oslg__ one-liner methods that _log & return_ in one go. These are for some of the most common checks OpenStudio SDK Ruby developers are likely to need. These methods require _valid_ arguments for __oslg__ to actually log. Although often expecting strings as arguments, the methods will try to convert other types to strings (e.g. classes, numbers, even entire arrays) if possible.
108
+ The following are __oslg__ one-liner methods that _log & return_ in one go. These are for some of the most common checks OpenStudio SDK Ruby developers are likely to need. The methods require _valid_ arguments for __oslg__ to actually log. Although often expecting strings as arguments, the methods will try to convert other types to strings (e.g. classes, numbers, even entire arrays) if possible.
109
109
 
110
110
  ---
111
111
 
112
112
  __invalid__: for logging e.g. uninitialized or nilled objects:
113
113
 
114
114
  ```
115
- return Modu.invalid("area", "sum", 0, Modu::ERROR, false) unless area
115
+ return M.invalid("area", "sum", 0, M::ERROR, false) unless area
116
116
  ```
117
117
 
118
118
  This logs an ERROR message informing users that an invalid object, 'area', was caught while running method 'sum', and then exits by returning _false_. The logged message would be:
@@ -125,8 +125,8 @@ The 3rd argument (e.g. _0_) is ignored unless `> 0` - a useful option when asser
125
125
 
126
126
  ```
127
127
  def sum(areas, units)
128
- return Modu.invalid("areas", "sum", 1) unless areas
129
- return Modu.invalid("units", "sum", 2) unless units
128
+ return M.invalid("areas", "sum", 1) unless areas
129
+ return M.invalid("units", "sum", 2) unless units
130
130
  ...
131
131
  end
132
132
  ```
@@ -144,7 +144,7 @@ The first 2x __invalid__ method arguments (faulty object ID, calling method ID)
144
144
  __mismatch__: for logging incompatible instances vs classes:
145
145
 
146
146
  ```
147
- return Modu.mismatch("areas", areas, Array, "sum") unless areas.is_a?(Array)
147
+ return M.mismatch("areas", areas, Array, "sum") unless areas.is_a?(Array)
148
148
  ```
149
149
 
150
150
  If 'areas' were a _String_, __mismatch__ would generate the following DEBUG log message (before returning _nil_):
@@ -153,30 +153,30 @@ If 'areas' were a _String_, __mismatch__ would generate the following DEBUG log
153
153
  "'areas' String? expecting Array (sum)"
154
154
  ```
155
155
 
156
- These 4x __mismatch__ arguments are required (an object ID, a valid Ruby object, the mismatched Ruby class, and the calling method ID). As a safeguard, __oslg__ will NOT log a _mismatch_ if the object is an actual instance of the class. As with __invalid__, there are 2x optional _terminal_ arguments, e.g. `Modu::ERROR, false)`.
156
+ These 4x __mismatch__ arguments are required (an object ID, a valid Ruby object, the mismatched Ruby class, and the calling method ID). As a safeguard, __oslg__ will NOT log a _mismatch_ if the object is an actual instance of the class. As with __invalid__, there are 2x optional _terminal_ arguments, e.g. `M::ERROR, false)`.
157
157
 
158
158
  ---
159
159
 
160
160
  __hashkey__: for logging missing _Hash_ keys:
161
161
 
162
162
  ```
163
- return Modu.hashkey("faces", faces, :area, "sum") unless faces.key?(:area)
163
+ return M.hashkey("faces", faces, :area, "sum") unless faces.key?(:area)
164
164
  ```
165
165
 
166
- If the _Hash_ `faces` does not hold `:area` as one of its keys, then __mismatch__ would generate the following DEBUG log message (before returning _nil_):
166
+ If the _Hash_ `faces` does not hold `:area` as one of its keys, then __hashkey__ would generate the following DEBUG log message (before returning _nil_):
167
167
 
168
168
  ```
169
169
  "'faces' Hash: no key 'area' (sum)"
170
170
  ```
171
171
 
172
- Similar to __mismatch__, the method __hashkey__ requires 4x arguments (a _Hash_ ID, a valid Ruby _Hash_, the missing _key_, and the calling method ID). There are also 2x optional _terminal_ arguments, e.g. `Modu::ERROR, false)`.
172
+ Similar to __mismatch__, the method __hashkey__ requires 4x arguments (a _Hash_ ID, a valid Ruby _Hash_, the missing _key_, and the calling method ID). There are also 2x optional _terminal_ arguments, e.g. `M::ERROR, false)`.
173
173
 
174
174
  ---
175
175
 
176
176
  __empty__: for logging empty _Enumerable_ (e.g. _Array_, _Hash_) instances or uninitialized boost optionals (e.g. uninitialized _ThermalZone_ object of an _OpenStudio Space_):
177
177
 
178
178
  ```
179
- return Modu.empty("faces", "sum", Modu::ERROR, false) if faces.empty?
179
+ return M.empty("faces", "sum", M::ERROR, false) if faces.empty?
180
180
  ```
181
181
 
182
182
  An empty `faces` _Hash_ would generate the following ERROR log message (before returning _false_):
@@ -192,8 +192,8 @@ Again, the first 2x arguments are required; the last 2x are optional.
192
192
  __zero__: for logging zero'ed (or nearly-zero'ed) values:
193
193
 
194
194
  ```
195
- Modu.zero("area", "sum", Modu::FATAL, false) if area.zero?
196
- Modu.zero("area", "sum", Modu::FATAL, false) if area.abs < TOL
195
+ M.zero("area", "sum", M::FATAL, false) if area.zero?
196
+ M.zero("area", "sum", M::FATAL, false) if area.abs < TOL
197
197
  ```
198
198
  ... generating the following FATAL log message (before returning _false_):
199
199
 
@@ -209,7 +209,7 @@ And again, the first 2x arguments are required; the last 2x are optional.
209
209
  __negative__: for logging negative (< 0) values:
210
210
 
211
211
  ```
212
- Modu.negative("area", "sum", Modu::FATAL, false) if area < 0
212
+ M.negative("area", "sum", M::FATAL, false) if area < 0
213
213
  ```
214
214
  ... generating this FATAL log message (before returning _false_):
215
215
 
@@ -218,3 +218,7 @@ Modu.negative("area", "sum", Modu::FATAL, false) if area < 0
218
218
  ```
219
219
 
220
220
  You guessed it: the first 2x arguments are required; the last 2x as optionals.
221
+
222
+ ---
223
+
224
+ Look up the full __oslg__ API [here](https://www.rubydoc.info/gems/oslg).
data/Rakefile CHANGED
@@ -3,9 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- require "yard"
7
- YARD::Rake::YardocTask.new do |t|
8
- t.files = ["lib/oslg/oslog.rb"]
9
- end
10
-
11
6
  task default: :spec
data/lib/oslg/version.rb CHANGED
@@ -29,5 +29,5 @@
29
29
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
 
31
31
  module OSlg
32
- VERSION = "0.2.2".freeze
32
+ VERSION = "0.2.3".freeze
33
33
  end
data/oslg.gemspec CHANGED
@@ -6,14 +6,17 @@ Gem::Specification.new do |s|
6
6
  # Specify which files should be added to the gem when it is released.
7
7
  # "git ls-files -z" loads files in the RubyGem that have been added into git.
8
8
  s.files = Dir.chdir(File.expand_path("..", __FILE__)) do
9
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
9
+ `git ls-files -z`.split("\x0").reject do |f|
10
+ f.match(%r{^(test|spec|features)/})
11
+ end
10
12
  end
11
13
 
12
14
  s.name = "oslg"
13
15
  s.version = OSlg::VERSION
14
16
  s.license = "BSD-3-Clause"
15
17
  s.summary = "OpenStudio SDK logger"
16
- s.description = "For SDK users who select what's logged where."
18
+ s.description = "For OpenStudio SDK users who wish to select " \
19
+ "what gets logged to which target."
17
20
  s.authors = ["Denis Bourgeois"]
18
21
  s.email = ["denis@rd2.ca"]
19
22
  s.platform = Gem::Platform::RUBY
@@ -27,7 +30,6 @@ Gem::Specification.new do |s|
27
30
  s.add_development_dependency "bundler", "~> 2.1"
28
31
  s.add_development_dependency "rake", "~> 13.0"
29
32
  s.add_development_dependency "rspec", "~> 3.11"
30
- s.add_development_dependency "yard", "~> 0.9"
31
33
 
32
34
  s.metadata["homepage_uri"] = s.homepage
33
35
  s.metadata["source_code_uri"] = "#{s.homepage}/tree/v#{s.version}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oslg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Bourgeois
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,21 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.11'
55
- - !ruby/object:Gem::Dependency
56
- name: yard
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.9'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.9'
69
- description: For SDK users who select what's logged where.
55
+ description: For OpenStudio SDK users who wish to select what gets logged to which
56
+ target.
70
57
  email:
71
58
  - denis@rd2.ca
72
59
  executables: []
@@ -89,7 +76,7 @@ licenses:
89
76
  - BSD-3-Clause
90
77
  metadata:
91
78
  homepage_uri: https://github.com/rd2/oslg
92
- source_code_uri: https://github.com/rd2/oslg/tree/v0.2.2
79
+ source_code_uri: https://github.com/rd2/oslg/tree/v0.2.3
93
80
  bug_tracker_uri: https://github.com/rd2/oslg/issues
94
81
  post_install_message:
95
82
  rdoc_options: []