soar_auditor_api 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: a5030e0bde899627dc4b7948d62c7beb4083c7cc
4
- data.tar.gz: 2ab287eb385b783aaf66035ff2e5519c36f7dca1
3
+ metadata.gz: 5b6df8f23b406ea3f044f762a4b89c682ffa1e78
4
+ data.tar.gz: 457d8bc37bd018832c15a9f03b8c6a563502a898
5
5
  SHA512:
6
- metadata.gz: e9be17c974061665baf108a1cd9471cb2def004f911c25dd486aa47e77ab4508107d90edbf56d551d9414baefa36898359e4bff96d7f6a20a15601d8f00fb903
7
- data.tar.gz: 22badc8a993560166dec0a4f1e0f05f7914fbebf81fbc749cc635d1fa723f5be31812e8fe59f2b8d7143607d07811a6eee11bbc55fa91bc034419af802fdf352
6
+ metadata.gz: f2cbe2db4c2ebb1ff3c4aeb4591acc453032d44a8a62d7eaa3644ba09aa69cf187d95ecbc07af2b82113ae9b3d6f8ac3d47f60349e959aecd618fa68b2f06f47
7
+ data.tar.gz: c0f88aadbe0f8a7aa92edfeff0494b8dfd6a19945edca55911bd0458e160988bb78614d495bc440603ad4d5d38a637f24f113145fa32d8dffd2858a714d3baf4
data/README.md CHANGED
@@ -99,6 +99,21 @@ some_debug_object = 123
99
99
  @iut.debug(some_debug_object)
100
100
  ```
101
101
 
102
+ ### Serializable classes
103
+
104
+ Class instances to be logged in the message field can be serialized by extending from the SoarAuditorApi::Serializable class.
105
+ Store the data in the @data attribute and implement the to_s method that calls the serialize method in the base class.
106
+
107
+ ``` ruby
108
+ class TestSerializable < SoarAuditorApi::Serializable
109
+ attr_accessor :data
110
+
111
+ def to_s
112
+ serialize
113
+ end
114
+ end
115
+ ```
116
+
102
117
  ## Detailed example
103
118
 
104
119
  ```ruby
@@ -1,10 +1,11 @@
1
1
  module SoarAuditorApi
2
2
  class AuditorAPI
3
3
  AUDIT_LEVELS = [:debug, :info, :warn, :error, :fatal] unless defined? AUDIT_LEVELS; AUDIT_LEVELS.freeze
4
+ DEFAULT_AUDIT_LEVEL = :info unless defined? DEFAULT_AUDIT_LEVEL; DEFAULT_AUDIT_LEVEL.freeze
4
5
 
5
6
  def initialize
6
7
  @configuration = nil
7
- @minimum_audit_level = :info
8
+ @minimum_audit_level = DEFAULT_AUDIT_LEVEL
8
9
  end
9
10
 
10
11
  def configure(configuration = nil)
@@ -43,12 +44,12 @@ module SoarAuditorApi
43
44
 
44
45
  #Safety to ensure that the Auditor that extends this API implements this IOC method
45
46
  def configuration_is_valid?(configuration)
46
- raise NotImplementedError, "Method must implement configuration_is_valid? method in Auditor extending the API"
47
+ raise NotImplementedError, "Class must implement configuration_is_valid? method in Auditor extending the API"
47
48
  end
48
49
 
49
50
  #Safety to ensure that the Auditor that extends this API implements this IOC method
50
51
  def audit(data)
51
- raise NotImplementedError, "Method must implement audit method in Auditor extending the API"
52
+ raise NotImplementedError, "Class must implement audit method in Auditor extending the API"
52
53
  end
53
54
 
54
55
  private
@@ -1,3 +1,3 @@
1
1
  module SoarAuditorApi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/sanity/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'byebug'
4
- gem 'soar_auditor_api', "~> 0.0.6"
4
+ gem 'soar_auditor_api', "~> 0.0.7"
data/sanity/sanity.rb CHANGED
@@ -11,10 +11,11 @@ class SanityAuditor < SoarAuditorApi::AuditorAPI
11
11
  end
12
12
  end
13
13
 
14
- class MyStackTrace < SoarAuditorApi::Serializable
14
+ class TestSerializable < SoarAuditorApi::Serializable
15
15
  def to_s
16
- serialize()
16
+ serialize
17
17
  end
18
+ end
18
19
 
19
20
  class Main
20
21
  def test_sanity
@@ -31,6 +32,9 @@ class Main
31
32
  @iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
32
33
  @iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
33
34
  @iut << 'Rack::CommonLogger requires this'
35
+
36
+ serializable_object = TestSerializable.new("some data")
37
+ serializable_object.to_s
34
38
  end
35
39
  end
36
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_auditor_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barney de Villiers