lumberjack 1.3.1 → 1.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07e6e20fe9cf765f75723c6a3d3101f1c2387633d109a6cd4c85cb67a3a2d0ce
4
- data.tar.gz: e9321f97338038f863eff17801cf3b2620f88f1685631a0a894fb219578b0b8c
3
+ metadata.gz: 2be09b55c4a7ac6187425bdf0a6ded2a983301bd2698519174843e753ae27bb5
4
+ data.tar.gz: 131dd6986a741ba4b819ef2de652c4c5c6576bd970138d7a9883c4a9eb470237
5
5
  SHA512:
6
- metadata.gz: 18cf33bd3e45a2d6fa703586447c66cf7848580a4c793da67f50a1fd2bbdb0724bb4e393165e4fdcade80a71f72e7ff6751f52e883d6993d02880e53bc64ea8a
7
- data.tar.gz: 4c87222be54db1f498b1d6369821df16906a0ea7d3503de4528a16af05de3ec87dde1c45dd759b233dbec451536571a5030f0f2d23b28aa3fd31214e32cda6da
6
+ metadata.gz: 7d164abb04d3f06d8b2ec0f1653eeb9b6663fba66c8a095bd2841ecb7fe2ffc91a860e7662485e3a2e71acb058c9dadc35c3cd775f0802a2b1946f94fe8c39ef
7
+ data.tar.gz: 90f918cda88678f8a12a2ed84dc789eeb250c6ba5af9b70f7c8daddafb87196525732a2513bfe719eeeadc37c5f642c4af3e0cc80b49ef8a0f12ea0075c4ff9a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 1.3.3
8
+
9
+ ### Added
10
+
11
+ - Added `Lumberjack::Utils#expand_tags` method to expand a hash of tags that may contain nested hashes or dot notation keys.
12
+
13
+ ### Changed
14
+
15
+ - Updated `Lumberjack::Utils#flatten_tags` to convert all keys to strings.
16
+
17
+ ## 1.3.2
18
+
19
+ ### Fixed
20
+
21
+ - Fixed `NoMethodError` when setting the device via the `Lumberjack::Logger#device=` method.
22
+
7
23
  ## 1.3.1
8
24
 
9
25
  ### Added
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.3
@@ -96,9 +96,7 @@ module Lumberjack
96
96
  # @param [Lumberjack::Device] device The new logging device.
97
97
  # @return [void]
98
98
  def device=(device)
99
- @logdev = if device
100
- open_device(device, options)
101
- end
99
+ @logdev = device.nil? ? nil : open_device(device, {})
102
100
  end
103
101
 
104
102
  # Get the timestamp format on the device if it has one.
@@ -103,7 +103,10 @@ module Lumberjack
103
103
  # Flatten a tag hash to a single level hash with dot notation for nested keys.
104
104
  #
105
105
  # @param tag_hash [Hash] The hash to flatten.
106
- # @return [Hash] The flattened hash.
106
+ # @return [Hash<String, Object>] The flattened hash.
107
+ # @example
108
+ # expand_tags(user: {id: 123, name: "Alice"}, action: "login")})
109
+ # # => {"user.id" => 123, "user.name" => "Alice", "action" => "login"}
107
110
  def flatten_tags(tag_hash)
108
111
  return {} unless tag_hash.is_a?(Hash)
109
112
 
@@ -113,11 +116,26 @@ module Lumberjack
113
116
  result["#{key}.#{sub_key}"] = sub_value
114
117
  end
115
118
  else
116
- result[key] = value
119
+ result[key.to_s] = value
117
120
  end
118
121
  end
119
122
  end
120
123
 
124
+ # Expand a hash of tags that may contain nested hashes or dot notation keys. Dot notation tags
125
+ # will be expanded into nested hashes.
126
+ #
127
+ # @param tags [Hash] The hash of tags to expand.
128
+ # @return [Hash] The expanded hash with dot notation keys.
129
+ #
130
+ # @example
131
+ # expand_tags({"user.id" => 123, "user.name" => "Alice", "action" => "login"})
132
+ # # => {"user" => {"id" => 123, "name" => "Alice"}, "action" => "login"}
133
+ def expand_tags(tags)
134
+ return {} unless tags.is_a?(Hash)
135
+
136
+ expand_dot_notation_hash(tags)
137
+ end
138
+
121
139
  private
122
140
 
123
141
  def slugify(str)
@@ -128,6 +146,34 @@ module Lumberjack
128
146
  str.chomp!("-")
129
147
  str
130
148
  end
149
+
150
+ def expand_dot_notation_hash(hash, expanded = {})
151
+ return hash unless hash.is_a?(Hash)
152
+
153
+ hash.each do |key, value|
154
+ key = key.to_s
155
+ if key.include?(".")
156
+ main_key, sub_key = key.split(".", 2)
157
+ main_key_hash = expanded[main_key]
158
+ unless main_key_hash.is_a?(Hash)
159
+ main_key_hash = {}
160
+ expanded[main_key] = main_key_hash
161
+ end
162
+ expand_dot_notation_hash({sub_key => value}, main_key_hash)
163
+ elsif value.is_a?(Hash)
164
+ key_hash = expanded[key]
165
+ unless key_hash.is_a?(Hash)
166
+ key_hash = {}
167
+ expanded[key] = key_hash
168
+ end
169
+ expand_dot_notation_hash(value, key_hash)
170
+ else
171
+ expanded[key] = value
172
+ end
173
+ end
174
+
175
+ expanded
176
+ end
131
177
  end
132
178
  end
133
179
  end
data/lumberjack.gemspec CHANGED
@@ -8,6 +8,12 @@ Gem::Specification.new do |spec|
8
8
  spec.homepage = "https://github.com/bdurand/lumberjack"
9
9
  spec.license = "MIT"
10
10
 
11
+ spec.metadata = {
12
+ "homepage_uri" => spec.homepage,
13
+ "source_code_uri" => spec.homepage,
14
+ "changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md"
15
+ }
16
+
11
17
  # Specify which files should be added to the gem when it is released.
12
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
13
19
  ignore_files = %w[
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumberjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-20 00:00:00.000000000 Z
11
+ date: 2025-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,7 +78,10 @@ files:
78
78
  homepage: https://github.com/bdurand/lumberjack
79
79
  licenses:
80
80
  - MIT
81
- metadata: {}
81
+ metadata:
82
+ homepage_uri: https://github.com/bdurand/lumberjack
83
+ source_code_uri: https://github.com/bdurand/lumberjack
84
+ changelog_uri: https://github.com/bdurand/lumberjack/blob/main/CHANGELOG.md
82
85
  post_install_message:
83
86
  rdoc_options: []
84
87
  require_paths: