fewald-worklog 0.3.3 → 0.3.5
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/cli.rb +1 -0
- data/lib/person.rb +69 -48
- 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: f4b6b051e9dd15f4588ddcff4a3f23686077c3b6fa8c8fda053cd6187a91a34c
|
|
4
|
+
data.tar.gz: 7a3b6ff79f314e30016776efed9fbe2a76b68e46658c4658185577f27a7cf3bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23c300fa90069057589a947ff9da63db056f28bc7021ba7a9a19cfd28dbf424ed1ada21a24a76cd29b72f1810a7f7c14bdd9c4547b84e330ef96e99b1dbfd640
|
|
7
|
+
data.tar.gz: 627e537ca0e1530d64bf7b4a1c78709f9910bcec382ed8c1dba43d7a0c35bc32f1488f45490d8432d5aae0cf4db1e8692982a46416821b8afe7bf8108738f58f
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.5
|
data/lib/cli.rb
CHANGED
|
@@ -110,6 +110,7 @@ class WorklogCLI < Thor
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
desc 'people', 'Show all people mentioned in the work log'
|
|
113
|
+
option :inactive, type: :boolean, default: false, desc: 'Include inactive people in the list'
|
|
113
114
|
def people(person = nil)
|
|
114
115
|
worklog = Worklog::Worklog.new
|
|
115
116
|
worklog.people(person, options)
|
data/lib/person.rb
CHANGED
|
@@ -1,57 +1,78 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@name = name
|
|
21
|
-
@email = email
|
|
22
|
-
@team = team
|
|
23
|
-
@notes = notes
|
|
24
|
-
end
|
|
3
|
+
module Worklog
|
|
4
|
+
# Represents a person at work.
|
|
5
|
+
#
|
|
6
|
+
# !attribute [r] handle
|
|
7
|
+
# @return [String] The person's handle (username)
|
|
8
|
+
# !attribute [r] name
|
|
9
|
+
# @return [String] The person's full name
|
|
10
|
+
# !attribute [r] email
|
|
11
|
+
# @return [String, nil] The person's email address, can be nil
|
|
12
|
+
# !attribute [r] team
|
|
13
|
+
# @return [String, nil] The team the person belongs to, can be nil
|
|
14
|
+
# !attribute [r] notes
|
|
15
|
+
# @return [Array<String>] An array of notes about the person
|
|
16
|
+
# !attribute [r] inactive
|
|
17
|
+
# @return [Boolean] Whether the person is inactive (for example left the company)
|
|
18
|
+
class Person
|
|
19
|
+
attr_reader :handle, :github_username, :name, :email, :team, :notes, :inactive
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# @option hash [String] :name The person's full name
|
|
30
|
-
# @option hash [String, nil] :email The person's email address, can be nil
|
|
31
|
-
# @option hash [String, nil] :team The team the person belongs to, can be nil
|
|
32
|
-
# @option hash [Array<String>] :notes An array of notes about the person
|
|
33
|
-
# @return [Person] A new Person instance
|
|
34
|
-
def self.from_hash(hash)
|
|
35
|
-
raise ArgumentError, 'Person handle is required' unless hash[:handle] || hash['handle']
|
|
36
|
-
raise ArgumentError, 'Person name is required' unless hash[:name] || hash['name']
|
|
37
|
-
|
|
38
|
-
handle = hash[:handle] || hash['handle']
|
|
39
|
-
name = hash[:name] || hash['name']
|
|
40
|
-
email = hash[:email] || hash['email']
|
|
41
|
-
team = hash[:team] || hash['team']
|
|
42
|
-
notes = hash[:notes] || hash['notes'] || []
|
|
43
|
-
Person.new(handle: handle, name: name, email: email, team: team, notes: notes)
|
|
44
|
-
end
|
|
21
|
+
def initialize(handle:, name:, **params)
|
|
22
|
+
# params to symbol keys
|
|
23
|
+
params = params.transform_keys(&:to_sym)
|
|
45
24
|
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
@handle = handle
|
|
26
|
+
@name = name
|
|
27
|
+
@github_username = params[:github_username]
|
|
28
|
+
@email = params[:email]
|
|
29
|
+
@team = params[:team]
|
|
30
|
+
@notes = params[:notes] || []
|
|
31
|
+
@inactive = params[:inactive] || false
|
|
32
|
+
end
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
# Returns true if the person is active (not inactive).
|
|
35
|
+
# If not specified, persons are active by default.
|
|
36
|
+
# @return [Boolean] true if active, false otherwise
|
|
37
|
+
def active?
|
|
38
|
+
!@inactive
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns true if the person is marked as inactive.
|
|
42
|
+
# @return [Boolean] true if inactive, false otherwise
|
|
43
|
+
def inactive?
|
|
44
|
+
@inactive
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Creates a new Person instance from a hash of attributes.
|
|
48
|
+
# @param hash [Hash] A hash containing person attributes
|
|
49
|
+
# @option hash [String] :handle The person's handle (username)
|
|
50
|
+
# @option hash [String] :name The person's full name
|
|
51
|
+
# @option hash [String, nil] :email The person's email address, can be nil
|
|
52
|
+
# @option hash [String, nil] :team The team the person belongs to, can be nil
|
|
53
|
+
# @option hash [Array<String>] :notes An array of notes about the person
|
|
54
|
+
# @return [Person] A new Person instance
|
|
55
|
+
def self.from_hash(hash)
|
|
56
|
+
hash = hash.transform_keys(&:to_sym)
|
|
57
|
+
|
|
58
|
+
raise ArgumentError, 'Person handle is required' unless hash[:handle]
|
|
59
|
+
raise ArgumentError, 'Person name is required' unless hash[:name]
|
|
60
|
+
|
|
61
|
+
handle = hash[:handle]
|
|
62
|
+
name = hash[:name]
|
|
63
|
+
Person.new(handle: handle, name: name, **hash)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def to_s
|
|
67
|
+
return "#{name} (~#{handle})" if @email.nil?
|
|
68
|
+
|
|
69
|
+
"#{name} (~#{handle}) <#{email}>"
|
|
70
|
+
end
|
|
51
71
|
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
def ==(other)
|
|
73
|
+
return false unless other.is_a?(Person)
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
handle == other.handle && name == other.name && email == other.email && team == other.team && notes == other.notes
|
|
76
|
+
end
|
|
56
77
|
end
|
|
57
78
|
end
|
data/lib/worklog.rb
CHANGED
|
@@ -157,7 +157,7 @@ module Worklog
|
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
# Show all known people and details about a specific person.
|
|
160
|
-
def people(person = nil,
|
|
160
|
+
def people(person = nil, options = {})
|
|
161
161
|
all_logs = @storage.all_days
|
|
162
162
|
|
|
163
163
|
if person
|
|
@@ -180,6 +180,8 @@ module Worklog
|
|
|
180
180
|
|
|
181
181
|
mentions.each do |handle, v|
|
|
182
182
|
if @people.key?(handle)
|
|
183
|
+
next unless @people[handle].active? || options[:inactive]
|
|
184
|
+
|
|
183
185
|
person = @people[handle]
|
|
184
186
|
print "#{Rainbow(person.name).gold} (#{handle})"
|
|
185
187
|
print " (#{person.team})" if person.team
|
|
@@ -195,6 +197,8 @@ module Worklog
|
|
|
195
197
|
printer = Printer.new(@config, all_people)
|
|
196
198
|
puts "All interactions with #{Rainbow(person.name).gold}"
|
|
197
199
|
|
|
200
|
+
puts "GitHub: #{Rainbow(person.github_username).blue}" if person.github_username
|
|
201
|
+
|
|
198
202
|
if person.notes
|
|
199
203
|
puts 'Notes:'
|
|
200
204
|
person.notes.each do |note|
|