xeme 0.3 → 0.3.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xeme.rb +55 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d47d6001c1c5b02169dd9a5018544da7dfac7385eb06c581c70cd22f9f9330
4
- data.tar.gz: 0dcc2eee1b43a10c4caf95ecfe073a66db44f535ec7e0733cd9a22569a7bf22b
3
+ metadata.gz: 1413d7abd0e3cbfa5bebfad9dd795b007df52d93b177ab7233fbafc4bdd79c98
4
+ data.tar.gz: bad5d9f7de703c07d092a88f68ab97f5dbf01eae52ebdebc4632c611c5c3656d
5
5
  SHA512:
6
- metadata.gz: c20d4379578985940d8529fa92fe94e1990b2b49cb62d3e559cdb3b19340f64391253d444d2b26b64170192d61efc775b619277fa49a8936eaeaf0c22d928f07
7
- data.tar.gz: 457cfe0199c7c7da8a536d77b92cd596de85298da06f67035ae02f92db2ff50d25045133020a6da8e2f28d6597cafe31e94f83aa1cc18e9bce342aadfa6ea3d5
6
+ metadata.gz: 03d58e05f1544a1b68400bfb76be1ae38e880b3e4bde7c4e0894591b83015d9eee26b81803b96910cc045e06045adc75943798a42a3ceeeaa9c3600dd6d8305a
7
+ data.tar.gz: 674de2ab9106711fef9c123e68ddba3cc4293f3d8a3f1c2c7032e361e0864005e4c2a047e41df1eba98419d92a6420095fcfc27f36d3bac6c88f2e7a0eb3dd1d
@@ -6,13 +6,12 @@ require 'forwardable'
6
6
  # Xeme
7
7
  #
8
8
 
9
- ##
10
9
  # Objects of this class represent a set of results. See the README file for
11
10
  # more details.
12
11
 
13
12
  class Xeme
14
- # version 0.3
15
- VERSION = '0.3'
13
+ # version 0.3.1
14
+ VERSION = '0.3.1'
16
15
 
17
16
  # A Xeme::Messages object, which is basically just a hash containing arrays
18
17
  # for errors, warnings, and notes.
@@ -25,19 +24,13 @@ class Xeme
25
24
  # initialize
26
25
  #
27
26
 
28
- ##
29
27
  # new() does not take any parameters.
30
28
 
31
29
  def initialize
32
- # initialize errors, warnings, notes, misc
33
30
  @messages = Xeme::Messages.new
34
31
  @misc = {}
35
-
36
- # prefix and auto_misc
37
32
  @prefixes = []
38
33
  @auto_details_val = nil
39
-
40
- # transaction
41
34
  @transaction = nil
42
35
  end
43
36
  #
@@ -192,20 +185,19 @@ class Xeme
192
185
 
193
186
 
194
187
  #---------------------------------------------------------------------------
195
- # exception
188
+ # save_exception
196
189
  #
197
190
 
198
- ##
199
191
  # Use this method to hold on to details about an exception. An error message
200
- # object will be created, along with the exception's to_s backtrace.
192
+ # object will be created, along with the exception's to_s and backtrace.
201
193
 
202
- def exception(id, e, details={})
194
+ def save_exception(id, e, details={})
203
195
  message = self.error(id, details)
204
196
  message['error'] = e.to_s
205
197
  message['backtrace'] = e.backtrace
206
198
  end
207
199
  #
208
- # exception
200
+ # save_exception
209
201
  #---------------------------------------------------------------------------
210
202
 
211
203
 
@@ -357,6 +349,21 @@ class Xeme
357
349
  #---------------------------------------------------------------------------
358
350
 
359
351
 
352
+ #---------------------------------------------------------------------------
353
+ # new_exception
354
+ #
355
+
356
+ # Creates and returns a Xeme::Exception object. The Xeme object is attached
357
+ # to the Xeme::Exception object.
358
+
359
+ def new_exception(error_id)
360
+ return Xeme::Exception.new(error_id, self)
361
+ end
362
+ #
363
+ # new_exception
364
+ #---------------------------------------------------------------------------
365
+
366
+
360
367
  # private methods
361
368
  private
362
369
 
@@ -431,7 +438,6 @@ end
431
438
  # Xeme::Message
432
439
  #
433
440
 
434
- ##
435
441
  # A Xeme::Message object represents a single error, warning, or note.
436
442
  # It is the base class for Xeme::Message::Error,
437
443
  # Xeme::Message::Warning, and
@@ -450,6 +456,9 @@ class Xeme::Message
450
456
  # The id of the message.
451
457
  attr_reader :id
452
458
 
459
+ # Details about the message.
460
+ attr_reader :details
461
+
453
462
  # delegate to hsh
454
463
  extend Forwardable
455
464
  delegate %w([] []= each length clear delete) => :@details
@@ -565,9 +574,8 @@ end
565
574
  # Xeme::Transaction
566
575
  #
567
576
 
568
- ##
569
- # An object of this class provdes meta information about the request and
570
- # results. It always provides a a timestamp and a unique ID for the results. It
577
+ # An object of this class provides meta information about the request and
578
+ # results. It always provides a timestamp and a unique ID for the results. It
571
579
  # may also optionally include a request ID that was provided by the process
572
580
  # that made the request, such as a call to a REST application. Do not directly
573
581
  # instantiate this class; use Xeme#transaction.
@@ -626,3 +634,32 @@ end
626
634
  #
627
635
  # Xeme::Transaction
628
636
  #===============================================================================
637
+
638
+
639
+ #===============================================================================
640
+ # Xeme::Exception
641
+ #
642
+
643
+ # Xeme::Exception is a subclass of StandardError and can be used exactly like a
644
+ # StandardError object. The one addition to StandardError is the `xeme` property
645
+ # which holds a Xeme object. Don't instantiate this class directly; use
646
+ # Xeme#new_exception.
647
+
648
+ class Xeme::Exception < StandardError
649
+ attr_reader :xeme # a xeme object
650
+
651
+ #---------------------------------------------------------------------------
652
+ # initialize
653
+ #
654
+ def initialize(error_code, xeme)
655
+ @error_code = error_code
656
+ @xeme = xeme
657
+ super @error_code
658
+ end
659
+ #
660
+ # initialize
661
+ #---------------------------------------------------------------------------
662
+ end
663
+ #
664
+ # Xeme::Exception
665
+ #===============================================================================
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xeme
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike O'Sullivan