task_report 0.4.3 → 0.5.3

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
  SHA1:
3
- metadata.gz: c080be99f258e8a5ceeba925741c6b6fcf72bef9
4
- data.tar.gz: 5d376f50436b0b44a871e41ad6ad152be3f66d40
3
+ metadata.gz: 44c0dac375e7e16141977b24a08fcea97b4f8fb4
4
+ data.tar.gz: 1f5f2d07631828b73e3eac41aba1aab01acbae53
5
5
  SHA512:
6
- metadata.gz: 2c6b4a293035101e6aec6cb137a341e9b84574d11e86590221939d50893c0961929b54b899b0e6748ef956cc18a2889aa06b1dcf18a53614833021af1d5bfa16
7
- data.tar.gz: b563663acce8e241e4cb0fd4299fb325744783df8775d8c0e4480032aa772e080f1ef6e821f5c897f9faaa4c8be74a3e402d3c643c77cf01d757e170aae4eed8
6
+ metadata.gz: 1da1947ec2f57d33474fb109db1b44ee9fadc8b494a1e7441cf70b5a1418fcb4aa3083967107a64bcad18c15183d0efacee26092d5364bcb5b88eb9baf9e48c2
7
+ data.tar.gz: f2c949e04705e5452b53ca0932d4d1c5878dcce94de6e1f8fe6dd5ac058983db32fcbc4bf45cc9c2ea632e9162863b962f7390fe870fdb2624a119824f4a67e3
data/README.md CHANGED
@@ -54,6 +54,9 @@ Use `task` as follows:
54
54
  - adds arbitrary note TASK_NOTE to task TASK_ID
55
55
  - these notes will be appear in summaries as line items (markdown supported)
56
56
 
57
+ `task total`
58
+ - displays the total tracked time for today
59
+
57
60
  `task help`
58
61
  - shows this message
59
62
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.3
data/bin/task CHANGED
@@ -36,6 +36,9 @@ def show_usage_message(exit_status = 0)
36
36
  - adds arbitrary note TASK_NOTE to task TASK_ID
37
37
  - these notes will be appear in summaries as line items (markdown supported)
38
38
 
39
+ `task total`
40
+ - displays the total tracked time for today
41
+
39
42
  `task help`
40
43
  - shows this message"
41
44
 
@@ -61,6 +64,8 @@ when 'summary'
61
64
  TaskReport.summary(ARGV[1])
62
65
  when 'note'
63
66
  TaskReport.note(ARGV[1], ARGV[2])
67
+ when 'total'
68
+ TaskReport.total
64
69
  else
65
70
  show_usage_message
66
71
  end
@@ -11,7 +11,12 @@ module TaskReport
11
11
  min %= 60
12
12
  hour, _ = @seconds.divmod(3600)
13
13
 
14
- "#{hour} hours, #{min} minutes, #{sec} seconds"
14
+ result = []
15
+ result << "#{hour} hours" if hour > 0
16
+ result << "#{min} mins" if min > 0
17
+ result << "#{sec} seconds" if sec > 0
18
+
19
+ result.join(', ')
15
20
  end
16
21
  end
17
22
  end
@@ -116,6 +116,8 @@ module TaskReport
116
116
  task.notes.each do |note|
117
117
  puts " - #{note}"
118
118
  end
119
+
120
+ puts "\nTotal time tracked: #{total_duration.to_s}"
119
121
  end
120
122
  end
121
123
 
@@ -155,6 +157,10 @@ module TaskReport
155
157
  puts "Note added to #{task.to_s}"
156
158
  end
157
159
 
160
+ def total
161
+ puts total_duration.to_s
162
+ end
163
+
158
164
  private
159
165
  def initialize(description:, json_file_name:, gist_id: nil, gist_html_url: nil, existing_json_content: {})
160
166
  @description = description
@@ -245,7 +251,19 @@ module TaskReport
245
251
  end
246
252
  end
247
253
 
254
+ lines << ''
255
+ lines << "#### Total time tracked: #{total_duration.to_s}"
256
+
248
257
  lines.join("\n")
249
258
  end
259
+
260
+ def total_duration
261
+ total_time_in_seconds =
262
+ @tasks.inject(0) do |sum, task|
263
+ sum + task.total_time_in_seconds
264
+ end
265
+
266
+ Duration.new(total_time_in_seconds)
267
+ end
250
268
  end
251
269
  end
@@ -45,11 +45,13 @@ module TaskReport
45
45
  end
46
46
 
47
47
  def duration
48
- Duration.new(
49
- @time.inject(0) do |sum, time|
50
- sum + ( (time[:end] || Time.now) - time[:start] )
51
- end
52
- )
48
+ Duration.new(total_time_in_seconds)
49
+ end
50
+
51
+ def total_time_in_seconds
52
+ @time.inject(0) do |sum, time|
53
+ sum + ( (time[:end] || Time.now) - time[:start] )
54
+ end
53
55
  end
54
56
 
55
57
  def stop
data/lib/task_report.rb CHANGED
@@ -126,6 +126,13 @@ module TaskReport
126
126
  puts "Task '#{identifier}' does not exist - nothing to do."
127
127
  end
128
128
 
129
+ def total
130
+ return if no_gist?
131
+
132
+ @report ||= Report.create_from_gist(report_gist)
133
+ @report.total
134
+ end
135
+
129
136
  private
130
137
  def report_gist
131
138
  @report_gist ||=
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: task_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Pataki