fewald-worklog 0.2.32 → 0.2.33
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 +1 -1
- data/lib/log_entry.rb +7 -10
- data/lib/worklog.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c28fcf1980d7fba6dbe1585ef1ae6d41520329470c4289f427dc8feb689c4cba
|
|
4
|
+
data.tar.gz: d6db27c34cd1288d19042579426a947b96fa5ca30f7fd7a88887ee220f2adc16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4116746f5d7df43bfb7764a68c36dfc19d9ed3ccee6c8f1965306db4ffde3e1a7c56608293fc6d8b0c30810149ef0cdbfd83bb9881fb05d84feb0b368079883c
|
|
7
|
+
data.tar.gz: 0ec8ef405b87a6e07c9ca6a4c0191de9fc0c5fbc19bbd30656e332d9a6489db90fa8ae81532c481c9c3a4169fed3d5f9679a7d9cee4e9f5ee07a3af6d3ebc9d6
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.33
|
data/lib/daily_log.rb
CHANGED
data/lib/log_entry.rb
CHANGED
|
@@ -8,6 +8,8 @@ require 'hash'
|
|
|
8
8
|
module Worklog
|
|
9
9
|
# A single log entry in a DailyLog.
|
|
10
10
|
# @see DailyLog
|
|
11
|
+
# @!attribute [rw] key
|
|
12
|
+
# @return [String] the unique key of the log entry. The key is generated based on the time and message.
|
|
11
13
|
# @!attribute [rw] time
|
|
12
14
|
# @return [DateTime] the date and time of the log entry.
|
|
13
15
|
# @!attribute [rw] tags
|
|
@@ -27,11 +29,13 @@ module Worklog
|
|
|
27
29
|
|
|
28
30
|
include Hashify
|
|
29
31
|
|
|
30
|
-
attr_accessor :time, :tags, :ticket, :url, :epic, :message, :project
|
|
32
|
+
attr_accessor :key, :time, :tags, :ticket, :url, :epic, :message, :project
|
|
31
33
|
|
|
32
34
|
attr_reader :day
|
|
33
35
|
|
|
34
36
|
def initialize(params = {})
|
|
37
|
+
# key can be nil. This is needed for backwards compatibility with older log entries.
|
|
38
|
+
@key = params[:key]
|
|
35
39
|
@time = params[:time]
|
|
36
40
|
# If tags are nil, set to empty array.
|
|
37
41
|
# This is similar to the CLI default value.
|
|
@@ -105,19 +109,12 @@ module Worklog
|
|
|
105
109
|
end
|
|
106
110
|
|
|
107
111
|
# Create a LogEntry from a hash with symbolized keys
|
|
112
|
+
# This is an alias for the constructor and here for consistency with other classes.
|
|
108
113
|
#
|
|
109
114
|
# @param hash [Hash] the hash to convert
|
|
110
115
|
# @return [LogEntry] the created LogEntry object
|
|
111
116
|
def self.from_hash(hash)
|
|
112
|
-
new(
|
|
113
|
-
time: hash[:time],
|
|
114
|
-
tags: hash[:tags],
|
|
115
|
-
ticket: hash[:ticket],
|
|
116
|
-
url: hash[:url],
|
|
117
|
-
epic: hash[:epic],
|
|
118
|
-
message: hash[:message],
|
|
119
|
-
project: hash[:project]
|
|
120
|
-
)
|
|
117
|
+
new(**hash)
|
|
121
118
|
end
|
|
122
119
|
|
|
123
120
|
# Convert the log entry to YAML format.
|
data/lib/worklog.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'rainbow'
|
|
|
6
6
|
require 'yaml'
|
|
7
7
|
|
|
8
8
|
require 'configuration'
|
|
9
|
+
require 'digest'
|
|
9
10
|
require 'hash'
|
|
10
11
|
require 'daily_log'
|
|
11
12
|
require 'date_parser'
|
|
@@ -86,8 +87,11 @@ module Worklog
|
|
|
86
87
|
# Validate that the project exists if provided
|
|
87
88
|
validate_projects!(options[:project]) if options[:project] && !options[:project].empty?
|
|
88
89
|
|
|
90
|
+
# Use the first 7 characters of the SHA256 hash of message as the key
|
|
91
|
+
key = Digest::SHA256.hexdigest(message)[..6]
|
|
92
|
+
|
|
89
93
|
daily_log = @storage.load_log!(@storage.filepath(date))
|
|
90
|
-
new_entry = LogEntry.new(time:, tags: options[:tags], ticket: options[:ticket], url: options[:url],
|
|
94
|
+
new_entry = LogEntry.new(key:, time:, tags: options[:tags], ticket: options[:ticket], url: options[:url],
|
|
91
95
|
epic: options[:epic], message:, project: options[:project])
|
|
92
96
|
daily_log.entries << new_entry
|
|
93
97
|
|