fewald-worklog 0.2.23 → 0.2.25
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/project.rb +23 -0
- data/lib/worklog.rb +14 -2
- 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: 7412052ae6f6e4ff3fab0cc85cc061a3370aa144a5ae0d720e8b4c18771f71b5
|
|
4
|
+
data.tar.gz: 347ca8cf68c1170c1ccbf2a0d939bc2507257a33c9ae3bdd4cdf8cd46acb1d74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e31310232c8c15e9215adefefcd160cf42dac279c3a5e72cea7b7b1193abf9ed1ce15540237ba90c3f16c719b7c170dd27dd628b1082eef857354b1611e5f9a
|
|
7
|
+
data.tar.gz: b581a94567bbc30cce66f634d9d8c6879c8f0cc82b27867972a0c9c81927516ee2065803347d9e071ddd2e112bf3a2d633c712aec2df188cbeb1c717738fbb37
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.25
|
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/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
|
|
|
@@ -261,6 +262,7 @@ module Worklog
|
|
|
261
262
|
end
|
|
262
263
|
end
|
|
263
264
|
|
|
265
|
+
# Show overview of all tags used in the work log including their count.
|
|
264
266
|
def tag_overview
|
|
265
267
|
all_logs = @storage.all_days
|
|
266
268
|
puts Rainbow('Tags used in the work log:').gold
|
|
@@ -268,11 +270,21 @@ module Worklog
|
|
|
268
270
|
# Count all tags used in the work log
|
|
269
271
|
tags = all_logs.map(&:entries).flatten.map(&:tags).flatten.compact.tally
|
|
270
272
|
|
|
273
|
+
# Calculate the maximum count for scaling the output if needed
|
|
274
|
+
max_count = tags.values.max || 0
|
|
275
|
+
factor = 32.0 / max_count # Scale to a maximum of 32 characters wide
|
|
276
|
+
|
|
277
|
+
# Calculate longest number length for formatting
|
|
278
|
+
num_length = max_count.to_s.length
|
|
279
|
+
|
|
271
280
|
# Determine length of longest tag for formatting
|
|
272
|
-
# Add one
|
|
281
|
+
# Add one additional space for formatting
|
|
273
282
|
max_len = tags.empty? ? 0 : tags.keys.map(&:length).max + 1
|
|
274
283
|
|
|
275
|
-
tags.sort.each
|
|
284
|
+
tags.sort.each do |k, v|
|
|
285
|
+
print "#{Rainbow(k.to_s.rjust(max_len)).gold}: #{v.to_s.rjust(num_length)} "
|
|
286
|
+
puts '#' * (v * factor).ceil
|
|
287
|
+
end
|
|
276
288
|
end
|
|
277
289
|
|
|
278
290
|
# Show detailed information about a specific tag
|