doing 2.1.25 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) 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 +322 -108
  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 +1 -1
  11. data/README.md +1 -1
  12. data/Rakefile +2 -3
  13. data/bin/commands/add_section.rb +15 -0
  14. data/bin/commands/again.rb +57 -0
  15. data/bin/commands/archive.rb +55 -0
  16. data/bin/commands/cancel.rb +60 -0
  17. data/bin/commands/changes.rb +83 -0
  18. data/bin/commands/choose.rb +9 -0
  19. data/bin/commands/colors.rb +21 -0
  20. data/bin/commands/commands.rb +89 -0
  21. data/bin/commands/commands_accepting.rb +76 -0
  22. data/bin/commands/completion.rb +27 -0
  23. data/bin/commands/config.rb +245 -0
  24. data/bin/commands/done.rb +235 -0
  25. data/bin/commands/finish.rb +126 -0
  26. data/bin/commands/flag.rb +90 -0
  27. data/bin/commands/grep.rb +108 -0
  28. data/bin/commands/import.rb +71 -0
  29. data/bin/commands/install_fzf.rb +17 -0
  30. data/bin/commands/last.rb +81 -0
  31. data/bin/commands/meanwhile.rb +76 -0
  32. data/bin/commands/note.rb +91 -0
  33. data/bin/commands/now.rb +145 -0
  34. data/bin/commands/on.rb +65 -0
  35. data/bin/commands/open.rb +53 -0
  36. data/bin/commands/plugins.rb +23 -0
  37. data/bin/commands/recent.rb +77 -0
  38. data/bin/commands/redo.rb +26 -0
  39. data/bin/commands/reset.rb +73 -0
  40. data/bin/commands/rotate.rb +42 -0
  41. data/bin/commands/sections.rb +11 -0
  42. data/bin/commands/select.rb +105 -0
  43. data/bin/commands/show.rb +185 -0
  44. data/bin/commands/since.rb +63 -0
  45. data/bin/commands/tag.rb +149 -0
  46. data/bin/commands/tag_dir.rb +29 -0
  47. data/bin/commands/tags.rb +66 -0
  48. data/bin/commands/template.rb +61 -0
  49. data/bin/commands/today.rb +64 -0
  50. data/bin/commands/undo.rb +49 -0
  51. data/bin/commands/view.rb +201 -0
  52. data/bin/commands/views.rb +11 -0
  53. data/bin/commands/yesterday.rb +72 -0
  54. data/bin/doing +241 -3706
  55. data/docs/doc/Array.html +3 -502
  56. data/docs/doc/BooleanTermParser/Clause.html +1 -1
  57. data/docs/doc/BooleanTermParser/Operator.html +1 -1
  58. data/docs/doc/BooleanTermParser/Query.html +1 -1
  59. data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
  60. data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
  61. data/docs/doc/BooleanTermParser.html +1 -1
  62. data/docs/doc/Doing/Color.html +62 -56
  63. data/docs/doc/Doing/Completion.html +1 -1
  64. data/docs/doc/Doing/Configuration.html +36 -1
  65. data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
  66. data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
  67. data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
  68. data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
  69. data/docs/doc/Doing/Errors/NoResults.html +1 -1
  70. data/docs/doc/Doing/Errors/PluginException.html +1 -1
  71. data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
  72. data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
  73. data/docs/doc/Doing/Errors.html +1 -1
  74. data/docs/doc/Doing/Hooks.html +1 -1
  75. data/docs/doc/Doing/Item.html +1 -1
  76. data/docs/doc/Doing/Items.html +2 -2
  77. data/docs/doc/Doing/LogAdapter.html +1 -1
  78. data/docs/doc/Doing/Note.html +2 -2
  79. data/docs/doc/Doing/Pager.html +1 -1
  80. data/docs/doc/Doing/Plugins.html +1 -1
  81. data/docs/doc/Doing/Prompt.html +46 -1
  82. data/docs/doc/Doing/Section.html +1 -1
  83. data/docs/doc/Doing/TemplateString.html +2 -2
  84. data/docs/doc/Doing/Types.html +41 -1
  85. data/docs/doc/Doing/Util/Backup.html +1 -1
  86. data/docs/doc/Doing/Util.html +1 -1
  87. data/docs/doc/Doing/WWID.html +10 -10
  88. data/docs/doc/Doing.html +3 -3
  89. data/docs/doc/FalseClass.html +235 -0
  90. data/docs/doc/GLI/Commands/Help.html +1 -1
  91. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
  92. data/docs/doc/GLI/Commands.html +1 -1
  93. data/docs/doc/GLI.html +1 -1
  94. data/docs/doc/Hash.html +1 -1
  95. data/docs/doc/Numeric.html +1 -1
  96. data/docs/doc/Object.html +203 -0
  97. data/docs/doc/PhraseParser/Operator.html +1 -1
  98. data/docs/doc/PhraseParser/PhraseClause.html +1 -1
  99. data/docs/doc/PhraseParser/Query.html +1 -1
  100. data/docs/doc/PhraseParser/QueryParser.html +1 -1
  101. data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
  102. data/docs/doc/PhraseParser/TermClause.html +1 -1
  103. data/docs/doc/PhraseParser.html +1 -1
  104. data/docs/doc/Status.html +1 -1
  105. data/docs/doc/String.html +287 -3155
  106. data/docs/doc/Symbol.html +40 -6
  107. data/docs/doc/Time.html +1 -1
  108. data/docs/doc/TrueClass.html +235 -0
  109. data/docs/doc/_index.html +5 -10
  110. data/docs/doc/class_list.html +1 -1
  111. data/docs/doc/file.README.html +2 -2
  112. data/docs/doc/index.html +2 -2
  113. data/docs/doc/method_list.html +289 -681
  114. data/docs/doc/top-level-namespace.html +2 -2
  115. data/doing.rdoc +306 -205
  116. data/lib/completion/_doing.zsh +35 -35
  117. data/lib/completion/doing.bash +30 -30
  118. data/lib/completion/doing.fish +88 -78
  119. data/lib/doing/array/array.rb +4 -0
  120. data/lib/doing/array/nested_hash.rb +17 -0
  121. data/lib/doing/{array.rb → array/tags.rb} +7 -25
  122. data/lib/doing/changelog/change.rb +26 -11
  123. data/lib/doing/changelog/changes.rb +31 -4
  124. data/lib/doing/{array_chronify.rb → chronify/array.rb} +0 -0
  125. data/lib/doing/chronify/chronify.rb +5 -0
  126. data/lib/doing/{numeric_chronify.rb → chronify/numeric.rb} +0 -0
  127. data/lib/doing/{string_chronify.rb → chronify/string.rb} +0 -0
  128. data/lib/doing/colors.rb +115 -54
  129. data/lib/doing/configuration.rb +5 -0
  130. data/lib/doing/good.rb +8 -0
  131. data/lib/doing/help_monkey_patch.rb +6 -5
  132. data/lib/doing/item.rb +5 -5
  133. data/lib/doing/items.rb +2 -2
  134. data/lib/doing/log_adapter.rb +35 -2
  135. data/lib/doing/normalize.rb +188 -0
  136. data/lib/doing/pager.rb +1 -0
  137. data/lib/doing/plugins/export/dayone_export.rb +1 -1
  138. data/lib/doing/plugins/export/html_export.rb +1 -1
  139. data/lib/doing/plugins/export/json_export.rb +1 -1
  140. data/lib/doing/plugins/export/markdown_export.rb +1 -1
  141. data/lib/doing/plugins/export/template_export.rb +3 -1
  142. data/lib/doing/prompt.rb +9 -3
  143. data/lib/doing/string/highlight.rb +95 -0
  144. data/lib/doing/string/query.rb +129 -0
  145. data/lib/doing/string/string.rb +12 -0
  146. data/lib/doing/string/tags.rb +164 -0
  147. data/lib/doing/string/transform.rb +168 -0
  148. data/lib/doing/string/truncate.rb +75 -0
  149. data/lib/doing/string/url.rb +82 -0
  150. data/lib/doing/template_string.rb +0 -22
  151. data/lib/doing/types.rb +8 -0
  152. data/lib/doing/util.rb +13 -9
  153. data/lib/doing/version.rb +1 -1
  154. data/lib/doing/wwid.rb +53 -35
  155. data/lib/doing.rb +4 -6
  156. data/lib/examples/commands/wiki.rb +6 -7
  157. data/lib/examples/plugins/wiki_export/wiki_export.rb +1 -1
  158. data/lib/helpers/threaded_tests.rb +39 -20
  159. data/scripts/deploy.rb +107 -0
  160. data/scripts/runtests.sh +4 -0
  161. metadata +63 -8
  162. data/lib/doing/string.rb +0 -765
  163. data/lib/doing/symbol.rb +0 -28
@@ -4,27 +4,54 @@ 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
+ '--preview-window="right,70%"'
40
+ ])
18
41
  end
19
42
 
20
43
  def to_s
21
- @changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
44
+ if @changes_only
45
+ @changes.map(&:changes_only).join().force_encoding('utf-8')
46
+ else
47
+ @changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
48
+ end
22
49
  end
23
50
 
24
51
  private
25
52
 
26
53
  def parse_changes(lookup, search)
27
- change_rx = /(?<=\n|\A)### (\d+\.\d+\.\d+(?:\w*))(.*)(?=\n### |\Z)/m
54
+ change_rx = /(?<=\n|\A)### (\d+\.\d+\.\d+(?:\w*))(.*?)(?=\n### |\Z)/m
28
55
  @changes = @content.scan(change_rx).each_with_object([]) do |m, a|
29
56
  next if m[0].nil? || m[1].nil?
30
57
 
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
@@ -29,6 +29,7 @@ module Doing
29
29
  'plugin_path' => File.join(Util.user_home, '.config', 'doing', 'plugins'),
30
30
  'command_path' => File.join(Util.user_home, '.config', 'doing', 'commands')
31
31
  },
32
+ 'disabled_commands' => [],
32
33
  'doing_file' => '~/.local/share/doing/what_was_i_doing.md',
