doing 1.0.33 → 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: 381d875c7e4b8f3782e081c3a4bd6f0551c420b02d7dad20be8e2217b2dc4d59
4
- data.tar.gz: dae9efcc7453831ff1c33e1d03a61986fed1540d33b0eb3a9990522b5e4452f1
3
+ metadata.gz: 9638a33587192a9a5146ace1e3d8e6937efb34922b7b93c71ba088880f136ed4
4
+ data.tar.gz: 07bc825013ac19e6b4a1b4ef3103ac0f04ce186575ec65c724e55664b74087d6
5
5
  SHA512:
6
- metadata.gz: 6420c68b41773a9d3c54a0185c26fd972df2f69ad11cd17bd30d5c83789ed5b405172170a30e8f483c6cd164ac13e6c851a583dfbf0e3ec9bfd273606849ca71
7
- data.tar.gz: eb0f1d56e64e731f341879840ca592d3c55402e3e6f2467567cb7f513811a172ac3d605f3358c75f75d0ed5d28126a50ffdfba1165510b5073745ccdf8c1948d
6
+ metadata.gz: '087fa6df46f96bb25ddb7904505e10669a5bb28104e0652b890a497067ed8255ec2d6ce9e3e54018372efdf86b7272bd4a81c09b1a93b99e8f90e09ed86af381'
7
+ data.tar.gz: e395fd115d20f77cd522d086fa19b1bde92a51ea7785cf3f8b16ae39004f490ebc918be798d70e3ce133effcc15948c774493ddf84e541fd0b3a3e83271e0d90
data/README.md CHANGED
@@ -464,6 +464,16 @@ To add autotagging, include a section like this in your `~/.doingrc` file:
464
464
  - posting
465
465
  - publishing
466
466
 
467
+ ###### Tag transformation
468
+
469
+ You can include a `transform` section in the autotag config which contains pairs of regular expressions and replacement patterns separated by a colon. These will be used to look at existing tags in the text and generate additional tags from them. For example:
470
+
471
+ autotag:
472
+ transform:
473
+ - (\w+)-\d+:$1
474
+
475
+ This creates a search pattern looking for a string of word characters followed by a hyphen and one or more digits, e.g. `@projecttag-12`. Do not include the @ symbol in the pattern. The replacement (`$1`) indicates that the first matched group (in parenthesis) should be used to generate the new tag, resulting in `@projecttag` being added to the entry.
476
+
467
477
  ##### Annotating
468
478
 
469
479
  `note` lets you append a note to the last entry. You can specify a section to grab the last entry from with `-s section_name`. `-e` will open your `$EDITOR` for typing the note, but you can also just include it on the command line after any flags. You can also pipe a note in on STDIN (`echo "fun stuff"|doing note`). If you don't use the `-r` switch, new notes will be appended to the existing notes, and using the `-e` switch will let you edit and add to an existing note. The `-r` switch will remove/replace a note; if there's new note text passed when using the `-r` switch, it will replace any existing note. If the `-r` switch is used alone, any existing note will be removed.
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.33'
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']
@@ -581,6 +582,8 @@ class WWID
581
582
  opt[:back] ||= Time.now
582
583
  opt[:timed] ||= false
583
584
 
585
+ opt[:note] = [opt[:note]] if opt[:note].class == String
586
+
584
587
  title = [title.strip.cap_first]
585
588
  title = title.join(' ')
586
589
 
@@ -602,7 +605,7 @@ class WWID
602
605
  title.gsub!(/ +/,' ')
603
606
  entry = {'title' => title.strip, 'date' => opt[:back]}
604
607
  unless opt[:note].join('').strip == ''
605
- entry['note'] = opt[:note].map {|n| n.gsub(/ *$/,'')}
608
+ entry['note'] = opt[:note].map {|n| n.chomp}
606
609
  end
607
610
  items = @content[section]['items']
608
611
  if opt[:timed]
@@ -995,6 +998,7 @@ class WWID
995
998
  opt[:tags_color] ||= false
996
999
  opt[:times] ||= false
997
1000
  opt[:totals] ||= false
1001
+ opt[:sort_tags] ||= false
998
1002
  opt[:search] ||= false
999
1003
  opt[:only_timed] ||= false
1000
1004
  opt[:date_filter] ||= []
@@ -1178,7 +1182,7 @@ class WWID
1178
1182
  out = {
1179
1183
  'section' => section,
1180
1184
  'items' => items_out,
1181
- 'timers' => tag_times("json")
1185
+ 'timers' => tag_times("json", opt[:sort_tags])
1182
1186
  }.to_json
1183
1187
  elsif opt[:output] == "timeline"
1184
1188
  template =<<EOTEMPLATE
@@ -1261,7 +1265,7 @@ EOTEMPLATE
1261
1265
  style = css_template
1262
1266
  end
1263
1267
 
1264
- totals = opt[:totals] ? tag_times("html") : ""
1268
+ totals = opt[:totals] ? tag_times("html", opt[:sort_tags]) : ""
1265
1269
  engine = Haml::Engine.new(template)
1266
1270
  puts engine.render(Object.new, { :@items => items_out, :@page_title => page_title, :@style => style, :@totals => totals })
1267
1271
  else
@@ -1351,7 +1355,7 @@ EOTEMPLATE
1351
1355
 
1352
1356
  out += output + "\n"
1353
1357
  }
1354
- out += tag_times if opt[:totals]
1358
+ out += tag_times("text", opt[:sort_tags]) if opt[:totals]
1355
1359
  end
1356
1360
  return out
1357
1361
  end
@@ -1596,7 +1600,7 @@ EOTEMPLATE
1596
1600
  ##
1597
1601
  ## @param format (String) return format (html, json, or text)
1598
1602
  ##
1599
- def tag_times(format="text")
1603
+ def tag_times(format="text", sort_by_name = false)
1600
1604
 
1601
1605
  return "" if @timers.empty?
1602
1606
 
@@ -1604,6 +1608,13 @@ EOTEMPLATE
1604
1608
 
1605
1609
  total = @timers.delete("All")
1606
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
+
1607
1618
  if format == "html"
1608
1619
  output =<<EOS
1609
1620
  <table>
@@ -1620,9 +1631,7 @@ EOTEMPLATE
1620
1631
  </thead>
1621
1632
  <tbody>
1622
1633
  EOS
1623
- @timers.sort_by {|k,v|
1624
- v
1625
- }.reverse.each {|k,v|
1634
+ sorted_tags_data.reverse.each {|k,v|
1626
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
1627
1636
  }
1628
1637
  tail =<<EOS
@@ -1641,7 +1650,7 @@ EOS
1641
1650
  output + tail
1642
1651
  elsif format == "json"
1643
1652
  output = []
1644
- @timers.delete_if { |k,v| v == 0}.sort_by{|k,v| v }.reverse.each {|k,v|
1653
+ sorted_tags_data.reverse.each {|k,v|
1645
1654
  output << {
1646
1655
  'tag' => k,
1647
1656
  'seconds' => v,
@@ -1651,7 +1660,7 @@ EOS
1651
1660
  output
1652
1661
  else
1653
1662
  output = []
1654
- @timers.delete_if { |k,v| v == 0}.sort_by{|k,v| v }.reverse.each {|k,v|
1663
+ sorted_tags_data.reverse.each {|k,v|
1655
1664
  spacer = ""
1656
1665
  (max - k.length).times do
1657
1666
  spacer += " "
@@ -1693,6 +1702,25 @@ EOS
1693
1702
  end
1694
1703
  }
1695
1704
  }
1705
+ if @config['autotag'].key? 'transform'
1706
+ @config['autotag']['transform'].each {|tag|
1707
+ if tag =~ /\S+:\S+/
1708
+ rx, r = tag.split(/:/)
1709
+ r.gsub!(/\$/,'\\')
1710
+ rx.sub!(/^@/,'')
1711
+ regex = Regexp.new('@' + rx + '\b')
1712
+
1713
+ matches = text.scan(regex)
1714
+
1715
+ matches.each {|m|
1716
+ puts rx,r
1717
+ new_tag = m[0].sub(Regexp.new(rx), r)
1718
+ puts new_tag
1719
+ tail_tags.push(new_tag)
1720
+ } if matches
1721
+ end
1722
+ }
1723
+ end
1696
1724
  if whitelisted.length > 0
1697
1725
  @results.push("Whitelisted tags: #{whitelisted.join(', ')}")
1698
1726
  end
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.33
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: 2020-07-29 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
@@ -90,22 +90,22 @@ dependencies:
90
90
  name: haml
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: 5.1.2
96
93
  - - "~>"
97
94
  - !ruby/object:Gem::Version
98
- version: 5.1.2
95
+ version: 5.0.0
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 5.0.0
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: 5.1.2
106
103
  - - "~>"
107
104
  - !ruby/object:Gem::Version
108
- version: 5.1.2
105
+ version: 5.0.0
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 5.0.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: chronic
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -146,26 +146,6 @@ dependencies:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: 1.2.1
149
- - !ruby/object:Gem::Dependency
150
- name: json
151
- requirement: !ruby/object:Gem::Requirement
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- version: 1.8.1
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: 2.3.1
159
- type: :runtime
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: 1.8.1
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: 2.3.1
169
149
  description: A tool for managing a TaskPaper-like file of recent activites. Perfect
170
150
  for the late-night hacker on too much caffeine to remember what they accomplished
171
151
  at 2 in the morning.
@@ -210,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
190
  - !ruby/object:Gem::Version
211
191
  version: '0'
212
192
  requirements: []
213
- rubygems_version: 3.0.8
193
+ rubygems_version: 3.2.16
214
194
  signing_key:
215
195
  specification_version: 4
216
196
  summary: A command line tool for managing What Was I Doing reminders