cogger 0.25.0 → 0.26.0
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
- checksums.yaml.gz.sig +2 -5
- data/cogger.gemspec +1 -1
- data/lib/cogger/entry.rb +1 -2
- data/lib/cogger/formatters/abstract.rb +6 -6
- data/lib/cogger/formatters/color.rb +1 -1
- data/lib/cogger/formatters/crash.rb +1 -1
- data/lib/cogger/formatters/json.rb +2 -12
- data/lib/cogger/formatters/parsers/key.rb +1 -2
- data/lib/cogger/formatters/parsers/{key_extractor.rb → position.rb} +12 -3
- data/lib/cogger/formatters/property.rb +3 -13
- data/lib/cogger/formatters/sanitizers/{date_time.rb → format_time.rb} +1 -1
- data/lib/cogger/formatters/simple.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f0d785b86722f1a0d3247b5afc698df6f3cd643501ef2aa327cb2e45c23e77f
|
4
|
+
data.tar.gz: 510551f2a309c58768df7d207c73a0483c09c4cd6fb26454a4c05cfaf4826d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5603ca0a172662015262ca3d0a8702b8bff9cb16e07a85ad5f37040f9546a0e93a0e4b06ec350727224fe2dfa68471af20c47ac37487b124d393fdb8512ab7a2
|
7
|
+
data.tar.gz: 8184cd16ac184d2342d52a8b30a7ea98c0535eb9e749fcf3b60c32babbda0efb42c2b8dd324154819d41740d73a9c03e59b4e08bc7655c4709d17fd24186ecc5
|
checksums.yaml.gz.sig
CHANGED
@@ -1,5 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
���pXAɖ4a�̙�b�t��>�=#m1�gq��Zg���9�"W��߇�z�$o$�"D
|
4
|
-
�I�+�N��Z@&$
|
5
|
-
��9!Y,�X���{LVLC��8�o�Dl�R�BZu�4v)l2$��w]<���=A�0�������
|
1
|
+
��6=�'���
|
2
|
+
ʅ�hMJg#��y㼑"Ed�
|
data/cogger.gemspec
CHANGED
data/lib/cogger/entry.rb
CHANGED
@@ -4,10 +4,12 @@ module Cogger
|
|
4
4
|
module Formatters
|
5
5
|
# An abstract class with common/shared functionality.
|
6
6
|
class Abstract
|
7
|
+
NEW_LINE = "\n"
|
8
|
+
|
7
9
|
SANITIZERS = {
|
8
|
-
datetime: Sanitizers::DateTime,
|
9
10
|
escape: Sanitizers::Escape.new,
|
10
|
-
filter: Sanitizers::Filter
|
11
|
+
filter: Sanitizers::Filter,
|
12
|
+
format_time: Sanitizers::FormatTime
|
11
13
|
}.freeze
|
12
14
|
|
13
15
|
def initialize sanitizers: SANITIZERS
|
@@ -23,10 +25,8 @@ module Cogger
|
|
23
25
|
|
24
26
|
def sanitize entry, message
|
25
27
|
entry.public_send(message).tap do |attributes|
|
26
|
-
function = -> value { sanitize_datetime value, format: entry.datetime_format }
|
27
|
-
|
28
28
|
filter attributes
|
29
|
-
attributes.transform_values!
|
29
|
+
attributes.transform_values! { |value| format_time value, format: entry.datetime_format }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,7 +34,7 @@ module Cogger
|
|
34
34
|
|
35
35
|
def filter(...) = sanitizers.fetch(__method__).call(...)
|
36
36
|
|
37
|
-
def
|
37
|
+
def format_time(...) = sanitizers.fetch(__method__).call(...)
|
38
38
|
|
39
39
|
private
|
40
40
|
|
@@ -22,7 +22,7 @@ module Cogger
|
|
22
22
|
attributes = sanitize entry, :tagged
|
23
23
|
attributes[:backtrace] = %( #{attributes[:backtrace].join "\n "})
|
24
24
|
|
25
|
-
|
25
|
+
format(parse(attributes[:level]), attributes) << NEW_LINE
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -9,7 +9,7 @@ module Cogger
|
|
9
9
|
class JSON < Abstract
|
10
10
|
TEMPLATE = nil
|
11
11
|
|
12
|
-
def initialize template = TEMPLATE, parser: Parsers::
|
12
|
+
def initialize template = TEMPLATE, parser: Parsers::Position.new
|
13
13
|
super()
|
14
14
|
@template = template
|
15
15
|
@parser = parser
|
@@ -19,22 +19,12 @@ module Cogger
|
|
19
19
|
*, entry = input
|
20
20
|
attributes = sanitize(entry, :tagged_attributes).tap(&:compact!)
|
21
21
|
|
22
|
-
|
22
|
+
parser.call(template, attributes).to_json << NEW_LINE
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
27
|
attr_reader :template, :parser
|
28
|
-
|
29
|
-
def reorder attributes
|
30
|
-
positions = positions_for template
|
31
|
-
|
32
|
-
return attributes if positions.empty?
|
33
|
-
|
34
|
-
attributes.slice(*positions).merge!(attributes.except(*positions))
|
35
|
-
end
|
36
|
-
|
37
|
-
def positions_for(template) = template ? parser.call(template) : Core::EMPTY_ARRAY
|
38
28
|
end
|
39
29
|
end
|
40
30
|
end
|
@@ -10,9 +10,8 @@ module Cogger
|
|
10
10
|
PATTERN = /
|
11
11
|
% # Start.
|
12
12
|
(?<flag>[\s#+-0*])? # Optional flag.
|
13
|
+
\.? # Optional precision.
|
13
14
|
(?<width>\d+)? # Optional width.
|
14
|
-
\.? # Optional precision delimiter.
|
15
|
-
(?<precision>\d+)? # Optional precision value.
|
16
15
|
< # Reference start.
|
17
16
|
(?<key>\w+) # Key.
|
18
17
|
: # Delimiter.
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Cogger
|
4
4
|
module Formatters
|
5
5
|
module Parsers
|
6
|
-
# Parses template and
|
7
|
-
class
|
6
|
+
# Parses template and reorders attributes based on template key positions.
|
7
|
+
class Position
|
8
8
|
PATTERN = /
|
9
9
|
% # Start.
|
10
10
|
? # Flag, width, or precision.
|
@@ -19,11 +19,20 @@ module Cogger
|
|
19
19
|
@pattern = pattern
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
# :reek:FeatureEnvy
|
23
|
+
def call template, attributes
|
24
|
+
return attributes if !template || template.empty?
|
25
|
+
return attributes unless template.match? pattern
|
26
|
+
|
27
|
+
keys = scan template
|
28
|
+
attributes.slice(*keys).merge!(attributes.except(*keys))
|
29
|
+
end
|
23
30
|
|
24
31
|
private
|
25
32
|
|
26
33
|
attr_reader :pattern
|
34
|
+
|
35
|
+
def scan(template) = template.scan(pattern).map { |match| match.first.to_sym }
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
@@ -8,7 +8,7 @@ module Cogger
|
|
8
8
|
class Property < Abstract
|
9
9
|
TEMPLATE = nil
|
10
10
|
|
11
|
-
def initialize template = TEMPLATE, parser: Parsers::
|
11
|
+
def initialize template = TEMPLATE, parser: Parsers::Position.new
|
12
12
|
super()
|
13
13
|
@template = template
|
14
14
|
@parser = parser
|
@@ -18,7 +18,7 @@ module Cogger
|
|
18
18
|
*, entry = input
|
19
19
|
attributes = sanitize(entry, :tagged_attributes).tap(&:compact!)
|
20
20
|
|
21
|
-
concat(attributes).chop! <<
|
21
|
+
concat(attributes).chop! << NEW_LINE
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -26,20 +26,10 @@ module Cogger
|
|
26
26
|
attr_reader :template, :parser
|
27
27
|
|
28
28
|
def concat attributes
|
29
|
-
|
29
|
+
parser.call(template, attributes).each.with_object(+"") do |(key, value), line|
|
30
30
|
line << key.to_s << "=" << escape(value) << " "
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
def reorder attributes
|
35
|
-
positions = positions_for template
|
36
|
-
|
37
|
-
return attributes if positions.empty?
|
38
|
-
|
39
|
-
attributes.slice(*positions).merge!(attributes.except(*positions))
|
40
|
-
end
|
41
|
-
|
42
|
-
def positions_for(template) = template ? parser.call(template) : Core::EMPTY_ARRAY
|
43
33
|
end
|
44
34
|
end
|
45
35
|
end
|
@@ -6,7 +6,7 @@ module Cogger
|
|
6
6
|
module Formatters
|
7
7
|
module Sanitizers
|
8
8
|
# Sanitizes/formats date/time value.
|
9
|
-
|
9
|
+
FormatTime = lambda do |value, format: Cogger::DATETIME_FORMAT|
|
10
10
|
return value unless value.is_a?(::Time) || value.is_a?(Date) || value.is_a?(::DateTime)
|
11
11
|
|
12
12
|
value.strftime format
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-08-
|
38
|
+
date: 2024-08-30 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: core
|
@@ -118,11 +118,11 @@ files:
|
|
118
118
|
- lib/cogger/formatters/parsers/element.rb
|
119
119
|
- lib/cogger/formatters/parsers/emoji.rb
|
120
120
|
- lib/cogger/formatters/parsers/key.rb
|
121
|
-
- lib/cogger/formatters/parsers/
|
121
|
+
- lib/cogger/formatters/parsers/position.rb
|
122
122
|
- lib/cogger/formatters/property.rb
|
123
|
-
- lib/cogger/formatters/sanitizers/date_time.rb
|
124
123
|
- lib/cogger/formatters/sanitizers/escape.rb
|
125
124
|
- lib/cogger/formatters/sanitizers/filter.rb
|
125
|
+
- lib/cogger/formatters/sanitizers/format_time.rb
|
126
126
|
- lib/cogger/formatters/simple.rb
|
127
127
|
- lib/cogger/formatters/transformers/color.rb
|
128
128
|
- lib/cogger/formatters/transformers/emoji.rb
|
metadata.gz.sig
CHANGED
@@ -1 +1,4 @@
|
|
1
|
-
|
1
|
+
z�)��������I�z��� �zy=?�8p$%����z����c��S��q�@z����h�W�Uw�L��`���
|
2
|
+
�'Kul��E{���O���L�t��_[�[������[2n������$t�8Z��t�cc���{�)��B�g �5���<K��bS���])��c�_����^���'�7�3ƫ���7bN�p���<^�T=����
|
3
|
+
�p��e�7�A0��[���YM�N6pKjGO��6�Yb��,��4Iϛ��9D5�;63�ϡ��!tb?W�PH'�������'�A,��0�C�[.����S�4�)W?��\�Q֜ه+|/L�� g�P���:RoW45Un
|
4
|
+
Iet�l��DR����H&��i
|