33
34
  'doing_file_sort' => 'desc',
34
35
  'backup_dir' => '~/.local/share/doing/doing_backup',
@@ -178,6 +179,10 @@ module Doing
178
179
  end
179
180
  end
180
181
 
182
+ def fetch(*path, default)
183
+ @settings.dig(*path) || default
184
+ end
185
+
181
186
  ##
182
187
  ## Resolve a fuzzy-matched key path
183
188
  ##
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
 
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doing
4
+ ##
5
+ ## String to symbol conversion
6
+ ##
7
+ class ::String
8
+ ##
9
+ ## Convert tag sort string to a qualified type
10
+ ##
11
+ ## @return [Symbol] :name or :time
12
+ ##
13
+ def normalize_tag_sort(default = :name)
14
+ case self
15
+ when /^n/i
16
+ :name
17
+ when /^t/i
18
+ :time
19
+ else
20
+ default
21
+ end
22
+ end
23
+
24
+ ## @see #normalize_tag_sort
25
+ def normalize_tag_sort!(default = :name)
26
+ replace normalize_tag_sort(default)
27
+ end
28
+
29
+ ##
30
+ ## Convert an age string to a qualified type
31
+ ##
32
+ ## @return [Symbol] :oldest or :newest
33
+ ##
34
+ def normalize_age(default = :newest)
35
+ case self
36
+ when /^o/i
37
+ :oldest
38
+ when /^n/i
39
+ :newest
40
+ else
41
+ default
42
+ end
43
+ end
44
+
45
+ ## @see #normalize_age
46
+ def normalize_age!(default = :newest)
47
+ replace normalize_age(default)
48
+ end
49
+
50
+ ##
51
+ ## Convert a sort order string to a qualified type
52
+ ##
53
+ ## @return [Symbol] :asc or :desc
54
+ ##
55
+ def normalize_order!(default = :asc)
56
+ replace normalize_order(default)
57
+ end
58
+
59
+ def normalize_order(default = :asc)
60
+ case self
61
+ when /^a/i
62
+ :asc
63
+ when /^d/i
64
+ :desc
65
+ else
66
+ default
67
+ end
68
+ end
69
+
70
+ ##
71
+ ## Convert a case sensitivity string to a symbol
72
+ ##
73
+ ## @return Symbol :smart, :sensitive, :ignore
74
+ ##
75
+ def normalize_case(default = :smart)
76
+ case self
77
+ when /^(c|sens)/i
78
+ :sensitive
79
+ when /^i/i
80
+ :ignore
81
+ when /^s/i
82
+ :smart
83
+ else
84
+ default.is_a?(Symbol) ? default : default.normalize_case
85
+ end
86
+ end
87
+
88
+ ## @see #normalize_case
89
+ def normalize_case!(default = :smart)
90
+ replace normalize_case(default)
91
+ end
92
+
93
+ ##
94
+ ## Convert a boolean string to a symbol
95
+ ##
96
+ ## @return Symbol :and, :or, or :not
97
+ ##
98
+ def normalize_bool(default = :and)
99
+ case self
100
+ when /(and|all)/i
101
+ :and
102
+ when /(any|or)/i
103
+ :or
104
+ when /(not|none)/i
105
+ :not
106
+ when /^p/i
107
+ :pattern
108
+ else
109
+ default.is_a?(Symbol) ? default : default.normalize_bool
110
+ end
111
+ end
112
+
113
+ ## @see #normalize_bool
114
+ def normalize_bool!(default = :and)
115
+ replace normalize_bool(default)
116
+ end
117
+
118
+ ##
119
+ ## Convert a matching configuration string to a symbol
120
+ ##
121
+ ## @param default [Symbol] the default matching
122
+ ## type to return if the string
123
+ ## doesn't match a known symbol
124
+ ## @return Symbol :fuzzy, :pattern, :exact
125
+ ##
126
+ def normalize_matching(default = :pattern)
127
+ case self
128
+ when /^f/i
129
+ :fuzzy
130
+ when /^p/i
131
+ :pattern
132
+ when /^e/i
133
+ :exact
134
+ else
135
+ default.is_a?(Symbol) ? default : default.normalize_matching
136
+ end
137
+ end
138
+
139
+ ## @see #normalize_matching
140
+ def normalize_matching!(default = :pattern)
141
+ replace normalize_bool(default)
142
+ end
143
+
144
+ ##
145
+ ## Adds ?: to any parentheticals in a regular expression
146
+ ## to avoid match groups
147
+ ##
148
+ ## @return [String] modified regular expression
149
+ ##
150
+ def normalize_trigger
151
+ gsub(/\((?!\?:)/, '(?:').downcase
152
+ end
153
+
154
+ ## @see #normalize_trigger
155
+ def normalize_trigger!
156
+ replace normalize_trigger
157
+ end
158
+ end
159
+
160
+ ##
161
+ ## Symbol helpers
162
+ ##
163
+ class ::Symbol
164
+ def normalize_tag_sort(default = :name)
165
+ to_s.normalize_tag_sort
166
+ end
167
+
168
+ def normalize_bool(default = :and)
169
+ to_s.normalize_bool(default)
170
+ end
171
+
172
+ def normalize_age(default = :newest)
173
+ to_s.normalize_age(default)
174
+ end
175
+
176
+ def normalize_order(default = :asc)
177
+ to_s.normalize_order(default)
178
+ end
179
+
180
+ def normalize_case(default = :smart)
181
+ to_s.normalize_case(default)
182
+ end
183
+
184
+ def normalize_matching(default = :pattern)
185
+ to_s.normalize_matching(default)
186
+ end
187
+ end
188
+ end
data/lib/doing/pager.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'pathname'
3
4
 
4
5
  module Doing
@@ -129,7 +129,7 @@ module Doing
129
129
  self.template('dayone')
130
130
  end
131
131
 
132
- totals = opt[:totals] ? wwid.tag_times(format: :markdown, sort_by_name: opt[:sort_tags], sort_order: opt[:tag_order]) : ''
132
+ totals = opt[:totals] ? wwid.tag_times(format: :markdown, sort_by: opt[:sort_tags], sort_order: opt[:tag_order]) : ''
133
133
 
134
134
  case digest
135
135
  when :day
@@ -70,7 +70,7 @@ module Doing
70
70
  self.template('css')
71
71
  end
72
72
 
73
- totals = opt[:totals] ? wwid.tag_times(format: :html, sort_by_name: opt[:sort_tags], sort_order: opt[:tag_order]) : ''
73
+ totals = opt[:totals] ? wwid.tag_times(format: :html, sort_by: opt[:sort_tags], sort_order: opt[:tag_order]) : ''
74
74
  engine = Haml::Engine.new(template)
75
75
  Doing.logger.debug('HTML Export:', "#{items_out.count} items output to HTML")
76
76
  @out = engine.render(Object.new,
@@ -91,7 +91,7 @@ module Doing
91
91
  JSON.pretty_generate({
92
92
  'section' => variables[:page_title],
93
93
  'items' => items_out,
94
- 'timers' => wwid.tag_times(format: :json, sort_by_name: opt[:sort_tags], sort_order: opt[:tag_order])
94
+ 'timers' => wwid.tag_times(format: :json, sort_by: opt[:sort_tags], sort_order: opt[:tag_order])
95
95
  })
96
96
  elsif opt[:output] == 'timeline'
97
97
  template = <<~EOTEMPLATE