doing 1.0.37 → 1.0.38

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
  SHA256:
3
- metadata.gz: d00d66a9e4fa16bdc40697f2fa7b42685d87e64c757d6f5e0096dd8a07af4c37
4
- data.tar.gz: d7624aefddb7eb42b1a86c97f140e0881cbf2d8a41b34109d1f2f3a31b82c9b3
3
+ metadata.gz: 9638a33587192a9a5146ace1e3d8e6937efb34922b7b93c71ba088880f136ed4
4
+ data.tar.gz: 07bc825013ac19e6b4a1b4ef3103ac0f04ce186575ec65c724e55664b74087d6
5
5
  SHA512:
6
- metadata.gz: a50d44f0db2756591fc7b7e276dd521a27f13fc893c91928386a504ffc874657bb3913cad123c59e5c86fbb858812aa91914082bd183652857a43d0455ee3047
7
- data.tar.gz: bf9684307fbdf99a5f6846ae09ecc3c574eecba8be0d609ce0ce7f00c838470d39b434e065725c951a140d1be921910b61376c0793319be184997daa0d4b98e3
6
+ metadata.gz: '087fa6df46f96bb25ddb7904505e10669a5bb28104e0652b890a497067ed8255ec2d6ce9e3e54018372efdf86b7272bd4a81c09b1a93b99e8f90e09ed86af381'
7
+ data.tar.gz: e395fd115d20f77cd522d086fa19b1bde92a51ea7785cf3f8b16ae39004f490ebc918be798d70e3ce133effcc15948c774493ddf84e541fd0b3a3e83271e0d90
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
- 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], :highlight => true, :only_timed => options[:only_timed]})
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
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.37'
2
+ VERSION = '1.0.38'
3
3
  end
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] ||= []
@@ -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
@@ -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
@@ -1598,7 +1600,7 @@ EOTEMPLATE
1598
1600
  ##
1599
1601
  ## @param format (String) return format (html, json, or text)
1600
1602
  ##
1601
- def tag_times(format="text")
1603
+ def tag_times(format="text", sort_by_name = false)
1602
1604
 
1603
1605
  return "" if @timers.empty?
1604
1606
 
@@ -1606,6 +1608,13 @@ EOTEMPLATE
1606
1608
 
1607
1609
  total = @timers.delete("All")
1608
1610
 
1611
+ tags_data = @timers.delete_if { |k,v| v == 0}
1612
+ if sort_by_name
1613
+ sorted_tags_data = tags_data.sort_by{|k,v| k }.reverse
1614
+ else
1615
+ sorted_tags_data = tags_data.sort_by{|k,v| v }
1616
+ end
1617
+
1609
1618
  if format == "html"
1610
1619
  output =<<EOS
1611
1620
  <table>
@@ -1622,9 +1631,7 @@ EOTEMPLATE
1622
1631
  </thead>
1623
1632
  <tbody>
1624
1633
  EOS
1625
- @timers.sort_by {|k,v|
1626
- v
1627
- }.reverse.each {|k,v|
1634
+ sorted_tags_data.reverse.each {|k,v|
1628
1635
  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
1636
  }
1630
1637
  tail =<<EOS
@@ -1643,7 +1650,7 @@ EOS
1643
1650
  output + tail
1644
1651
  elsif format == "json"
1645
1652
  output = []
1646
- @timers.delete_if { |k,v| v == 0}.sort_by{|k,v| v }.reverse.each {|k,v|
1653
+ sorted_tags_data.reverse.each {|k,v|
1647
1654
  output << {
1648
1655
  'tag' => k,
1649
1656
  'seconds' => v,
@@ -1653,7 +1660,7 @@ EOS
1653
1660
  output
1654
1661
  else
1655
1662
  output = []
1656
- @timers.delete_if { |k,v| v == 0}.sort_by{|k,v| v }.reverse.each {|k,v|
1663
+ sorted_tags_data.reverse.each {|k,v|
1657
1664
  spacer = ""
1658
1665
  (max - k.length).times do
1659
1666
  spacer += " "
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.37
4
+ version: 1.0.38
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-05-14 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake