doing 0.2.2.pre → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/bin/doing +43 -5
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +72 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9113d5736076e7608e42c328d3bc6a9f6edb517e
|
4
|
+
data.tar.gz: 793034d75510f42fa2c9f2e3f75d26156fef4d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd187715ead8168b92c2a70ebe53d68d95271a241524a1011c82c9358cae43ed0766dea0b1fe73c469d112435921342e2fb9811af2835f039d9ab1445519196f
|
7
|
+
data.tar.gz: 11c41e6db6c47490ff82b922a262df3292808e6b5736babf3d12a28de96075f91322da61f882c73178a7b9240c82c8056f7f99180bee8c309d1dc852f7427ddc
|
data/README.md
CHANGED
@@ -109,8 +109,9 @@ The config also contains templates for various command outputs. Include placehol
|
|
109
109
|
- `%hr`: a horizontal rule (`-`) the width of the terminal
|
110
110
|
- `%hr_under`: a horizontal rule (`_`) the width of the terminal
|
111
111
|
- `%[color]`: color can be black, red, green, blue, yellow, magenta, cyan or white
|
112
|
-
|
113
|
-
|
112
|
+
- you can prefix "bg" to affect background colors (%bgyellow)
|
113
|
+
- prefix "bold" and "boldbg" for strong colors (%boldgreen, %boldbgblue)
|
114
|
+
- `%interval`: when used with the `-t` switch on the `show` command, it will display the time between a timestamp or `@start(date)` tag and the `@done(date)` tag, if it exists. Otherwise, it will remain empty.
|
114
115
|
|
115
116
|
Date formats are based on Ruby [strftime](http://www.ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-i-strftime) formatting.
|
116
117
|
|
@@ -293,6 +294,8 @@ You can filter the `show` command by tags. Simply list them after the section na
|
|
293
294
|
|
294
295
|
Use `-c X` to limit the displayed results. Combine it with `-a newest` or `-a oldest` to choose which chronological end it trims from. You can also set the sort order of the output with `-s asc` or `-s desc`.
|
295
296
|
|
297
|
+
The `show` command can also show the time spent on a task if it has a `@done(date)` tag with the `-t` option. This requires that you include a `%interval` token in template -> default in the config. You can also include `@start(date)` tags, which override the timestamp when calculating the intervals.
|
298
|
+
|
296
299
|
If you have a use for it, you can use `--csv` on the show or view commands to output the results as a comma-separated CSV to STDOUT. Redirect to a file to save it: `doing show all done --csv > ~/Desktop/done.csv`.
|
297
300
|
|
298
301
|
#### Views
|
data/bin/doing
CHANGED
@@ -140,7 +140,7 @@ command :done do |c|
|
|
140
140
|
c.switch [:a,:archive], :negatable => false, :default_value => false
|
141
141
|
|
142
142
|
c.desc 'Backdate to "date_string" (natural language)'
|
143
|
-
c.flag [:
|
143
|
+
c.flag [:back]
|
144
144
|
|
145
145
|
c.desc 'Section'
|
146
146
|
c.default_value wwid.current_section
|
@@ -287,9 +287,17 @@ command :show do |c|
|
|
287
287
|
c.flag [:s,:sort], :default_value => 'asc'
|
288
288
|
|
289
289
|
c.desc 'Output to csv'
|
290
|
-
c.default_value
|
290
|
+
c.default_value false
|
291
291
|
c.switch [:csv], :default_value => false, :negatable => false
|
292
292
|
|
293
|
+
c.desc 'Show time intervals on @done tasks'
|
294
|
+
c.default_value false
|
295
|
+
c.switch [:t,:times], :default_value => false
|
296
|
+
|
297
|
+
c.desc 'Show intervals with totals at the end of output'
|
298
|
+
c.default_value false
|
299
|
+
c.switch [:totals], :default_value => false, :negatable => true
|
300
|
+
|
293
301
|
c.action do |global_options,options,args|
|
294
302
|
tag_filter = false
|
295
303
|
tags = []
|
@@ -317,7 +325,12 @@ command :show do |c|
|
|
317
325
|
}
|
318
326
|
end
|
319
327
|
|
320
|
-
|
328
|
+
options[:t] = true if options[:totals]
|
329
|
+
|
330
|
+
puts wwid.list_section({:section => section, :count => options[:c].to_i, :tag_filter => tag_filter, :age => options[:a], :order => options[:s], :csv => options[:csv], :times => options[:t]})
|
331
|
+
|
332
|
+
puts wwid.tag_times if options[:totals]
|
333
|
+
|
321
334
|
end
|
322
335
|
end
|
323
336
|
|
@@ -345,8 +358,21 @@ end
|
|
345
358
|
|
346
359
|
desc 'List entries from today'
|
347
360
|
command :today do |c|
|
361
|
+
c.desc 'Show time intervals on @done tasks'
|
362
|
+
c.default_value false
|
363
|
+
c.switch [:t,:times], :default_value => false
|
364
|
+
|
365
|
+
c.desc 'Show time totals at the end of output'
|
366
|
+
c.default_value false
|
367
|
+
c.switch [:totals], :default_value => false, :negatable => true
|
368
|
+
|
348
369
|
c.action do |global_options,options,args|
|
349
|
-
|
370
|
+
|
371
|
+
options[:t] = true if options[:totals]
|
372
|
+
|
373
|
+
puts wwid.today(options[:t]).strip
|
374
|
+
|
375
|
+
puts wwid.tag_times if options[:totals]
|
350
376
|
end
|
351
377
|
end
|
352
378
|
|
@@ -398,6 +424,14 @@ command :view do |c|
|
|
398
424
|
c.default_value 'false'
|
399
425
|
c.switch [:csv], :default_value => false, :negatable => false
|
400
426
|
|
427
|
+
c.desc 'Show time intervals on @done tasks'
|
428
|
+
c.default_value false
|
429
|
+
c.switch [:t,:times], :default_value => false
|
430
|
+
|
431
|
+
c.desc 'Show intervals with totals at the end of output'
|
432
|
+
c.default_value false
|
433
|
+
c.switch [:totals], :default_value => false, :negatable => true
|
434
|
+
|
401
435
|
c.action do |global_options,options,args|
|
402
436
|
if args.empty?
|
403
437
|
title = wwid.choose_view
|
@@ -429,7 +463,11 @@ command :view do |c|
|
|
429
463
|
count = options[:c] ? options[:c] : view.has_key?('count') ? view['count'] : 10
|
430
464
|
section = options[:s] ? section : view.has_key?('section') ? view['section'] : wwid.current_section
|
431
465
|
order = view.has_key?('order') ? view['order'] : "asc"
|
432
|
-
|
466
|
+
options[:t] = true if options[:totals]
|
467
|
+
|
468
|
+
puts wwid.list_section({:section => section, :count => count, :template => template, :format => format, :order => order, :tag_filter => tag_filter, :csv => options[:csv], :tags_color => tags_color, :times => options[:t] })
|
469
|
+
|
470
|
+
puts wwid.tag_times if options[:totals]
|
433
471
|
else
|
434
472
|
raise "View #{title} not found in config"
|
435
473
|
end
|
data/lib/doing/version.rb
CHANGED
data/lib/doing/wwid.rb
CHANGED
@@ -13,7 +13,7 @@ class WWID
|
|
13
13
|
|
14
14
|
def initialize(input=nil)
|
15
15
|
@content = {}
|
16
|
-
|
16
|
+
@timers = {}
|
17
17
|
@config = read_config
|
18
18
|
|
19
19
|
@config['doing_file'] ||= "~/what_was_i_doing.md"
|
@@ -27,7 +27,7 @@ class WWID
|
|
27
27
|
}
|
28
28
|
@config['templates']['today'] ||= {
|
29
29
|
'date_format' => '%_I:%M%P',
|
30
|
-
'template' => '%date: %title%note',
|
30
|
+
'template' => '%date: %title %interval%note',
|
31
31
|
'wrap_width' => 0
|
32
32
|
}
|
33
33
|
@config['templates']['last'] ||= {
|
@@ -380,6 +380,7 @@ class WWID
|
|
380
380
|
opt[:today] ||= false
|
381
381
|
opt[:tag_filter] ||= false
|
382
382
|
opt[:tags_color] ||= false
|
383
|
+
opt[:times] ||= false
|
383
384
|
|
384
385
|
if opt[:section].nil?
|
385
386
|
opt[:section] = @content[choose_section]
|
@@ -481,6 +482,13 @@ class WWID
|
|
481
482
|
end
|
482
483
|
|
483
484
|
output.sub!(/%date/,item['date'].strftime(opt[:format]))
|
485
|
+
|
486
|
+
if item['title'] =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/ && opt[:times]
|
487
|
+
interval = get_interval(item)
|
488
|
+
end
|
489
|
+
interval ||= ""
|
490
|
+
output.sub!(/%interval/,interval)
|
491
|
+
|
484
492
|
output.sub!(/%shortdate/) {
|
485
493
|
if item['date'] > Date.today.to_time
|
486
494
|
item['date'].strftime('%_I:%M%P')
|
@@ -580,9 +588,9 @@ class WWID
|
|
580
588
|
list_section({:section => @current_section, :wrap_width => cfg['wrap_width'], :count => 0, :format => cfg['date_format'], :template => cfg['template'], :order => order})
|
581
589
|
end
|
582
590
|
|
583
|
-
def today
|
591
|
+
def today(times=false)
|
584
592
|
cfg = @config['templates']['today']
|
585
|
-
list_section({:section => @current_section, :wrap_width => cfg['wrap_width'], :count => 0, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :today => true})
|
593
|
+
list_section({:section => @current_section, :wrap_width => cfg['wrap_width'], :count => 0, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :today => true, :times => times})
|
586
594
|
end
|
587
595
|
|
588
596
|
def recent(count=10,section=nil)
|
@@ -597,8 +605,68 @@ class WWID
|
|
597
605
|
list_section({:section => @current_section, :wrap_width => cfg['wrap_width'], :count => 1, :format => cfg['date_format'], :template => cfg['template']})
|
598
606
|
end
|
599
607
|
|
608
|
+
def tag_times
|
609
|
+
output = []
|
610
|
+
return "" if @timers.length == 0
|
611
|
+
max = @timers.keys.sort_by {|k| k.length }.reverse[0].length + 1
|
612
|
+
|
613
|
+
total = @timers.delete("All")
|
614
|
+
|
615
|
+
@timers.sort_by{|k,v| v }.reverse.each {|k,v|
|
616
|
+
spacer = ""
|
617
|
+
(max - k.length).times do
|
618
|
+
spacer += " "
|
619
|
+
end
|
620
|
+
output.push("#{k}:#{spacer}#{"%02d:%02d:%02d" % fmt_time(v)}")
|
621
|
+
}
|
622
|
+
output.empty? ? "" : "\n--- Tag Totals ---\n" + output.join("\n") + "\n\nTotal tracked: #{"%02d:%02d:%02d" % fmt_time(total)}\n"
|
623
|
+
end
|
624
|
+
|
625
|
+
private
|
626
|
+
|
627
|
+
def get_interval(item)
|
628
|
+
done = nil
|
629
|
+
start = nil
|
630
|
+
|
631
|
+
if item['title'] =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/
|
632
|
+
done = Time.parse($1)
|
633
|
+
else
|
634
|
+
return nil
|
635
|
+
end
|
636
|
+
|
637
|
+
if item['title'] =~ /@start\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/
|
638
|
+
start = Time.parse($1)
|
639
|
+
else
|
640
|
+
start = item['date']
|
641
|
+
end
|
642
|
+
|
643
|
+
seconds = (done - start).to_i
|
644
|
+
|
645
|
+
item['title'].scan(/(?mi)@(\S+?)(\(.*\))?(?=\s|$)/).each {|m|
|
646
|
+
k = m[0] == "done" ? "All" : m[0]
|
647
|
+
if @timers.has_key?(k)
|
648
|
+
@timers[k] += seconds
|
649
|
+
else
|
650
|
+
@timers[k] = seconds
|
651
|
+
end
|
652
|
+
}
|
653
|
+
|
654
|
+
"%02d:%02d:%02d" % fmt_time(seconds)
|
655
|
+
end
|
656
|
+
|
657
|
+
def fmt_time(seconds)
|
658
|
+
minutes = (seconds / 60).to_i
|
659
|
+
hours = (minutes / 60).to_i
|
660
|
+
days = (hours / 24).to_i
|
661
|
+
hours = (hours % 60).to_i
|
662
|
+
minutes = (minutes % 60).to_i
|
663
|
+
[days, hours, minutes]
|
664
|
+
end
|
600
665
|
end
|
601
666
|
|
667
|
+
|
668
|
+
|
669
|
+
|
602
670
|
# infile = "~/Dropbox/nvALT2.2/?? What was I doing.md"
|
603
671
|
|
604
672
|
# wwid = WWID.new(infile)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
@@ -130,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
requirements:
|
133
|
-
- - '
|
133
|
+
- - '>='
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
135
|
+
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
138
|
rubygems_version: 2.2.2
|