doing 2.1.26 → 2.1.30

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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +15 -20
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/CHANGELOG.md +52 -0
  6. data/Dockerfile +5 -5
  7. data/Dockerfile-2.6 +5 -5
  8. data/Dockerfile-2.7 +5 -4
  9. data/Dockerfile-3.0 +5 -4
  10. data/Gemfile.lock +2 -1
  11. data/README.md +1 -1
  12. data/Rakefile +2 -3
  13. data/bin/commands/add_section.rb +2 -0
  14. data/bin/commands/again.rb +23 -65
  15. data/bin/commands/archive.rb +20 -61
  16. data/bin/commands/cancel.rb +27 -69
  17. data/bin/commands/changes.rb +53 -12
  18. data/bin/commands/colors.rb +4 -2
  19. data/bin/commands/commands.rb +4 -2
  20. data/bin/commands/commands_accepting.rb +62 -11
  21. data/bin/commands/completion.rb +10 -7
  22. data/bin/commands/config.rb +8 -8
  23. data/bin/commands/done.rb +3 -17
  24. data/bin/commands/finish.rb +7 -30
  25. data/bin/commands/flag.rb +15 -51
  26. data/bin/commands/grep.rb +12 -28
  27. data/bin/commands/import.rb +3 -33
  28. data/bin/commands/last.rb +3 -36
  29. data/bin/commands/meanwhile.rb +3 -13
  30. data/bin/commands/note.rb +13 -52
  31. data/bin/commands/now.rb +15 -21
  32. data/bin/commands/on.rb +3 -4
  33. data/bin/commands/open.rb +3 -3
  34. data/bin/commands/recent.rb +3 -4
  35. data/bin/commands/redo.rb +6 -2
  36. data/bin/commands/reset.rb +19 -52
  37. data/bin/commands/rotate.rb +5 -36
  38. data/bin/commands/select.rb +23 -41
  39. data/bin/commands/show.rb +28 -74
  40. data/bin/commands/since.rb +3 -4
  41. data/bin/commands/tag.rb +4 -34
  42. data/bin/commands/tags.rb +5 -32
  43. data/bin/commands/today.rb +3 -4
  44. data/bin/commands/view.rb +36 -73
  45. data/bin/commands/yesterday.rb +4 -5
  46. data/bin/doing +150 -13
  47. data/docs/doc/Array.html +3 -502
  48. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  49. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  50. data/docs/doc/BooleanTermParser/Query.html +1 -1
  51. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  52. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  53. data/docs/doc/BooleanTermParser.html +1 -1
  54. data/docs/doc/Doing/Color.html +62 -56
  55. data/docs/doc/Doing/Completion.html +1 -1
  56. data/docs/doc/Doing/Configuration.html +35 -1
  57. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  58. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  59. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  60. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  61. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  62. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  63. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  64. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  65. data/docs/doc/Doing/Errors.html +1 -1
  66. data/docs/doc/Doing/Hooks.html +1 -1
  67. data/docs/doc/Doing/Item.html +1 -1
  68. data/docs/doc/Doing/Items.html +2 -2
  69. data/docs/doc/Doing/LogAdapter.html +1 -1
  70. data/docs/doc/Doing/Note.html +2 -2
  71. data/docs/doc/Doing/Pager.html +1 -1
  72. data/docs/doc/Doing/Plugins.html +1 -1
  73. data/docs/doc/Doing/Prompt.html +1 -1
  74. data/docs/doc/Doing/Section.html +1 -1
  75. data/docs/doc/Doing/TemplateString.html +2 -2
  76. data/docs/doc/Doing/Types.html +41 -1
  77. data/docs/doc/Doing/Util/Backup.html +1 -1
  78. data/docs/doc/Doing/Util.html +1 -1
  79. data/docs/doc/Doing/WWID.html +10 -10
  80. data/docs/doc/Doing.html +3 -3
  81. data/docs/doc/FalseClass.html +35 -1
  82. data/docs/doc/GLI/Commands/Help.html +1 -1
  83. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  84. data/docs/doc/GLI/Commands.html +1 -1
  85. data/docs/doc/GLI.html +1 -1
  86. data/docs/doc/Hash.html +1 -1
  87. data/docs/doc/Object.html +1 -1
  88. data/docs/doc/PhraseParser/Operator.html +1 -1
  89. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  90. data/docs/doc/PhraseParser/Query.html +1 -1
  91. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  92. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  93. data/docs/doc/PhraseParser/TermClause.html +1 -1
  94. data/docs/doc/PhraseParser.html +1 -1
  95. data/docs/doc/Status.html +1 -1
  96. data/docs/doc/String.html +287 -3155
  97. data/docs/doc/Symbol.html +40 -6
  98. data/docs/doc/Time.html +1 -1
  99. data/docs/doc/TrueClass.html +35 -1
  100. data/docs/doc/_index.html +5 -10
  101. data/docs/doc/class_list.html +1 -1
  102. data/docs/doc/file.README.html +2 -2
  103. data/docs/doc/index.html +2 -2
  104. data/docs/doc/method_list.html +278 -678
  105. data/docs/doc/top-level-namespace.html +2 -2
  106. data/doing.gemspec +1 -0
  107. data/doing.rdoc +297 -206
  108. data/lib/completion/_doing.zsh +32 -32
  109. data/lib/completion/doing.bash +30 -30
  110. data/lib/completion/doing.fish +87 -77
  111. data/lib/doing/array/array.rb +4 -0
  112. data/lib/doing/array/nested_hash.rb +17 -0
  113. data/lib/doing/{array.rb → array/tags.rb} +7 -25
  114. data/lib/doing/changelog/change.rb +26 -11
  115. data/lib/doing/changelog/changes.rb +37 -8
  116. data/lib/doing/changelog/version.rb +11 -3
  117. data/lib/doing/{array_chronify.rb → chronify/array.rb} +0 -0
  118. data/lib/doing/chronify/chronify.rb +5 -0
  119. data/lib/doing/{numeric_chronify.rb → chronify/numeric.rb} +0 -0
  120. data/lib/doing/{string_chronify.rb → chronify/string.rb} +0 -0
  121. data/lib/doing/colors.rb +115 -54
  122. data/lib/doing/completion/zsh_completion.rb +5 -0
  123. data/lib/doing/configuration.rb +9 -5
  124. data/lib/doing/good.rb +8 -0
  125. data/lib/doing/help_monkey_patch.rb +6 -5
  126. data/lib/doing/item.rb +5 -5
  127. data/lib/doing/items.rb +2 -2
  128. data/lib/doing/log_adapter.rb +35 -2
  129. data/lib/doing/normalize.rb +188 -0
  130. data/lib/doing/plugins/export/dayone_export.rb +1 -1
  131. data/lib/doing/plugins/export/html_export.rb +1 -1
  132. data/lib/doing/plugins/export/json_export.rb +1 -1
  133. data/lib/doing/plugins/export/markdown_export.rb +1 -1
  134. data/lib/doing/plugins/export/template_export.rb +3 -1
  135. data/lib/doing/prompt.rb +1 -3
  136. data/lib/doing/section.rb +1 -1
  137. data/lib/doing/string/highlight.rb +95 -0
  138. data/lib/doing/string/query.rb +129 -0
  139. data/lib/doing/string/string.rb +12 -0
  140. data/lib/doing/string/tags.rb +164 -0
  141. data/lib/doing/string/transform.rb +168 -0
  142. data/lib/doing/string/truncate.rb +75 -0
  143. data/lib/doing/string/url.rb +82 -0
  144. data/lib/doing/template_string.rb +0 -22
  145. data/lib/doing/types.rb +8 -0
  146. data/lib/doing/util.rb +13 -9
  147. data/lib/doing/version.rb +1 -1
  148. data/lib/doing/wwid.rb +54 -36
  149. data/lib/doing.rb +5 -6
  150. data/lib/examples/plugins/wiki_export/wiki_export.rb +1 -1
  151. data/lib/helpers/threaded_tests.rb +15 -2
  152. data/scripts/deploy.rb +107 -0
  153. data/scripts/runtests.sh +4 -0
  154. metadata +39 -8
  155. data/lib/doing/string.rb +0 -765
  156. data/lib/doing/symbol.rb +0 -28
@@ -4,21 +4,49 @@ module Doing
4
4
  # A collection of Changes
5
5
  class Changes
6
6
  attr_reader :changes
7
+ attr_writer :changes_only
7
8
 
8
- def initialize(lookup: nil, search: nil)
9
+ def initialize(lookup: nil, search: nil, changes: false, sort: :desc)
10
+ @changes_only = changes
9
11
  changelog = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'CHANGELOG.md'))
10
12
  raise 'Error locating changelog' unless File.exist?(changelog)
11
13
 
12
14
  @content = IO.read(changelog)
13
15
  parse_changes(lookup, search)
16
+
17
+ @changes.reverse! if sort == :asc
14
18
  end
15
19
 
16
20
  def latest
17
- @changes[0].to_s.force_encoding('utf-8')
21
+ if @changes_only
22
+ @changes[0].changes_only.force_encoding('utf-8')
23
+ else
24
+ @changes[0].to_s.force_encoding('utf-8')
25
+ end
26
+ end
27
+
28
+ def versions
29
+ @changes.select { |change| change.entries&.count > 0 }.map { |change| change.version }
30
+ end
31
+
32
+ def interactive
33
+ Doing::Prompt.choose_from(versions,
34
+ prompt: 'Select a version to see its changelog',
35
+ sorted: false,
36
+ fzf_args: [
37
+ %(--preview='doing changes --render -l {1}'),
38
+ '--disabled',
39
+ '--height=50',
40
+ '--preview-window="right,70%"'
41
+ ])
18
42
  end
19
43
 
20
44
  def to_s
21
- @changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
45
+ if @changes_only
46
+ @changes.map(&:changes_only).join().force_encoding('utf-8')
47
+ else
48
+ @changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
49
+ end
22
50
  end
23
51
 
24
52
  private
@@ -38,18 +66,19 @@ module Doing
38
66
  def lookup(lookup_version)
39
67
  range = []
40
68
 
41
- if lookup_version =~ /([\d.]+) *-+ *([\d.]+)/
69
+ if lookup_version =~ /([\d.]+) *(?:-|to)+ *([\d.]+)/
42
70
  m = Regexp.last_match
43
71
  lookup("> #{m[1]}")
44
72
  lookup("< #{m[2]}")
45
- elsif lookup_version.scan(/[<>]/).count > 1
46
- params = lookup_version.scan(/[<>] [\d.]+/)
73
+ elsif lookup_version.scan(/(?:<=?|prior|before|older|>=?|since|after|newer) *[0-9*?.]+/).count > 1
74
+ params = lookup_version.scan(/(?:<=?|prior|before|older|>=?|since|after|newer) *[0-9*?.]+/)
47
75
  params.each { |query| lookup(query) }
48
76
  else
77
+ inclusive = lookup_version =~ /=/ ? true : false
49
78
  comp = case lookup_version
50
79
  when /(<|prior|before|older)/
51
80
  :older
52
- when />|since|after|newer/
81
+ when /(>|since|after|newer)/
53
82
  :newer
54
83
  else
55
84
  :equal
@@ -57,7 +86,7 @@ module Doing
57
86
  version = Version.new(lookup_version)
58
87
 
59
88
  @changes.select! do |change|
60
- change.version.compare(version, comp)
89
+ change.version.compare(version, comp, inclusive: inclusive)
61
90
  end
