doing 1.0.37 → 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/doing +66 -7
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +42 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f715c083c72c609fb2e2fc8c730cca68b8391dccbc4ca2168333dd9b30df0887
|
4
|
+
data.tar.gz: 3d7df2ec9624ae8d2b6822ccceed402c42f82f2a5b2e010c639880c9cd95580f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4287daf5a4821ff6e295c36275d2101ecebefdc0adc962faefe82c460bd52f2e9a1a69e767e3ad59f7d68074a86807496e3e1669dd7f6f68688da903fb370309
|
7
|
+
data.tar.gz: 4a62305048b02bac186c63f951a6e3a7985663dc826070801c3a333b8e9388147435639910ac0f1fe24b0ad5a90e15b61510c0799ce94cf84060ca8fad097f0b
|
data/bin/doing
CHANGED
@@ -604,6 +604,13 @@ command :show do |c|
|
|
604
604
|
c.default_value false
|
605
605
|
c.switch [:totals], :default_value => false, :negatable => true
|
606
606
|
|
607
|
+
c.desc 'Sort tags by (name|time)'
|
608
|
+
default = 'time'
|
609
|
+
if wwid.config.has_key?('tag_sort')
|
610
|
+
default = wwid.config['tag_sort']
|
611
|
+
end
|
612
|
+
c.flag [:tag_sort], :default_value => default
|
613
|
+
|
607
614
|
c.desc 'Only show items with recorded time intervals'
|
608
615
|
c.default_value false
|
609
616
|
c.switch [:only_timed], :default_value => false, :negatable => false
|
@@ -666,7 +673,9 @@ command :show do |c|
|
|
666
673
|
|
667
674
|
options[:t] = true if options[:totals]
|
668
675
|
|
669
|
-
|
676
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
677
|
+
|
678
|
+
puts wwid.list_section({:section => section, :date_filter => dates, :count => options[:c].to_i, :tag_filter => tag_filter, :age => options[:a], :order => options[:s], :output => options[:output], :times => options[:t], :totals => options[:totals], :sort_tags => options[:sort_tags], :highlight => true, :only_timed => options[:only_timed]})
|
670
679
|
|
671
680
|
end
|
672
681
|
end
|
@@ -690,6 +699,13 @@ command [:grep,:search] do |c|
|
|
690
699
|
c.default_value false
|
691
700
|
c.switch [:totals], :default_value => false, :negatable => true
|
692
701
|
|
702
|
+
c.desc 'Sort tags by (name|time)'
|
703
|
+
default = 'time'
|
704
|
+
if wwid.config.has_key?('tag_sort')
|
705
|
+
default = wwid.config['tag_sort']
|
706
|
+
end
|
707
|
+
c.flag [:tag_sort], :default_value => default
|
708
|
+
|
693
709
|
c.desc 'Only show items with recorded time intervals'
|
694
710
|
c.default_value false
|
695
711
|
c.switch [:only_timed], :default_value => false, :negatable => false
|
@@ -699,8 +715,9 @@ command [:grep,:search] do |c|
|
|
699
715
|
section = wwid.guess_section(options[:s]) if options[:s]
|
700
716
|
|
701
717
|
options[:t] = true if options[:totals]
|
718
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
702
719
|
|
703
|
-
puts wwid.list_section({:search => args.join(' '), :section => section, :output => options[:output], :times => options[:t], :highlight => true, :totals => options[:totals], :only_timed => options[:only_timed]})
|
720
|
+
puts wwid.list_section({:search => args.join(' '), :section => section, :output => options[:output], :times => options[:t], :highlight => true, :totals => options[:totals], :only_timed => options[:only_timed], :sort_tags => options[:sort_tags]})
|
704
721
|
|
705
722
|
end
|
706
723
|
end
|
@@ -721,6 +738,13 @@ command :recent do |c|
|
|
721
738
|
c.default_value false
|
722
739
|
c.switch [:totals], :default_value => false, :negatable => true
|
723
740
|
|
741
|
+
c.desc 'Sort tags by (name|time)'
|
742
|
+
default = 'time'
|
743
|
+
if wwid.config.has_key?('tag_sort')
|
744
|
+
default = wwid.config['tag_sort']
|
745
|
+
end
|
746
|
+
c.flag [:tag_sort], :default_value => default
|
747
|
+
|
724
748
|
c.action do |global_options,options,args|
|
725
749
|
|
726
750
|
section = wwid.guess_section(options[:s]) || options[:s].cap_first
|
@@ -732,8 +756,9 @@ command :recent do |c|
|
|
732
756
|
count = 10
|
733
757
|
end
|
734
758
|
options[:t] = true if options[:totals]
|
759
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
735
760
|
|
736
|
-
puts wwid.recent(count,section.cap_first,{ :times => options[:t], :totals => options[:totals] })
|
761
|
+
puts wwid.recent(count,section.cap_first,{ :times => options[:t], :totals => options[:totals], :sort_tags => options[:sort_tags] })
|
737
762
|
|
738
763
|
end
|
739
764
|
end
|
@@ -754,14 +779,22 @@ command :today do |c|
|
|
754
779
|
c.default_value false
|
755
780
|
c.switch [:totals], :default_value => false, :negatable => true
|
756
781
|
|
782
|
+
c.desc 'Sort tags by (name|time)'
|
783
|
+
default = 'time'
|
784
|
+
if wwid.config.has_key?('tag_sort')
|
785
|
+
default = wwid.config['tag_sort']
|
786
|
+
end
|
787
|
+
c.flag [:tag_sort], :default_value => default
|
788
|
+
|
757
789
|
c.desc 'Output to export format (csv|html|json)'
|
758
790
|
c.flag [:o,:output]
|
759
791
|
|
760
792
|
c.action do |global_options,options,args|
|
761
793
|
|
762
794
|
options[:t] = true if options[:totals]
|
795
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
763
796
|
|
764
|
-
puts wwid.today(options[:t],options[:output],{:totals => options[:totals], :section => options[:s]}).chomp
|
797
|
+
puts wwid.today(options[:t],options[:output],{:totals => options[:totals], :section => options[:s], :sort_tags => options[:sort_tags]}).chomp
|
765
798
|
|
766
799
|
end
|
767
800
|
end
|
@@ -783,6 +816,13 @@ command :on do |c|
|
|
783
816
|
c.default_value false
|
784
817
|
c.switch [:totals], :default_value => false, :negatable => true
|
785
818
|
|
819
|
+
c.desc 'Sort tags by (name|time)'
|
820
|
+
default = 'time'
|
821
|
+
if wwid.config.has_key?('tag_sort')
|
822
|
+
default = wwid.config['tag_sort']
|
823
|
+
end
|
824
|
+
c.flag [:tag_sort], :default_value => default
|
825
|
+
|
786
826
|
c.desc 'Output to export format (csv|html|json)'
|
787
827
|
c.flag [:o,:output]
|
788
828
|
|
@@ -806,8 +846,9 @@ command :on do |c|
|
|
806
846
|
wwid.results.push(message)
|
807
847
|
|
808
848
|
options[:t] = true if options[:totals]
|
849
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
809
850
|
|
810
|
-
puts wwid.list_date([start,finish],options[:s],options[:t],options[:output],{:totals => options[:totals]}).chomp
|
851
|
+
puts wwid.list_date([start, finish], options[:s], options[:t], options[:output], {:totals => options[:totals], :sort_tags => options[:sort_tags]}).chomp
|
811
852
|
|
812
853
|
end
|
813
854
|
end
|
@@ -830,8 +871,16 @@ command :yesterday do |c|
|
|
830
871
|
c.default_value false
|
831
872
|
c.switch [:totals], :default_value => false, :negatable => true
|
832
873
|
|
874
|
+
c.desc 'Sort tags by (name|time)'
|
875
|
+
default = 'time'
|
876
|
+
if wwid.config.has_key?('tag_sort')
|
877
|
+
default = wwid.config['tag_sort']
|
878
|
+
end
|
879
|
+
c.flag [:tag_sort], :default_value => default
|
880
|
+
|
833
881
|
c.action do |global_options, options,args|
|
834
|
-
|
882
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
883
|
+
puts wwid.yesterday(options[:s],options[:t],options[:o],{:totals => options[:totals], :sort_tags => options[:sort_tags]}).chomp
|
835
884
|
|
836
885
|
end
|
837
886
|
end
|
@@ -918,6 +967,13 @@ command :view do |c|
|
|
918
967
|
c.default_value false
|
919
968
|
c.switch [:totals], :default_value => false, :negatable => true
|
920
969
|
|
970
|
+
c.desc 'Sort tags by (name|time)'
|
971
|
+
default = 'time'
|
972
|
+
if wwid.config.has_key?('tag_sort')
|
973
|
+
default = wwid.config['tag_sort']
|
974
|
+
end
|
975
|
+
c.flag [:tag_sort], :default_value => default
|
976
|
+
|
921
977
|
c.desc 'Only show items with recorded time intervals'
|
922
978
|
c.default_value false
|
923
979
|
c.switch [:only_timed], :default_value => false, :negatable => true
|
@@ -963,9 +1019,12 @@ command :view do |c|
|
|
963
1019
|
count = options[:c] ? options[:c] : view.has_key?('count') ? view['count'] : 10
|
964
1020
|
section = options[:s] ? section : view.has_key?('section') ? view['section'] : wwid.current_section
|
965
1021
|
order = view.has_key?('order') ? view['order'] : "asc"
|
1022
|
+
|
966
1023
|
options[:t] = true if options[:totals]
|
967
1024
|
options[:output].downcase! if options[:output]
|
968
|
-
|
1025
|
+
options[:sort_tags] = options[:tag_sort] =~ /^n/i
|
1026
|
+
|
1027
|
+
puts wwid.list_section({:section => section, :count => count, :template => template, :format => format, :order => order, :tag_filter => tag_filter, :output => options[:o], :tags_color => tags_color, :times => options[:t], :highlight => true, :totals => options[:totals], :only_timed => only_timed, :sort_tags => options[:sort_tags] })
|
969
1028
|
else
|
970
1029
|
if title.class == FalseClass
|
971
1030
|
exit_now! "Cancelled"
|
data/lib/doing/version.rb
CHANGED
data/lib/doing/wwid.rb
CHANGED
@@ -188,6 +188,7 @@ class WWID
|
|
188
188
|
@config['marker_tag'] ||= 'flagged'
|
189
189
|
@config['marker_color'] ||= 'red'
|
190
190
|
@config['default_tags'] ||= []
|
191
|
+
@config['tag_sort'] ||= 'time'
|
191
192
|
|
192
193
|
@current_section = config['current_section']
|
193
194
|
@default_template = config['templates']['default']['template']
|
@@ -997,6 +998,7 @@ class WWID
|
|
997
998
|
opt[:tags_color] ||= false
|
998
999
|
opt[:times] ||= false
|
999
1000
|
opt[:totals] ||= false
|
1001
|
+
opt[:sort_tags] ||= false
|
1000
1002
|
opt[:search] ||= false
|
1001
1003
|
opt[:only_timed] ||= false
|
1002
1004
|
opt[:date_filter] ||= []
|
@@ -1123,7 +1125,6 @@ class WWID
|
|
1123
1125
|
}
|
1124
1126
|
out = output.join("")
|
1125
1127
|
elsif opt[:output] == "json" || opt[:output] == "timeline"
|
1126
|
-
|
1127
1128
|
items_out = []
|
1128
1129
|
max = items[-1]['date'].strftime('%F')
|
1129
1130
|
min = items[0]['date'].strftime('%F')
|
@@ -1135,7 +1136,6 @@ class WWID
|
|
1135
1136
|
title = i['title']
|
1136
1137
|
note = i['note'].map { |line| line.strip } if i['note']
|
1137
1138
|
end
|
1138
|
-
|
1139
1139
|
if i['title'] =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/ && opt[:times]
|
1140
1140
|
end_date = Time.parse($1)
|
1141
1141
|
interval = get_interval(i,false)
|
@@ -1150,14 +1150,16 @@ class WWID
|
|
1150
1150
|
tags.push(tag[0]) unless skip_tags.include?(tag[0])
|
1151
1151
|
}
|
1152
1152
|
if opt[:output] == "json"
|
1153
|
+
|
1153
1154
|
items_out << {
|
1154
1155
|
:date => i['date'],
|
1155
1156
|
:end_date => end_date,
|
1156
1157
|
:title => title.strip, #+ " #{note}"
|
1157
|
-
:note => note.class == Array ? note.join("\n") : note,
|
1158
|
+
:note => note.class == Array ? note.map(&:strip).join("\n") : note,
|
1158
1159
|
:time => "%02d:%02d:%02d" % fmt_time(interval),
|
1159
1160
|
:tags => tags
|
1160
1161
|
}
|
1162
|
+
|
1161
1163
|
elsif opt[:output] == "timeline"
|
1162
1164
|
new_item = {
|
1163
1165
|
'id' => index + 1,
|
@@ -1180,7 +1182,7 @@ class WWID
|
|
1180
1182
|
out = {
|
1181
1183
|
'section' => section,
|
1182
1184
|
'items' => items_out,
|
1183
|
-
'timers' => tag_times("json")
|
1185
|
+
'timers' => tag_times("json", opt[:sort_tags])
|
1184
1186
|
}.to_json
|
1185
1187
|
elsif opt[:output] == "timeline"
|
1186
1188
|
template =<<EOTEMPLATE
|
@@ -1263,7 +1265,7 @@ EOTEMPLATE
|
|
1263
1265
|
style = css_template
|
1264
1266
|
end
|
1265
1267
|
|
1266
|
-
totals = opt[:totals] ? tag_times("html") : ""
|
1268
|
+
totals = opt[:totals] ? tag_times("html", opt[:sort_tags]) : ""
|
1267
1269
|
engine = Haml::Engine.new(template)
|
1268
1270
|
puts engine.render(Object.new, { :@items => items_out, :@page_title => page_title, :@style => style, :@totals => totals })
|
1269
1271
|
else
|
@@ -1278,7 +1280,7 @@ EOTEMPLATE
|
|
1278
1280
|
end
|
1279
1281
|
|
1280
1282
|
if (item.has_key?('note') && !item['note'].empty?) && @config[:include_notes]
|
1281
|
-
note_lines = item['note'].delete_if{|line| line =~ /^\s*$/ }.map{|line| "\t" + line.sub(/^\t*/,'') + " " }
|
1283
|
+
note_lines = item['note'].delete_if{|line| line =~ /^\s*$/ }.map{|line| "\t\t" + line.sub(/^\t*/,'').sub(/^-/, '—') + " " }
|
1282
1284
|
if opt[:wrap_width] && opt[:wrap_width] > 0
|
1283
1285
|
width = opt[:wrap_width]
|
1284
1286
|
note_lines.map! {|line|
|
@@ -1353,7 +1355,7 @@ EOTEMPLATE
|
|
1353
1355
|
|
1354
1356
|
out += output + "\n"
|
1355
1357
|
}
|
1356
|
-
out += tag_times if opt[:totals]
|
1358
|
+
out += tag_times("text", opt[:sort_tags]) if opt[:totals]
|
1357
1359
|
end
|
1358
1360
|
return out
|
1359
1361
|
end
|
@@ -1526,8 +1528,10 @@ EOTEMPLATE
|
|
1526
1528
|
##
|
1527
1529
|
def today(times=true,output=nil,opt={})
|
1528
1530
|
opt[:totals] ||= false
|
1531
|
+
opt[:sort_tags] ||= false
|
1532
|
+
|
1529
1533
|
cfg = @config['templates']['today']
|
1530
|
-
list_section({:section => opt[:section], :wrap_width => cfg['wrap_width'], :count => 0, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :today => true, :times => times, :output => output, :totals => opt[:totals]})
|
1534
|
+
list_section({:section => opt[:section], :wrap_width => cfg['wrap_width'], :count => 0, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :today => true, :times => times, :output => output, :totals => opt[:totals], :sort_tags => opt[:sort_tags]})
|
1531
1535
|
end
|
1532
1536
|
|
1533
1537
|
##
|
@@ -1541,13 +1545,14 @@ EOTEMPLATE
|
|
1541
1545
|
##
|
1542
1546
|
def list_date(dates,section,times=nil,output=nil,opt={})
|
1543
1547
|
opt[:totals] ||= false
|
1548
|
+
opt[:sort_tags] ||= false
|
1544
1549
|
section = guess_section(section)
|
1545
1550
|
# :date_filter expects an array with start and end date
|
1546
1551
|
if dates.class == String
|
1547
1552
|
dates = [dates, dates]
|
1548
1553
|
end
|
1549
1554
|
|
1550
|
-
list_section({:section => section, :count => 0, :order => "asc", :date_filter => dates, :times => times, :output => output, :totals => opt[:totals] })
|
1555
|
+
list_section({:section => section, :count => 0, :order => "asc", :date_filter => dates, :times => times, :output => output, :totals => opt[:totals], :sort_tags => opt[:sort_tags] })
|
1551
1556
|
end
|
1552
1557
|
|
1553
1558
|
##
|
@@ -1560,8 +1565,9 @@ EOTEMPLATE
|
|
1560
1565
|
##
|
1561
1566
|
def yesterday(section,times=nil,output=nil,opt={})
|
1562
1567
|
opt[:totals] ||= false
|
1568
|
+
opt[:sort_tags] ||= false
|
1563
1569
|
section = guess_section(section)
|
1564
|
-
list_section({:section => section, :count => 0, :order => "asc", :yesterday => true, :times => times, :output => output, :totals => opt[:totals] })
|
1570
|
+
list_section({:section => section, :count => 0, :order => "asc", :yesterday => true, :times => times, :output => output, :totals => opt[:totals], :sort_tags => opt[:sort_tags] })
|
1565
1571
|
end
|
1566
1572
|
|
1567
1573
|
##
|
@@ -1574,10 +1580,12 @@ EOTEMPLATE
|
|
1574
1580
|
def recent(count=10,section=nil,opt={})
|
1575
1581
|
times = opt[:t] || true
|
1576
1582
|
opt[:totals] ||= false
|
1583
|
+
opt[:sort_tags] ||= false
|
1584
|
+
|
1577
1585
|
cfg = @config['templates']['recent']
|
1578
1586
|
section ||= @current_section
|
1579
1587
|
section = guess_section(section)
|
1580
|
-
list_section({:section => section, :wrap_width => cfg['wrap_width'], :count => count, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :times => times, :totals => opt[:totals] })
|
1588
|
+
list_section({:section => section, :wrap_width => cfg['wrap_width'], :count => count, :format => cfg['date_format'], :template => cfg['template'], :order => "asc", :times => times, :totals => opt[:totals], :sort_tags => opt[:sort_tags] })
|
1581
1589
|
end
|
1582
1590
|
|
1583
1591
|
##
|
@@ -1598,14 +1606,20 @@ EOTEMPLATE
|
|
1598
1606
|
##
|
1599
1607
|
## @param format (String) return format (html, json, or text)
|
1600
1608
|
##
|
1601
|
-
def tag_times(format="text")
|
1602
|
-
|
1609
|
+
def tag_times(format="text", sort_by_name = false)
|
1603
1610
|
return "" if @timers.empty?
|
1604
1611
|
|
1605
1612
|
max = @timers.keys.sort_by {|k| k.length }.reverse[0].length + 1
|
1606
1613
|
|
1607
1614
|
total = @timers.delete("All")
|
1608
1615
|
|
1616
|
+
tags_data = @timers.delete_if { |k,v| v == 0}
|
1617
|
+
if sort_by_name
|
1618
|
+
sorted_tags_data = tags_data.sort_by{|k,v| k }.reverse
|
1619
|
+
else
|
1620
|
+
sorted_tags_data = tags_data.sort_by{|k,v| v }
|
1621
|
+
end
|
1622
|
+
|
1609
1623
|
if format == "html"
|
1610
1624
|
output =<<EOS
|
1611
1625
|
<table>
|
@@ -1622,9 +1636,7 @@ EOTEMPLATE
|
|
1622
1636
|
</thead>
|
1623
1637
|
<tbody>
|
1624
1638
|
EOS
|
1625
|
-
|
1626
|
-
v
|
1627
|
-
}.reverse.each {|k,v|
|
1639
|
+
sorted_tags_data.reverse.each {|k,v|
|
1628
1640
|
output += "<tr><td style='text-align:left;'>#{k}</td><td style='text-align:left;'>#{"%02d:%02d:%02d" % fmt_time(v)}</td></tr>\n" if v > 0
|
1629
1641
|
}
|
1630
1642
|
tail =<<EOS
|
@@ -1643,7 +1655,7 @@ EOS
|
|
1643
1655
|
output + tail
|
1644
1656
|
elsif format == "json"
|
1645
1657
|
output = []
|
1646
|
-
|
1658
|
+
sorted_tags_data.reverse.each {|k,v|
|
1647
1659
|
output << {
|
1648
1660
|
'tag' => k,
|
1649
1661
|
'seconds' => v,
|
@@ -1653,7 +1665,7 @@ EOS
|
|
1653
1665
|
output
|
1654
1666
|
else
|
1655
1667
|
output = []
|
1656
|
-
|
1668
|
+
sorted_tags_data.reverse.each {|k,v|
|
1657
1669
|
spacer = ""
|
1658
1670
|
(max - k.length).times do
|
1659
1671
|
spacer += " "
|
@@ -1704,11 +1716,15 @@ EOS
|
|
1704
1716
|
regex = Regexp.new('@' + rx + '\b')
|
1705
1717
|
|
1706
1718
|
matches = text.scan(regex)
|
1707
|
-
|
1708
1719
|
matches.each {|m|
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1720
|
+
new_tag = r
|
1721
|
+
if m.kind_of?(Array)
|
1722
|
+
index = 1
|
1723
|
+
m.each {|v|
|
1724
|
+
new_tag = new_tag.gsub('\\' + index.to_s, v)
|
1725
|
+
index = index + 1
|
1726
|
+
}
|
1727
|
+
end
|
1712
1728
|
tail_tags.push(new_tag)
|
1713
1729
|
} if matches
|
1714
1730
|
end
|
@@ -1782,6 +1798,10 @@ EOS
|
|
1782
1798
|
if seconds.nil?
|
1783
1799
|
return [0, 0, 0]
|
1784
1800
|
end
|
1801
|
+
if seconds =~ /(\d+):(\d+):(\d+)/
|
1802
|
+
h, m, s = [$1, $2, $3]
|
1803
|
+
seconds = (h.to_i * 60 * 60) + (m.to_i * 60) + s.to_i
|
1804
|
+
end
|
1785
1805
|
minutes = (seconds / 60).to_i
|
1786
1806
|
hours = (minutes / 60).to_i
|
1787
1807
|
days = (hours / 24).to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|