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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/log_entry.rb +16 -0
  4. data/lib/worklog.rb +6 -0
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2751c650dcbcba507262e9478216769e167d24b73b69f731b8fb408200ba78fb
4
- data.tar.gz: d9ca2b543acfa5917164cbf0fb37d40da2ca86c2b51707d58a10fe64678c0ad7
3
+ metadata.gz: 5884616a7ecad2f07046d271cdd4d56a10d4d67afac7583f077b58d70c1adb2b
4
+ data.tar.gz: 895be92dee9fe678bef8b108ba316f8d29a69ee4132ad4155d7e0bcb1a57b450
5
5
  SHA512:
6
- metadata.gz: 1cdb5443b36ea5403014eb770f46d16518aefe599f2d9b91ef635d88f7bf37a5f03ee5e73d609fc94dd9137ce34342b0cdcf862c37812d65ca9ce6a2ee430ce8
7
- data.tar.gz: e4a03c4c5e40ce1d3b943db711038411cd3bfd781bc18b7e7db6766306ee2185c9903bf118049abc86dc5635bfbe8462f5da7e8a6c8fd7862329691b5c76ae88
6
+ metadata.gz: 0f5e94a954a83e34ec9ccfcb026e253fa8122336eae4fccfe5e63ffbfe6005a8fb1c3740be5603d2d366eb309fc9909cc8163819e10e52be1645c4e5ec9b53a5
7
+ data.tar.gz: 4f321c340d27c2cf3d6b9394d68cc21c3f5273749bbc9a51c0a6e2f80b4b7c9a4d7216b0d6d471c90ba79837e6edd8a9dc8670a6199028279459d0ac86191320
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.26
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
 
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.3.26
4
+ version: 0.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald