fewald-worklog 0.2.33 → 0.2.35
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/.version +1 -1
- data/lib/daily_log.rb +11 -0
- data/lib/hasher.rb +19 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6a7037fb7f1b5194e72152f812ef7e2defdcbe46e9845935a64b9e6fffbce32
|
|
4
|
+
data.tar.gz: d2b005c1399811835d84fc9f53bc341a3cf4a861f898ede71c706defb895e63f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7186e4bf2fd4978e5245cfbb7e798d70d37c9002eec9dc4a9c259798e4df87abb07ae3af12ea58e7febca6b5e33d8be5acabe61cffbf5e3db037ecd1bccc7e60
|
|
7
|
+
data.tar.gz: 7699e19686d0e6a15d47ee9b2e12f2fe0da07f1e7ba70b1d90e8a967d295eba13ca0cd0c2892ad8f9f8bac0d2f0ba96180b44947616dd7b0c0c7998e39418175
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.35
|
data/lib/daily_log.rb
CHANGED
|
@@ -62,5 +62,16 @@ module Worklog
|
|
|
62
62
|
def ==(other)
|
|
63
63
|
date == other.date && entries == other.entries
|
|
64
64
|
end
|
|
65
|
+
|
|
66
|
+
# Access a log entry by its unique key.
|
|
67
|
+
# To safeguard against multiple entries with the same key, and future-proofing,
|
|
68
|
+
# an empty string will return nil.
|
|
69
|
+
# @param key [String] the unique key of the log entry
|
|
70
|
+
# @return [LogEntry, nil] the log entry with the specified key, or nil if not found
|
|
71
|
+
def [](key)
|
|
72
|
+
return nil if key.nil? || key.empty?
|
|
73
|
+
|
|
74
|
+
@entries.find { |entry| entry.key == key }
|
|
75
|
+
end
|
|
65
76
|
end
|
|
66
77
|
end
|
data/lib/hasher.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'digest'
|
|
4
|
+
|
|
5
|
+
module Worklog
|
|
6
|
+
# Simple hashing utility
|
|
7
|
+
class Hasher
|
|
8
|
+
# Generate SHA256 hash for the given input string
|
|
9
|
+
# @param input [String] The input string to hash
|
|
10
|
+
# @param length [Integer] The length of the resulting hash (default: 7)
|
|
11
|
+
# @return [String] The resulting SHA256 hash in hexadecimal format
|
|
12
|
+
# @raise [ArgumentError] if length is not between 1 and 64
|
|
13
|
+
def self.sha256(input, length = 7)
|
|
14
|
+
raise ArgumentError, 'Length must be between 1 and 64' unless length.between?(1, 64)
|
|
15
|
+
|
|
16
|
+
Digest::SHA256.hexdigest(input)[..(length - 1)]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fewald-worklog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.35
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Friedrich Ewald
|
|
@@ -128,6 +128,7 @@ files:
|
|
|
128
128
|
- lib/date_parser.rb
|
|
129
129
|
- lib/editor.rb
|
|
130
130
|
- lib/hash.rb
|
|
131
|
+
- lib/hasher.rb
|
|
131
132
|
- lib/log_entry.rb
|
|
132
133
|
- lib/person.rb
|
|
133
134
|
- lib/printer.rb
|