doing 2.0.10 → 2.0.11

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: 3cc03da6b7d2ea778baf93cd1031b1663f071e1aaddf84efc15ffc21690fc157
4
- data.tar.gz: 1fecde44c95f32746406cbf2cafbdddea6d47db1696a0311437cd7dd928f3fef
3
+ metadata.gz: fd5337fb3832570e16b9d3572b931c8484f3fe84547aa2ba5db15a4a0a622713
4
+ data.tar.gz: e9df16fbd231aeba99a1e4976e7e0f96908f7f1bb0e16e385722db1e6de79548
5
5
  SHA512:
6
- metadata.gz: '095d859e021692c9cee5e9ab16b82b48c1c1619798db261e83a9c50375f9df52547390a817623ba1ec3173f502731b9bf208dc574333886742955864e7a21ba9'
7
- data.tar.gz: e0a350fb87a0c173181eb5ff4ca6ea8e2152d98a8f54cf9a70153e24b94990f058d8fd5937ae2f5f40a7826b85e9d98b84277d4dd02a98a99d996ba24d17ca31
6
+ metadata.gz: 7b30f84f92598bae30f83d476d3989c0fe9a3aff32a7a3e8472be85c235c89e4dfc29f65c3eb9f5cc99076e94d5a00fe93d6291ba00b8e73c823a28407349d07
7
+ data.tar.gz: fe71eb8ab551f9f7a240e49c474ce01abde51182300c9c22a18062b25803dffa427714ee22665f34a98947d1742e68a7c4694a92eefddfc82a274489679fa21f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 2.0.11
2
+
3
+ #### NEW
4
+
5
+ - Append `/r` to tag transforms to replace original tag
6
+
7
+ #### FIXED
8
+
9
+ - Autotag tag transform fixes
10
+
1
11
  ### 2.0.10
2
12
 
3
13
  #### NEW
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doing (2.0.10)
4
+ doing (2.0.11)
5
5
  amatch (~> 0.4, >= 0.4.0)
6
6
  chronic (~> 0.10, >= 0.10.2)
7
7
  deep_merge (~> 1.2, >= 1.2.1)
data/README.md CHANGED
@@ -6,7 +6,7 @@ _If you're one of the rare people like me who find this useful, feel free to [bu
6
6
 
7
7
  <!--README-->
8
8
 
9
- The current version of `doing` is <!--VER-->2.0.9<!--END VER-->.
9
+ The current version of `doing` is <!--VER-->2.0.10<!--END VER-->.
10
10
 
11
11
  Find all of the documentation in the [doing wiki](https://github.com/ttscoff/doing/wiki).
12
12
 
data/bin/doing CHANGED
@@ -1252,6 +1252,7 @@ command :tag do |c|
1252
1252
  count = options[:count].to_i
1253
1253
  end
1254
1254
 
1255
+ options[:case] ||= :smart
1255
1256
  options[:case] = options[:case].normalize_case
1256
1257
 
1257
1258
  if options[:search]
data/doing.rdoc CHANGED
@@ -5,7 +5,7 @@ record of what you've been doing, complete with tag-based time tracking. The
5
5
  command line tool allows you to add entries, annotate with tags and notes, and
6
6
  view your entries with myriad options, with a focus on a "natural" language syntax.
7
7
 
8
- v2.0.10
8
+ v2.0.11
9
9
 
10
10
  === Global Options
11
11
  === --config_file arg
data/lib/doing/array.rb CHANGED
@@ -4,5 +4,18 @@ module Doing
4
4
  ##
5
5
  ## Array helpers
6
6
  ##
7
- class ::Array end
7
+ class ::Array
8
+ def to_tags
9
+ map { |t| t.sub(/^@?/, '@') }
10
+ end
11
+
12
+ def highlight_tags(color = 'cyan')
13
+ tag_color = Doing::Color.send(color)
14
+ to_tags.map { |t| "#{tag_color}#{t}" }
15
+ end
16
+
17
+ def log_tags
18
+ highlight_tags.join(', ')
19
+ end
20
+ end
8
21
  end
@@ -19,16 +19,17 @@ module Doing
19
19
  }.freeze
