fewald-worklog 0.2.24 → 0.2.26
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/person.rb +31 -0
- data/lib/project.rb +23 -0
- data/lib/storage.rb +7 -1
- data/lib/worklog.rb +1 -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: 36b9165b88874b753ed10bbb1a337626257db5de478fc56c15a475212836879a
|
|
4
|
+
data.tar.gz: fe0e5c279c1fb166876892e9642f85761bc6fdbd7d6e24c14b707bd34bd99668
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a9fafe519688f3b9258aa9b5d433dbec01ea6259fc199e3e302791acfb64a3c2159081b4d749ad86b118da0c5fbca990170c9b42dc986ef0e8bf22ec9e81ddf
|
|
7
|
+
data.tar.gz: a15669d9d071af3ef4124f0c60de3d41a47fb6c1684b90a523c35cfe53576ef9eca9030bed21f8c2b095279327ed84b6e1bde062beb428225bae888f65fc65f7
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.26
|
data/lib/person.rb
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
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
|
|
4
15
|
class Person
|
|
5
16
|
attr_reader :handle, :name, :email, :team, :notes
|
|
6
17
|
|
|
@@ -12,6 +23,26 @@ class Person
|
|
|
12
23
|
@notes = notes
|
|
13
24
|
end
|
|
14
25
|
|
|
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, name, email, team, notes)
|
|
44
|
+
end
|
|
45
|
+
|
|
15
46
|
def to_s
|
|
16
47
|
return "#{name} (~#{handle})" if @email.nil?
|
|
17
48
|
|
data/lib/project.rb
CHANGED
|
@@ -67,5 +67,28 @@ module Worklog
|
|
|
67
67
|
def ended?
|
|
68
68
|
!end_date.nil? && end_date < Date.today
|
|
69
69
|
end
|
|
70
|
+
|
|
71
|
+
# Generate an ASCII activity graph for the project.
|
|
72
|
+
# The graph shows activity over time, with each character representing a day.
|
|
73
|
+
# More active days are represented with a different character.
|
|
74
|
+
# @return [String] An ASCII representation of the activity graph.
|
|
75
|
+
def activity_graph
|
|
76
|
+
graph = String.new
|
|
77
|
+
# Generate the graph for the last 30 days
|
|
78
|
+
(0..29).each do |i|
|
|
79
|
+
date = Date.today - i
|
|
80
|
+
graph << if entries.any? { |entry| entry.time.to_date == date }
|
|
81
|
+
'#'
|
|
82
|
+
else
|
|
83
|
+
'.'
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
graph.reverse!
|
|
88
|
+
|
|
89
|
+
graph << "\n"
|
|
90
|
+
graph << ("#{' ' * 31}^\n")
|
|
91
|
+
graph << ("#{' ' * 31}Today")
|
|
92
|
+
end
|
|
70
93
|
end
|
|
71
94
|
end
|
data/lib/storage.rb
CHANGED
|
@@ -157,7 +157,13 @@ module Worklog
|
|
|
157
157
|
people_file = File.join(@config.storage_path, 'people.yaml')
|
|
158
158
|
return [] unless File.exist?(people_file)
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
yamltext = File.read(people_file)
|
|
161
|
+
if yamltext != yamltext.gsub(/^- !.*$/, '-')
|
|
162
|
+
WorkLogger.debug 'The people.yaml file contains deprecated syntax. Migrating now.'
|
|
163
|
+
yamltext.gsub!(/^- !.*$/, '-')
|
|
164
|
+
File.write(people_file, yamltext)
|
|
165
|
+
end
|
|
166
|
+
YAML.load(yamltext, permitted_classes: []).map { |person_hash| Person.from_hash(person_hash) }
|
|
161
167
|
end
|
|
162
168
|
|
|
163
169
|
# Write people to the people file
|
data/lib/worklog.rb
CHANGED
|
@@ -233,6 +233,7 @@ module Worklog
|
|
|
233
233
|
puts " End date: #{project.end_date.strftime('%b %d, %Y')}" if project.end_date
|
|
234
234
|
puts " Status: #{project.status}" if project.status
|
|
235
235
|
puts " Last activity: #{project.last_activity.strftime('%b %d, %Y')}" if project.last_activity
|
|
236
|
+
puts " #{project.activity_graph}"
|
|
236
237
|
|
|
237
238
|
next unless project.entries && !project.entries.empty?
|
|
238
239
|
|