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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/cli.rb +1 -0
  4. data/lib/person.rb +69 -48
  5. data/lib/worklog.rb +5 -1
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a506272e4cd5333bf7cde0d53485b610824df90266582bea673c80b21d068cb8
4
- data.tar.gz: 8370a7e86257ffe693ad26f43814a35c78d0196e6594e0987e4b7242c75b0dad
3
+ metadata.gz: f4b6b051e9dd15f4588ddcff4a3f23686077c3b6fa8c8fda053cd6187a91a34c
4
+ data.tar.gz: 7a3b6ff79f314e30016776efed9fbe2a76b68e46658c4658185577f27a7cf3bf
5
5
  SHA512:
6
- metadata.gz: 9e53674d918ee23dd49e66a833c2d86f8653d5ff84db5833bcf13864b121d843c09b2dfc94f4c92c38f5cd485d977fbc1f68a53efc71f9cb755589ac83e96552
7
- data.tar.gz: 56d7e076bef0e561e1c4b1adf26c4b04c4a781bdc36f159460e4972f5645d7ea868de7df5625e7bb640377cee640be71f658cb5c0cd65e1d003f1dc1fcf26384
6
+ metadata.gz: 23c300fa90069057589a947ff9da63db056f28bc7021ba7a9a19cfd28dbf424ed1ada21a24a76cd29b72f1810a7f7c14bdd9c4547b84e330ef96e99b1dbfd640
7
+ data.tar.gz: 627e537ca0e1530d64bf7b4a1c78709f9910bcec382ed8c1dba43d7a0c35bc32f1488f45490d8432d5aae0cf4db1e8692982a46416821b8afe7bf8108738f58f
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.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
- # Represents a person at work.
4
- #
5
- # !attribute [r] handle
6
- # @return [String] The person's handle (username)
7
- # !attribute [r] name
8
- # @return [String] The person's full name
9
- # !attribute [r] email
10
- # @return [String, nil] The person's email address, can be nil
11
- # !attribute [r] team
12
- # @return [String, nil] The team the person belongs to, can be nil
13
- # !attribute [r] notes
14
- # @return [Array<String>] An array of notes about the person
15
- class Person
16
- attr_reader :handle, :name, :email, :team, :notes
17
-
18
- def initialize(handle:, name:, email:, team:, notes: [])
19
- @handle = handle
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
- # Creates a new Person instance from a hash of attributes.
27
- # @param hash [Hash] A hash containing person attributes
28
- # @option hash [String] :handle The person's handle (username)
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
- def to_s
47
- return "#{name} (~#{handle})" if @email.nil?
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
- "#{name} (~#{handle}) <#{email}>"
50
- end
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
- def ==(other)
53
- return false unless other.is_a?(Person)
72
+ def ==(other)
73
+ return false unless other.is_a?(Person)
54
74
 
55
- handle == other.handle && name == other.name && email == other.email && team == other.team && notes == other.notes
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, _options = {})
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|
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.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Friedrich Ewald