20
20
 
21
21
  COUNT_KEYS = %i[
22
- added_tags
23
- removed_tags
24
22
  added
25
- updated
26
- deleted
27
- completed
23
+ added_tags
28
24
  archived
29
- moved
25
+ autotag
26
+ completed
30
27
  completed_archived
28
+ deleted
29
+ moved
30
+ removed_tags
31
31
  skipped
32
+ updated
32
33
  ].freeze
33
34
 
34
35
  #
@@ -242,6 +243,8 @@ module Doing
242
243
 
243
244
  def format_counter(key, data)
244
245
  case key
246
+ when :autotag
247
+ ['Autotag:', data[:message] || 'autotagged %count %items']
245
248
  when :added_tags
246
249
  ['Tagged:', data[:message] || 'added %tags to %count %items']
247
250
  when :removed_tags
data/lib/doing/string.rb CHANGED
@@ -279,7 +279,7 @@ module Doing
279
279
 
280
280
  def add_tags(tags, remove: false)
281
281
  title = self.dup
282
- tags = tags.to_tags if tags.is_a?(String)
282
+ tags = tags.to_tags
283
283
  tags.each { |tag| title.tag!(tag, remove: remove) }
284
284
  title
285
285
  end
@@ -353,7 +353,7 @@ module Doing
353
353
 
354
354
  def dedup_tags
355
355
  title = dup
356
- tags = title.scan(/(?<=^| )(@(\S+?)(\([^)]+\))?)(?= |$)/).uniq
356
+ tags = title.scan(/(?<=\A| )(@(\S+?)(\([^)]+\))?)(?= |\Z)/).uniq
357
357
  tags.each do |tag|
358
358
  found = false