62
91
  end
63
92
  end
@@ -37,7 +37,7 @@ module Doing
37
37
  end
38
38
 
39
39
 
40
- def compare(other, comp)
40
+ def compare(other, comp, inclusive: false)
41
41
  case comp
42
42
  when :older
43
43
  if @maj <= other.maj
@@ -46,7 +46,11 @@ module Doing
46
46
  elsif @maj == other.maj && (other.min.nil? || @min < other.min)
47
47
  true
48
48
  elsif @maj == other.maj && @min == other.min
49
- other.patch.nil? ? false : @patch < other.patch
49
+ if other.patch.nil?
50
+ false
51
+ else
52
+ inclusive ? @patch <= other.patch : @patch < other.patch
53
+ end
50
54
  else
51
55
  false
52
56
  end
@@ -60,7 +64,11 @@ module Doing
60
64
  elsif @maj == other.maj && (other.min.nil? || @min > other.min)
61
65
  true
62
66
  elsif @maj == other.maj && @min == other.min
63
- other.patch.nil? || @patch >= other.patch
67
+ if other.patch.nil?
68
+ false
69
+ else
70
+ inclusive ? @patch >= other.patch : @patch > other.patch
71
+ end
64
72
  else
65
73
  false
66
74
  end
File without changes
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'array'
4
+ require_relative 'numeric'
5
+ require_relative 'string'
data/lib/doing/colors.rb CHANGED
@@ -6,61 +6,67 @@ module Doing
6
6
  module Color
7
7
  # :stopdoc:
