cogger 0.25.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/cogger.gemspec +5 -5
- 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} +2 -2
- data/lib/cogger/formatters/simple.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +13 -10
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f6a9da3a0ab293bb7909571afaf8af33e2c42dd36f1bb0845ac38442d13557
|
4
|
+
data.tar.gz: f8dca81f5e93e6ba4c59a6af2bb57cf89cb79ff3a9885b1e390b61549a3dcf41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ae3c273c6da93bed7c4c2e01d55ac010525f2342806a3bd63eef9a12920fe92797391a3d1d450ed2d90e3d56ca15dcbb50ad9046f1d0bdcad087df437f9fcd
|
7
|
+
data.tar.gz: c5215a8a89e139ba6087d70dfe10575fe4bb1b3d251b3aa333f9400406e4dd05255529578be09e537052e534c3d890db614b8fcac52ff260626ba92c018504c3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/cogger.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "cogger"
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.27.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/cogger"
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.metadata = {
|
13
13
|
"bug_tracker_uri" => "https://github.com/bkuhlmann/cogger/issues",
|
14
14
|
"changelog_uri" => "https://alchemists.io/projects/cogger/versions",
|
15
|
-
"
|
15
|
+
"homepage_uri" => "https://alchemists.io/projects/cogger",
|
16
16
|
"funding_uri" => "https://github.com/sponsors/bkuhlmann",
|
17
17
|
"label" => "Cogger",
|
18
18
|
"rubygems_mfa_required" => "true",
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.signing_key = Gem.default_key_path
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
|
-
spec.required_ruby_version = "
|
26
|
-
spec.add_dependency "core", "~> 1.
|
27
|
-
spec.add_dependency "refinements", "~> 12.
|
25
|
+
spec.required_ruby_version = ">= 3.3", "<= 3.4"
|
26
|
+
spec.add_dependency "core", "~> 1.7"
|
27
|
+
spec.add_dependency "refinements", "~> 12.8"
|
28
28
|
spec.add_dependency "tone", "~> 1.0"
|
29
29
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
30
30
|
|
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,8 +6,8 @@ module Cogger
|
|
6
6
|
module Formatters
|
7
7
|
module Sanitizers
|
8
8
|
# Sanitizes/formats date/time value.
|
9
|
-
|
10
|
-
return value unless value.is_a?(::Time) || value.is_a?(Date) || value.is_a?(
|
9
|
+
FormatTime = lambda do |value, format: Cogger::DATETIME_FORMAT|
|
10
|
+
return value unless value.is_a?(::Time) || value.is_a?(Date) || value.is_a?(DateTime)
|
11
11
|
|
12
12
|
value.strftime format
|
13
13
|
end
|
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.27.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-
|
38
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: core
|
@@ -43,28 +43,28 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.7'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1.
|
53
|
+
version: '1.7'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: refinements
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '12.
|
60
|
+
version: '12.8'
|
61
61
|
type: :runtime
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '12.
|
67
|
+
version: '12.8'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: tone
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -143,7 +143,7 @@ licenses:
|
|
143
143
|
metadata:
|
144
144
|
bug_tracker_uri: https://github.com/bkuhlmann/cogger/issues
|
145
145
|
changelog_uri: https://alchemists.io/projects/cogger/versions
|
146
|
-
|
146
|
+
homepage_uri: https://alchemists.io/projects/cogger
|
147
147
|
funding_uri: https://github.com/sponsors/bkuhlmann
|
148
148
|
label: Cogger
|
149
149
|
rubygems_mfa_required: 'true'
|
@@ -154,9 +154,12 @@ require_paths:
|
|
154
154
|
- lib
|
155
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '3.3'
|
160
|
+
- - "<="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '3.4'
|
160
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
164
|
requirements:
|
162
165
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|