359
359
  title.gsub!(/( |^)#{tag[1]}(\([^)]+\))?(?= |$)/) do |m|
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '2.0.10'
2
+ VERSION = '2.0.11'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -1868,68 +1868,90 @@ module Doing
1868
1868
 
1869
1869
  original = text.dup
1870
1870
 
1871
- current_tags = text.scan(/@\w+/)
1872
- whitelisted = []
1871
+ current_tags = text.scan(/@\w+/).map { |t| t.sub(/^@/, '') }
1872
+ tagged = {
1873
+ whitelisted: [],
1874
+ synonyms: [],
1875
+ transformed: [],
1876
+ replaced: []
1877
+ }
1878
+
1873
1879
  @config['autotag']['whitelist'].each do |tag|
1874
1880
  next if text =~ /@#{tag}\b/i
1875
1881
 
1876
- text.sub!(/(?<!@)\b(#{tag.strip})\b/i) do |m|
1877
- m.downcase! if tag =~ /[a-z]/
1878
- whitelisted.push("@#{m}")
1882
+ text.sub!(/(?<= |\A)(#{tag.strip})(?= |\Z)/i) do |m|
1883
+ m.downcase! unless tag =~ /[A-Z]/
1884
+ tagged[:whitelisted].push(m)
1879
1885
  "@#{m}"
1880
1886
  end
1881
1887
  end
1882
- tail_tags = []
1888
+
1883
1889
  @config['autotag']['synonyms'].each do |tag, v|
1884
1890
  v.each do |word|
1885
1891
  next unless text =~ /\b#{word}\b/i
1886
1892
 
1887
- tail_tags.push(tag) unless current_tags.include?("@#{tag}") || whitelisted.include?("@#{tag}")
1893
+ unless current_tags.include?(tag) || tagged[:whitelisted].include?(tag)
1894
+ tagged[:synonyms].push(tag)
1895
+ tagged[:synonyms] = tagged[:synonyms].uniq
1896
+ end
1888
1897
  end
1889
1898
  end
1899
+
1890
1900
  if @config['autotag'].key? 'transform'
1891
1901
  @config['autotag']['transform'].each do |tag|
1892
1902
  next unless tag =~ /\S+:\S+/
1893
1903
 
1894
1904
  rx, r = tag.split(/:/)
1905
+ flag_rx = %r{/([r]+)$}
1906
+ if r =~ flag_rx
1907
+ flags = r.match(flag_rx)[1].split(//)
1908
+ r.sub!(flag_rx, '')
1909
+ end
1895
1910
  r.gsub!(/\$/, '\\')
1896
- rx.sub!(/^@/, '')
1897
- regex = Regexp.new('@' + rx + '\b')
1911
+ rx.sub!(/^@?/, '@')
1912
+ regex = Regexp.new("(?<= |\\A)#{rx}(?= |\\Z)")
1898
1913
 
1899
- matches = text.scan(regex)
1900
- next unless matches
1901
-
1902
- matches.each do |m|
1914
+ text.sub!(regex) do
1915
+ m = Regexp.last_match
1903
1916
  new_tag = r
1904
- if m.is_a?(Array)
1905
- index = 1
1906
- m.each do |v|
1907
- new_tag.gsub!('\\' + index.to_s, v)
1908
- index += 1
1909
- end
1917
+
1918
+ m.to_a.slice(1, m.length - 1).each_with_index do |v, idx|
1919
+ new_tag.gsub!("\\#{idx + 1}", v)
1920
+ end
1921
+ # Replace original tag if /r
1922
+ if flags&.include?('r')
1923
+ tagged[:replaced].concat(new_tag.split(/ /).map { |t| t.sub(/^@/, '') })
1924
+ new_tag.split(/ /).map { |t| t.sub(/^@?/, '@') }.join(' ')
1925
+ else
1926
+ tagged[:transformed].concat(new_tag.split(/ /).map { |t| t.sub(/^@/, '') })
1927
+ tagged[:transformed] = tagged[:transformed].uniq
1928
+ m[0]
1910
1929
  end
1911
- tail_tags.push(new_tag)
1912
1930
  end
1913
1931
  end
1914
1932
  end
1915
1933
 
1916
- logger.debug('Autotag:', "whitelisted tags: #{whitelisted.join(', ')}") unless whitelisted.empty?
1917
- new_tags = whitelisted
1918
- unless tail_tags.empty?
1919
- tags = tail_tags.uniq.map { |t| "@#{t}".cyan }.join(' ')
1920
- logger.debug('Autotag:', "synonym tags: #{tags}")
1921
- tags_a = tail_tags.map { |t| "@#{t}" }
1922
- text.add_tags!(tags_a.join(' '))
1923
- new_tags.concat(tags_a)
1924
- end
1925
1934
 
1926
- unless text == original
1927
- logger.info('Autotag:', "added #{new_tags.join(', ')} to \"#{text}\"")
1935
+ logger.debug('Autotag:', "whitelisted tags: #{tagged[:whitelisted].log_tags}") unless tagged[:whitelisted].empty?
1936
+ logger.debug('Autotag:', "synonyms: #{tagged[:synonyms].log_tags}") unless tagged[:synonyms].empty?
1937
+ logger.debug('Autotag:', "transforms: #{tagged[:transformed].log_tags}") unless tagged[:transformed].empty?
1938
+ logger.debug('Autotag:', "transform replaced: #{tagged[:replaced].log_tags}") unless tagged[:replaced].empty?
1939
+
1940
+ tail_tags = tagged[:synonyms].concat(tagged[:transformed])
1941
+ tail_tags.sort!
1942
+ tail_tags.uniq!
1943
+
1944
+ text.add_tags!(tail_tags) unless tail_tags.empty?
1945
+
1946
+ if text == original
1947
+ logger.debug('Autotag:', "no change to \"#{text}\"")
1928
1948
  else
1929
- logger.debug('Skipped:', "no change to \"#{text}\"")
1949
+ new_tags = tagged[:whitelisted].concat(tail_tags).concat(tagged[:replaced])
1950
+ logger.debug('Autotag:', "added #{new_tags.log_tags} to \"#{text}\"")
1951
+ logger.count(:autotag, level: :info, count: 1, message: 'autotag updated %count %items')
1930
1952
  end
1931
1953
 
1932
- text
1954
+ text.dedup_tags
1933
1955
  end
1934
1956
 
1935
1957
  ##
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: 2.0.10
4
+ version: 2.0.11
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-19 00:00:00.000000000 Z
11
+ date: 2021-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml