xeme 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +44 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f0167b2bc464df9ea9f19613a320fdae68341e4da43fba5a85f4c5d0644c5e7
|
4
|
+
data.tar.gz: 9a74cb9a9026cc9f3877c4232301fb88d611634f38ac755007cb56e76ffde52c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d563da48a8c9a49ba3b5e9cec5da9843e84bf32ca28032699cd9ee94f38e9d9a422fe27aa03b10d852a1ad00a22bcf3e4097620fd68bdcb617e6789401ff2a9
|
7
|
+
data.tar.gz: 732c7cf90ed366fefa4bc9c3ac5abf3128e83ac3da33c0819af172b6683993250e118d7407e0d7fafe9459f566d5b70e66d9b87271881ef7fb31263583f4217c
|
data/README.md
CHANGED
@@ -109,7 +109,7 @@ The usual:
|
|
109
109
|
gem install xeme
|
110
110
|
```
|
111
111
|
|
112
|
-
###
|
112
|
+
### Basic Xeme concepts
|
113
113
|
|
114
114
|
Xeme (the gem) is a thin layer over a hash that implements the Xeme format. (For
|
115
115
|
the rest of this document "Xeme" refers to the Ruby class, not the format.)
|
@@ -138,7 +138,7 @@ xeme['errors'] = []
|
|
138
138
|
xeme['errors'].push({'id'=>'my-error'})
|
139
139
|
```
|
140
140
|
|
141
|
-
|
141
|
+
### Success and failure
|
142
142
|
|
143
143
|
Because a xeme isn't considered successful until it has been explicitly declared
|
144
144
|
so, a new xeme is considered to indicate failure. However, because there are no
|
@@ -188,7 +188,7 @@ xeme.try_succeed
|
|
188
188
|
puts xeme.success? # => false
|
189
189
|
```
|
190
190
|
|
191
|
-
|
191
|
+
### Creating and using messages
|
192
192
|
|
193
193
|
Messages in a xeme provide a way to indicate errors (i.e. fatal errors),
|
194
194
|
warnings (non-fatal errors), notes (not an error at all), and promises (guides
|
@@ -206,12 +206,12 @@ xeme.note 'my-note'
|
|
206
206
|
xeme.promise 'my-promise'
|
207
207
|
```
|
208
208
|
|
209
|
-
|
210
|
-
Although it is not required, it's usually a good idea to give a string
|
211
|
-
first parameter. That string will be set to the `id` element in the
|
212
|
-
hash, as seen in the example above.
|
209
|
+
`#error`, `#warning`, `#note`, and `#promise` each create a message for their
|
210
|
+
own type. Although it is not required, it's usually a good idea to give a string
|
211
|
+
as the first parameter. That string will be set to the `id` element in the
|
212
|
+
resulting hash, as seen in the example above.
|
213
213
|
|
214
|
-
|
214
|
+
`#errors`, `#warnings`, `#notes`, and `#promises` return arrays for each type.
|
215
215
|
|
216
216
|
```ruby
|
217
217
|
xeme.errors.each do |e|
|
@@ -261,7 +261,39 @@ err['database-error'] = 'some database error'
|
|
261
261
|
err['commands'] = ['a', 'b', 'c']
|
262
262
|
```
|
263
263
|
|
264
|
-
|
264
|
+
### Creating metainformation
|
265
|
+
|
266
|
+
The `#meta` method returns the `meta` element in the xeme hash, creating it if
|
267
|
+
necessary. The hash will be automatically populated with a timestamp and a UUID.
|
268
|
+
If you gave the xeme an identifier when you created it, that id will stored in
|
269
|
+
the meta hash:
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
xeme = Xeme.new('my-xeme')
|
273
|
+
puts xeme.meta
|
274
|
+
```
|
275
|
+
|
276
|
+
This produces a `meta` hash like this:
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
{
|
280
|
+
"uuid"=>"4e736a8f-314e-470a-8209-6811a7b2d38c",
|
281
|
+
"timestamp"=>2023-05-29 19:22:37.26152866 -0400,
|
282
|
+
"id"=>"my-xeme"
|
283
|
+
}
|
284
|
+
```
|
285
|
+
|
286
|
+
If you don't pass in an id then the meta hash isn't created. However, you can
|
287
|
+
always create and use the meta hash by calling the `#meta` method. The timestamp
|
288
|
+
and UUID will be automatically created.
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
xeme = Xeme.new
|
292
|
+
xeme.meta['foo'] = 'bar'
|
293
|
+
xeme.meta.class # => Hash
|
294
|
+
```
|
295
|
+
|
296
|
+
### Nesting xemes
|
265
297
|
|
266
298
|
In complex testing situations it can be useful to nest results within other
|
267
299
|
results. To nest a xeme within another xeme, use the `#nest` method:
|
@@ -332,7 +364,7 @@ puts xeme['errors']
|
|
332
364
|
```
|
333
365
|
|
334
366
|
|
335
|
-
|
367
|
+
### Resolving xemes
|
336
368
|
|
337
369
|
A xeme can contain contradictory information. For example, if `success` is true
|
338
370
|
but there are errors, then the xeme should be considered as failed. If there are
|
@@ -376,4 +408,5 @@ mike@idocs.com
|
|
376
408
|
| version | date | notes |
|
377
409
|
|---------|--------------|-------------------------------|
|
378
410
|
| 0.1 | Jan 7, 2020 | Initial upload. |
|
379
|
-
| 1.0 | May 29, 2023 | Complete overhaul. Not backward compatible. |
|
411
|
+
| 1.0 | May 29, 2023 | Complete overhaul. Not backward compatible. |
|
412
|
+
| 1.1 | May 29, 2023 | Added and cleaned up documentation. No change to funcationality. |
|