fewald-worklog 0.3.26 → 0.3.27
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/log_entry.rb +16 -0
- data/lib/worklog.rb +6 -0
- 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: 5884616a7ecad2f07046d271cdd4d56a10d4d67afac7583f077b58d70c1adb2b
|
|
4
|
+
data.tar.gz: 895be92dee9fe678bef8b108ba316f8d29a69ee4132ad4155d7e0bcb1a57b450
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f5e94a954a83e34ec9ccfcb026e253fa8122336eae4fccfe5e63ffbfe6005a8fb1c3740be5603d2d366eb309fc9909cc8163819e10e52be1645c4e5ec9b53a5
|
|
7
|
+
data.tar.gz: 4f321c340d27c2cf3d6b9394d68cc21c3f5273749bbc9a51c0a6e2f80b4b7c9a4d7216b0d6d471c90ba79837e6edd8a9dc8670a6199028279459d0ac86191320
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.27
|
data/lib/log_entry.rb
CHANGED
|
@@ -30,6 +30,10 @@ module Worklog
|
|
|
30
30
|
class LogEntry
|
|
31
31
|
PERSON_REGEX = /(?:\s|^)[~@](\w+)/
|
|
32
32
|
|
|
33
|
+
# Matches a Jira-style ticket identifier (e.g. PROJ-1234) at the end of a URL path,
|
|
34
|
+
# optionally followed by a query string, fragment, or trailing slash.
|
|
35
|
+
TICKET_URL_REGEX = %r{([A-Z]+-\d+)(?:[?#/].*)?$}
|
|
36
|
+
|
|
33
37
|
include Hashify
|
|
34
38
|
|
|
35
39
|
attr_accessor :key, :source, :time, :tags, :ticket, :url, :epic, :message, :project
|
|
@@ -94,6 +98,18 @@ module Worklog
|
|
|
94
98
|
new(**hash)
|
|
95
99
|
end
|
|
96
100
|
|
|
101
|
+
# Extract a Jira-style ticket identifier from a URL.
|
|
102
|
+
# Returns nil if the URL is blank or no ticket pattern is found.
|
|
103
|
+
#
|
|
104
|
+
# @param url [String, nil] the URL to scan
|
|
105
|
+
# @return [String, nil] the ticket identifier (e.g. "PROJ-1234"), or nil
|
|
106
|
+
def self.extract_ticket_from_url(url)
|
|
107
|
+
return nil if url.nil? || url.strip.empty?
|
|
108
|
+
|
|
109
|
+
match = url.match(TICKET_URL_REGEX)
|
|
110
|
+
match ? match[1] : nil
|
|
111
|
+
end
|
|
112
|
+
|
|
97
113
|
# Convert the log entry to YAML format.
|
|
98
114
|
# @return [String] the YAML representation of the log entry.
|
|
99
115
|
def to_yaml
|
data/lib/worklog.rb
CHANGED
|
@@ -105,6 +105,12 @@ module Worklog
|
|
|
105
105
|
# Validate that the project exists if provided
|
|
106
106
|
validate_projects!(options[:project]) if options[:project] && !options[:project].empty?
|
|
107
107
|
|
|
108
|
+
# Auto-extract ticket from URL when no ticket was explicitly provided
|
|
109
|
+
if (options[:ticket].nil? || options[:ticket].empty?) && options[:url]
|
|
110
|
+
extracted = LogEntry.extract_ticket_from_url(options[:url])
|
|
111
|
+
options = options.merge(ticket: extracted) if extracted
|
|
112
|
+
end
|
|
113
|
+
|
|
108
114
|
# Use the first 7 characters of the SHA256 hash of message as the key
|
|
109
115
|
key = Hasher.sha256(message)
|
|
110
116
|
|