8
8
  ATTRIBUTES = [
9
- [:clear, 0], # String#clear is already used to empty string in Ruby 1.9
10
- [:reset, 0], # synonym for :clear
11
- [:bold, 1],
12
- [:dark, 2],
13
- [:italic, 3], # not widely implemented
14
- [:underline, 4],
15
- [:underscore, 4], # synonym for :underline
16
- [:blink, 5],
17
- [:rapid_blink, 6], # not widely implemented
18
- [:negative, 7], # no reverse because of String#reverse
19
- [:concealed, 8],
20
- [:strikethrough, 9], # not widely implemented
21
- [:black, 30],
22
- [:red, 31],
23
- [:green, 32],
24
- [:yellow, 33],
25
- [:blue, 34],
26
- [:magenta, 35],
27
- [:purple, 35],
28
- [:cyan, 36],
29
- [:white, 37],
30
- [:bgblack, 40],
31
- [:bgred, 41],
32
- [:bggreen, 42],
33
- [:bgyellow, 43],
34
- [:bgblue, 44],
35
- [:bgmagenta, 45],
36
- [:bgpurple, 45],
37
- [:bgcyan, 46],
38
- [:bgwhite, 47],
39
- [:boldblack, 90], # High intensity, aixterm (works in OS X)
40
- [:boldred, 91],
41
- [:boldgreen, 92],
42
- [:boldyellow, 93],
43
- [:boldblue, 94],
44
- [:boldmagenta, 95],
45
- [:boldpurple, 95],
46
- [:boldcyan, 96],
47
- [:boldwhite, 97],
48
- [:boldbgblack, 100], # High intensity background, aixterm (works in OS X)
49
- [:boldbgred, 101],
50
- [:boldbggreen, 102],
51
- [:boldbgyellow, 103],
52
- [:boldbgblue, 104],
53
- [:boldbgmagenta, 105],
54
- [:boldbgpurple, 105],
55
- [:boldbgcyan, 106],
56
- [:boldbgwhite, 107],
57
- [:softpurple, '0;35;40'],
58
- [:hotpants, '7;34;40'],
9
+ [:clear, 0], # String#clear is already used to empty string in Ruby 1.9
10
+ [:reset, 0], # synonym for :clear
11
+ [:bold, 1],
12
+ [:dark, 2],
13
+ [:italic, 3], # not widely implemented
14
+ [:underline, 4],
15
+ [:underscore, 4], # synonym for :underline
16
+ [:blink, 5],
17
+ [:rapid_blink, 6], # not widely implemented
18
+ [:negative, 7], # no reverse because of String#reverse
19
+ [:concealed, 8],
20
+ [:strikethrough, 9], # not widely implemented
21
+ [:strike, 9], # not widely implemented
22
+ [:black, 30],
23
+ [:red, 31],
24
+ [:green, 32],
25
+ [:yellow, 33],
26
+ [:blue, 34],
27
+ [:magenta, 35],
28
+ [:purple, 35],
29
+ [:cyan, 36],
30
+ [:white, 37],
31
+ [:bgblack, 40],
32
+ [:bgred, 41],
33
+ [:bggreen, 42],
34
+ [:bgyellow, 43],
35
+ [:bgblue, 44],
36
+ [:bgmagenta, 45],
37
+ [:bgpurple, 45],
38
+ [:bgcyan, 46],
39
+ [:bgwhite, 47],
40
+ [:boldblack, 90],
41
+ [:boldred, 91],
42
+ [:boldgreen, 92],
43
+ [:boldyellow, 93],
44
+ [:boldblue, 94],
45
+ [:boldmagenta, 95],
46
+ [:boldpurple, 95],
47
+ [:boldcyan, 96],
48
+ [:boldwhite, 97],
49
+ [:boldbgblack, 100],
50
+ [:boldbgred, 101],
51
+ [:boldbggreen, 102],
52
+ [:boldbgyellow, 103],
53
+ [:boldbgblue, 104],
54
+ [:boldbgmagenta, 105],
55
+ [:boldbgpurple, 105],
56
+ [:boldbgcyan, 106],
57
+ [:boldbgwhite, 107],
58
+ [:softpurple, '0;35;40'],
59
+ [:hotpants, '7;34;40'],
59
60
  [:knightrider, '7;30;40'],
60
- [:flamingo, '7;31;47'],
61
- [:yeller, '1;37;43'],
62
- [:whiteboard, '1;30;47'],
63
- [:default, '0;39']
61
+ [:flamingo, '7;31;47'],
62
+ [:yeller, '1;37;43'],
63
+ [:whiteboard, '1;30;47'],
64
+ [:chalkboard, '1;37;40'],
65
+ [:led, '0;32;40'],
66
+ [:redacted, '0;30;40'],
67
+ [:alert, '1;31;43'],
68
+ [:error, '1;37;41'],
69
+ [:default, '0;39']
64
70
  ].map(&:freeze).freeze
65
71
 
66
72
  ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
@@ -78,6 +84,40 @@ module Doing
78
84
  end
79
85
  end
80
86
 
87
+ # Template coloring
88
+ class ::String
89
+ ##
90
+ ## Extract the longest valid %color name from a string.
91
+ ##
92
+ ## Allows %colors to bleed into other text and still
93
+ ## be recognized, e.g. %greensomething still finds
94
+ ## %green.
95
+ ##
96
+ ## @return [String] a valid color name
97
+ ##
98
+ def validate_color
99
+ valid_color = nil
100
+ compiled = ''
101
+ normalize_color.split('').each do |char|
102
+ compiled += char
103
+ valid_color = compiled if Color.attributes.include?(compiled.to_sym)
104
+ end
105
+
106
+ valid_color
107
+ end
108
+
109
+ ##
110
+ ## Normalize a color name, removing underscores,
111
+ ## replacing "bright" with "bold", and converting
112
+ ## bgbold to boldbg
113
+ ##
114
+ ## @return [String] Normalized color name
115
+ ##
116
+ def normalize_color
117
+ gsub(/_/, '').sub(/bright/i, 'bold').sub(/bgbold/, 'boldbg')
118
+ end
119
+ end
120
+
81
121
  class << self
82
122
  # Returns true, if the coloring function of this module
83
123
  # is switched on, false otherwise.
@@ -113,6 +153,27 @@ module Doing
113
153
  result
114
154
  end
115
155
  EOT
156
+
157
+ # Accept brightwhite in addition to boldwhite
158
+ if c =~ /bold/
159
+ eval <<-EOT
160
+ def #{c.to_s.sub(/bold/, 'bright')}(string = nil)
161
+ result = ''
162
+ result << "\e[#{v}m" if Doing::Color.coloring?
163
+ if block_given?
164
+ result << yield
165
+ elsif string.respond_to?(:to_str)
166
+ result << string.to_str
167
+ elsif respond_to?(:to_str)
168
+ result << to_str
169
+ else
170
+ return result #only switch on
171
+ end
172
+ result << "\e[0m" if Doing::Color.coloring?
173
+ result
174
+ end
175
+ EOT
176
+ end
116
177
  end
117
178
 
118
179
  # Regular expression that is used to scan for ANSI-sequences while
@@ -68,6 +68,11 @@ module Doing
68
68
 
69
69
  def parse_command(command)
70
70
  res = command.match(/^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/)
71
+ if res.nil?
72
+ Doing.logger.error('Completion:', "Error parsing #{command}")
73
+ return nil
74
+
75
+ end
71
76
  commands = [res['cmd']]
72
77
  commands.concat(res['alias'].split(/, /).delete_if(&:empty?)) if res['alias']
73
78
 
@@ -179,6 +179,10 @@ module Doing
179
179
  end
180
180
  end
181
181
 
182
+ def fetch(*path, default)
183
+ @settings.dig(*path) || default
184
+ end
185
+
182
186
  ##
183
187
  ## Resolve a fuzzy-matched key path
184
188
  ##
@@ -216,9 +220,9 @@ module Doing
216
220
  return nil unless create
217
221
  end
218
222
 
219
- resolved = real_path.count.positive? ? "Resolved #{real_path.join('->')}, but " : ''
223
+ resolved = real_path.count.positive? ? "Resolved #{real_path.join('.')}, but " : ''
220
224
  Doing.logger.log_now(:warn, "#{resolved}#{path} is unknown")
221
- new_path = [*real_path, path, *paths].join('->')
225
+ new_path = [*real_path, path, *paths].join('.')
222
226
  Doing.logger.log_now(:warn, "Continuing will create the path #{new_path}")
223
227
  res = Prompt.yn('Key path not found, create it?', default_response: true)
224
228
  raise InvalidArgument, 'Invalid key path' unless res
@@ -370,7 +374,7 @@ module Doing
370
374
  deprecated = true
371
375
  config['editors']['default'] ||= config['editor']
372
376
  config.delete('editor')
373
- Doing.logger.debug('Deprecated:', "config key 'editor' is now 'editors->default', please update your config.")
377
+ Doing.logger.debug('Deprecated:', "config key 'editor' is now 'editors.default', please update your config.")
374
378
  end
375
379
 
376
380
  if config.key?('config_editor_app') && !config['editors']['config']
@@ -378,7 +382,7 @@ module Doing
378
382
  config['editors']['config'] = config['config_editor_app']
379
383
  config.delete('config_editor_app')
380
384
  Doing.logger.debug('Deprecated:',
381
- "config key 'config_editor_app' is now 'editors->config', please update your config.")
385
+ "config key 'config_editor_app' is now 'editors.config', please update your config.")
382
386
  end
383
387
 
384
388
  if config.key?('editor_app') && !config['editors']['doing_file']
@@ -386,7 +390,7 @@ module Doing
386
390
  config['editors']['doing_file'] = config['editor_app']
387
391
  config.delete('editor_app')
388
392
  Doing.logger.debug('Deprecated:',
389
- "config key 'editor_app' is now 'editors->doing_file', please update your config.")
393
+ "config key 'editor_app' is now 'editors.doing_file', please update your config.")
390
394
  end
391
395
 
392
396
  Doing.logger.warn('Deprecated:', 'outdated keys found, please run `doing config --update`.') if deprecated
data/lib/doing/good.rb CHANGED
@@ -48,6 +48,10 @@ module Doing
48
48
  def good?
49
49
  false
50
50
  end
51
+
52
+ def normalize_tag_sort
53
+ :time
54
+ end
51
55
  end
52
56
 
53
57
  class ::TrueClass
@@ -60,5 +64,9 @@ module Doing
60
64
  def good?
61
65
  true
62
66
  end
67
+
68
+ def normalize_tag_sort
69
+ :name
70
+ end
63
71
  end
64
72
  end
@@ -4,15 +4,15 @@ module GLI
4
4
  module Commands
5
5
  # Help Command Monkeypatch for paginated output
6
6
  class Help < Command
7
- def show_help(global_options,options,arguments,out,error)
7
+ def show_help(global_options, options, arguments, out, error)
8
8
  Doing::Pager.paginate = true
9
9
 
10
- command_finder = HelpModules::CommandFinder.new(@app,arguments,error)
10
+ command_finder = HelpModules::CommandFinder.new(@app, arguments, error)
11
11
  if options[:c]
12
- help_output = HelpModules::HelpCompletionFormat.new(@app,command_finder,arguments).format
12
+ help_output = HelpModules::HelpCompletionFormat.new(@app, command_finder, arguments).format
13
13
  out.puts help_output unless help_output.nil?
14
14
  elsif arguments.empty? || options[:c]
15
- Doing::Pager.page HelpModules::GlobalHelpFormat.new(@app,@sorter,@text_wrapping_class).format
15
+ Doing::Pager.page HelpModules::GlobalHelpFormat.new(@app, @sorter, @text_wrapping_class).format
16
16
  else
17
17
  name = arguments.shift
18
18
  command = command_finder.find_command(name)
@@ -22,7 +22,8 @@ module GLI
22
22
  @app,
23
23
  @sorter,
24
24
  @synopsis_formatter_class,
25
- @text_wrapping_class).format
25
+ @text_wrapping_class
26
+ ).format
26
27
  end
27
28
  end
28
29
  end
data/lib/doing/item.rb CHANGED
@@ -177,7 +177,7 @@ module Doing
177
177
  tags.each do |tag|
178
178
  bool = remove ? :and : :not
179
179
  if tags?(tag, bool)
180
- @title.tag!(tag, **options).strip!
180
+ @title = @title.tag(tag, **options).strip
181
181
  remove ? removed.push(tag) : added.push(tag)
182
182
  end
183
183
  end
@@ -278,7 +278,7 @@ module Doing
278
278
  case_type ||= prefs.fetch('case', 'smart').normalize_case
279
279
  new_note = Note.new
280
280
 
281
- if search.is_rx? || matching == :fuzzy
281
+ if search.rx? || matching == :fuzzy
282
282
  rx = search.to_rx(distance: distance, case_type: case_type)
283
283
  new_title = @title.gsub(rx) { |m| yellow(m) }
284
284
  new_note.add(@note.to_s.gsub(rx) { |m| yellow(m) })
@@ -316,7 +316,7 @@ module Doing
316
316
  distance ||= prefs.fetch('distance', 3).to_i
317
317
  case_type ||= prefs.fetch('case', 'smart').normalize_case
318
318
 
319
- if search.is_rx? || matching == :fuzzy
319
+ if search.rx? || matching == :fuzzy
320
320
  matches = @title + @note.to_s =~ search.to_rx(distance: distance, case_type: case_type)
321
321
  else
322
322
  query = search.strip.to_phrase_query
@@ -335,7 +335,7 @@ module Doing
335
335
  # matches = text =~ search.to_rx(distance: distance, case_type: case_type)
336
336
  # end
337
337
 
338
- # if search.is_rx? || !fuzzy
338
+ # if search.rx? || !fuzzy
339
339
  # matches = text =~ search.to_rx(distance: distance, case_type: case_type)
340
340
  # else
341
341
  # distance = 0.25 if distance > 1
@@ -393,7 +393,7 @@ module Doing
393
393
 
394
394
  Doing.logger.count(@section == 'Archive' ? :archived : :moved) if log
395
395
  Doing.logger.debug("#{@section == 'Archive' ? 'Archived' : 'Moved'}:",
396
- "#{@title.truncate(60)} from #{from} to #{@section}")
396
+ "#{@title.trunc(60)} from #{from} to #{@section}")
397
397
  self
398
398
  end
399
399
 
data/lib/doing/items.rb CHANGED
@@ -102,7 +102,7 @@ module Doing
102
102
 
103
103
  self[s_idx] = new_item
104
104
  Doing.logger.count(:updated)
105
- Doing.logger.info('Entry updated:', self[s_idx].title.truncate(60))
105
+ Doing.logger.info('Entry updated:', self[s_idx].title.trunc(60))
106
106
  new_item
107
107
  end
108
108
 
@@ -132,7 +132,7 @@ module Doing
132
132
  @sections.each do |section|
133
133
  out.push(section.original)
134
134
  items = in_section(section.title).sort_by { |i| i.date }
135
- items.reverse! if Doing.config.settings['doing_file_sort'].normalize_order == 'desc'
135
+ items.reverse! if Doing.config.settings['doing_file_sort'].normalize_order == :desc
136
136
  items.each { |item| out.push(item.to_s)}
137
137
  end
138
138
 
@@ -277,17 +277,50 @@ module Doing
277
277
 
278
278
  def log_benchmarks
279
279
  if ENV['DOING_BENCHMARK']
280
+
280
281
  output = []
281
- @benchmarks.each do |k, timers|
282
+ beginning = @benchmarks[:total][:start]
283
+ ending = @benchmarks[:total][:finish]
284
+ total = ending - beginning
285
+ factor = TTY::Screen.columns / total
286
+
287
+ cols = Array.new(TTY::Screen.columns)
288
+
289
+ colors = %w[bgred bggreen bgyellow bgblue bgmagenta bgcyan bgwhite boldbgred boldbggreen boldbgyellow boldbgblue boldbgwhite]
290
+ idx = 0
291
+ # @benchmarks.delete(:total)
292
+
293
+ @benchmarks.sort_by { |_, timers| [timers[:start], timers[:finish]] }.each do |k, timers|
282
294
  if timers[:finish] && timers[:start]
283
- output << "#{k}: #{timers[:finish] - timers[:start]}"
295
+ color = colors[idx % colors.count]
296
+ fg = if idx < 7
297
+ Color.boldblack
298
+ else
299
+ Color.boldwhite
300
+ end
301
+ color = Color.send(color) + fg
302
+
303
+ start = ((timers[:start] - beginning) * factor).floor
304
+ finish = ((timers[:finish] - beginning) * factor).ceil
305
+
306
+ cols.fill("#{color}-", start..finish)
307
+ cols[start] = "#{color}|"
308
+ cols[finish] = "#{color}|"
309
+ output << "#{color}#{k}#{Color.default}: #{timers[:finish] - timers[:start]}"
284
310
  else
285
311
  output << "#{k}: error"
286
312
  end
313
+
314
+ idx += 1
287
315
  end
316
+
288
317
  output.each do |msg|
289
318
  $stdout.puts color_message(:debug, 'Benchmark:', msg)
290
319
  end
320
+
321
+ $stdout.puts color_message(:debug, 'Benchmark:', "Total: #{total}")
322
+
323
+ $stdout.puts cols[0..TTY::Screen.columns-1].join + Color.reset
291
324
  end
292
325
  end
293
326