adalog 0.4.0 → 0.4.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 +3 -2
- data/lib/adalog/simple_logging_adapter.rb +29 -13
- data/lib/adalog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e726549691167f64945f6d0bd5057b79fb210db
|
4
|
+
data.tar.gz: d9df52ddb63df02578a5b1eb84d16f60dcc5ceba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ade73f1d7180ae64863936d8bb28796132170a1d3331c3d7a651ebb5a033ec91df1bc759a06644a380c70f25f9d54b3767801cb86b6f249043cfdcd88a7574f
|
7
|
+
data.tar.gz: 5315dcf3c987dd18f6c5a9b5adca744b7ce53bde65ba85b237b94f80e54eaa45530efa95122730751f756da614e8e2d1337e8c92325a31ad3d5e0c472ed61f31
|
data/README.md
CHANGED
@@ -103,11 +103,12 @@ And now if, in the course of building out your application, you can make an adap
|
|
103
103
|
|
104
104
|
## Included Adapters
|
105
105
|
|
106
|
-
Much like how useful repositories come built-in, there are also basic adapters included in the project. Presently the only included adapter that saves you from writing your own, is `SimpleLoggingAdapter`, which
|
106
|
+
Much like how useful repositories come built-in, there are also basic adapters included in the project. Presently the only included adapter that saves you from writing your own, is `SimpleLoggingAdapter`, which is a factory for new logging adapter classes. These classes use `method_missing` to write entries for every method call made on it. For example:
|
107
107
|
|
108
108
|
```ruby
|
109
109
|
# After configuring Adalog
|
110
|
-
|
110
|
+
klass = Adalog::SimpleLoggingAdapter.new("StubMoosendAdapter", Adalog.repo)
|
111
|
+
adapter = klass.new("any", "args", "you", "want", "they're", "ignored!")
|
111
112
|
adapter.unsubscribe_email('baz@example.com')
|
112
113
|
```
|
113
114
|
|
@@ -1,20 +1,36 @@
|
|
1
1
|
module Adalog
|
2
|
-
|
2
|
+
module SimpleLoggingAdapter
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
def self.new(service_name, repo)
|
5
|
+
new_logger_class = Class.new(self::Base)
|
6
|
+
new_logger_class.instance_variable_set(:@service_name, service_name)
|
7
|
+
new_logger_class.instance_variable_set(:@repo, repo)
|
8
|
+
new_logger_class
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
|
12
|
+
class Base
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def service_name; @service_name ; end
|
16
|
+
def repo ; @repo ; end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :service_name, :repo
|
20
|
+
|
21
|
+
def initialize(*args, **kwargs, &block)
|
22
|
+
@service_name = self.class.service_name
|
23
|
+
@repo = self.class.repo
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# TODO: Record something w.r.t. whether or not a block is given?
|
28
|
+
def method_missing(msg, *args, &block)
|
29
|
+
repo.insert(
|
30
|
+
title: service_name,
|
31
|
+
message: msg,
|
32
|
+
details: args)
|
33
|
+
end
|
18
34
|
end
|
19
35
|
|
20
36
|
end
|
data/lib/adalog/version.rb
CHANGED