fewald-worklog 0.3.9 → 0.3.11

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: a5a920425a1afeebc25dfcc71d12b6df1019cee84acb600121371d42e041004f
4
- data.tar.gz: 1f2de59cecee3fd2ed0d553488738bb908aefa1f907c2125aa8c28b3c0a4a641
3
+ metadata.gz: 194ae6d7e50c4b3010d53a84e0d9e25d949e374eb5fb75cf3cd51d301c087619
4
+ data.tar.gz: c4fe113cf9bed0c8c16f2bbb514d296c933a3fd99a590186bd705ad6d43dfcb6
5
5
  SHA512:
6
- metadata.gz: 1c4d4203b735ebe240623eddfed044793bc6a1a9dc45ade6e28c171f8f9b458a0624228d864b743ffe7396eb1cf432563331027ed68e521e74445ccb27af5107
7
- data.tar.gz: 648c610f794c778610de43a4698cbb6cbf04cfd8ac3abf09c3d219d3bb9552e0502bf7cb4b823036b1b95c1526114c7ae7b774f6acacd3f208b8683129d214d0
6
+ metadata.gz: 02627ae920d177212b611f46f6ddb888ad3b74c2c8619d1576af299aaa712503c1dd4474bebfec12fb4fe514694becd418a1b379794b1b9b3e456eaa49033a43
7
+ data.tar.gz: 609860215096e6d34b361b38e215da8ad64900113d8a6d60162dfe63dbd9ece113bc9274668055bd14825fcb45f33db32a83857e16403baf2cfef11c7f6e16b8
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.9
1
+ 0.3.11
data/lib/github/client.rb CHANGED
@@ -163,8 +163,10 @@ module Worklog
163
163
  # @raise [GithubAPIError] if the API token is missing
164
164
  def verify_token!
165
165
  WorkLogger.debug 'Verifying GitHub API token presence'
166
- @configuration.github.api_key || raise(GithubAPIError,
167
- 'GitHub API key is not configured. Please set it in the configuration.')
166
+ return unless @configuration.github.api_key.nil? || @configuration.github.api_key.empty?
167
+
168
+ raise(GithubAPIError,
169
+ 'GitHub API key is not configured. Please set it in the configuration.')
168
170
  end
169
171
  end
170
172
  end
@@ -50,7 +50,7 @@ module Worklog
50
50
 
51
51
  # Convert the PullRequestEvent to a LogEntry
52
52
  # @return [LogEntry]
53
- def to_log_entry
53
+ def to_log_entry(*)
54
54
  message = if merged?
55
55
  'Merged PR '
56
56
  elsif closed?
@@ -40,10 +40,12 @@ module Worklog
40
40
 
41
41
  # Convert the PullRequestReviewEvent to a LogEntry
42
42
  # @return [LogEntry]
43
- def to_log_entry
43
+ def to_log_entry(people_storage = nil)
44
+ handle = resolve_username(people_storage) || creator
45
+
44
46
  message = String.new 'Reviewed '
45
47
  message << 'and approved ' if approved?
46
- message << "PR ##{number} #{creator}: #{title}"
48
+ message << "PR ##{number} #{handle}: #{title}"
47
49
  LogEntry.new(
48
50
  key: Hasher.sha256("#{repository}-#{number}-#{state}"),
49
51
  source: 'github',
@@ -58,6 +60,20 @@ module Worklog
58
60
  def to_s
59
61
  "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
60
62
  end
63
+
64
+ private
65
+
66
+ # Resolve the GitHub username to a person handle using the provided PeopleStorage
67
+ # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution
68
+ # @return [String, nil] The person handle if found, otherwise nil
69
+ # @example
70
+ # resolve_username(people_storage) #=> "~johndoe"
71
+ def resolve_username(people_storage)
72
+ return if people_storage.nil?
73
+
74
+ person = people_storage.find_by_github_username(creator)
75
+ person ? "~#{person.handle}" : nil
76
+ end
61
77
  end
62
78
  end
63
79
  end
@@ -6,7 +6,7 @@ module Worklog
6
6
  module Github
7
7
  # Event representing a push event
8
8
  class PushEvent
9
- def to_log_entry
9
+ def to_log_entry(*)
10
10
  WorkLogger.debug('Converting PushEvent to LogEntry')
11
11
  LogEntry.new(
12
12
  key: 'github-push-event',
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'person'
4
+ require 'worklogger'
3
5
  require 'yaml'
4
- require_relative 'worklogger'
5
- require_relative 'person'
6
+
6
7
  module Worklog
7
- # Handles storage of people
8
+ # Finding, reading, and writing of people
9
+ # @see Person
10
+ # @see Storage
8
11
  class PeopleStorage
9
12
  PEOPLE_FILE = 'people.yaml'
10
13
 
@@ -14,7 +17,11 @@ module Worklog
14
17
  ---
15
18
  # Each person is defined by the following attributes:
16
19
  # - handle: <unique_handle>
20
+ # Unique handle used to reference this person (e.g., ~jdoe)
17
21
  # github_username: <github_username>
22
+ # GitHub username of the person, used to link GitHub events to this person.
23
+ # This can be omitted if the person does not have a GitHub account and can
24
+ # be different from the handle.
18
25
  # name: <full_name>
19
26
  # team: <team_name>
20
27
  # email: <email_address>
data/lib/worklog.rb CHANGED
@@ -154,7 +154,7 @@ module Worklog
154
154
  daily_log = @storage.load_log!(@storage.filepath(date))
155
155
  entries_before = daily_log.entries.size
156
156
  events.each do |event|
157
- log_entry = event.to_log_entry
157
+ log_entry = event.to_log_entry(@people_storage)
158
158
  WorkLogger.debug('Entry already exists, skipping') if daily_log.key?(log_entry.key)
159
159
  daily_log << log_entry unless daily_log.key?(log_entry.key)
160
160
  WorkLogger.debug "Added entry: #{log_entry.message_string}"
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.9
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald