doing 1.0.34 → 1.0.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc07b5fb8388f698785ffa70f0c12c208cd57dcc1716d07af252d93a7d427e09
4
- data.tar.gz: 168816a713de9f7a4379fb094b4ec16b7ad8f301663dca5e950b552934488295
3
+ metadata.gz: 62aab464d54aaaa9afbe992bc0e7d466d79ee24b9bdc5127ae8b45cfb4895795
4
+ data.tar.gz: '048bc4ec14d0df9c0c44940b9bd0cfc25c8167ea78db3e64526f8fdbad119588'
5
5
  SHA512:
6
- metadata.gz: e840428a46112abbec42ba184627935b73e7d2814362500d9d1410d309eec940f68c14a60a9aa0ee947088fc5f7ee5fd97892f3760a8a991e0084e763a46dfcc
7
- data.tar.gz: e677b2f9434ac46b538e513038f0a16ef6d775321de5079dab9bff66f9065480bb5db15f0af4dc9ad01ad488d0e05ac8c6b896a95ab7f3988efc4dbc07594c9f
6
+ metadata.gz: 5500256aa08f6a75a83118a6c4521453f1900a67d69bc57d31a753c4f064c5d9597675152508f5770eb2fbe036b11c7bbe506376cc1da48c6b9919169cb2c849
7
+ data.tar.gz: 51607b30fd337af37e21bea90d5b5e91c3fdf6d15c4909fce3f35836337d5f791504644afb5d9505e376bbd53e7b5e0ae386da2695d877bb3fac455c3cf9778b
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.34'
2
+ VERSION = '1.0.39'
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 += " "
@@ -1695,6 +1702,29 @@ EOS
1695
1702
  end
1696
1703
  }
1697
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
+ matches.each {|m|
1715
+ new_tag = r
1716
+ if m.kind_of?(Array)
1717
+ index = 1
1718
+ m.each {|v|
1719
+ new_tag = new_tag.sub('\\' + index.to_s, v)
1720
+ index = index + 1
1721
+ }
1722
+ end
1723
+ tail_tags.push(new_tag)
1724
+ } if matches
1725
+ end
1726
+ }
1727
+ end
1698
1728
  if whitelisted.length > 0
1699
1729
  @results.push("Whitelisted tags: #{whitelisted.join(', ')}")
1700
1730
  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.34
4
+ version: 1.0.39
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-09-15 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
@@ -92,20 +92,20 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 5.1.2
95
+ version: 5.0.0
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: 5.1.2
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
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: 5.1.2
105
+ version: 5.0.0
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 5.1.2
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: 2.3.1
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: 1.8.1
159
- type: :runtime
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: 2.3.1
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- version: 1.8.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.1.4
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