doing 2.1.24 → 2.1.28

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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +17 -21
  3. data/.yardoc/object_types +0 -0
  4. data/.yardoc/objects/root.dat +0 -0
  5. data/CHANGELOG.md +325 -102
  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 +3 -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 +73 -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 -3662
  55. data/docs/doc/Array.html +13 -449
  56. data/docs/doc/BooleanTermParser/Clause.html +5 -5
  57. data/docs/doc/BooleanTermParser/Operator.html +4 -4
  58. data/docs/doc/BooleanTermParser/Query.html +8 -8
  59. data/docs/doc/BooleanTermParser/QueryParser.html +2 -2
  60. data/docs/doc/BooleanTermParser/QueryTransformer.html +2 -2
  61. data/docs/doc/BooleanTermParser.html +1 -1
  62. data/docs/doc/Doing/Color.html +65 -59
  63. data/docs/doc/Doing/Completion.html +2 -2
  64. data/docs/doc/Doing/Configuration.html +49 -16
  65. data/docs/doc/Doing/Errors/DoingNoTraceError.html +2 -2
  66. data/docs/doc/Doing/Errors/DoingRuntimeError.html +2 -2
  67. data/docs/doc/Doing/Errors/DoingStandardError.html +2 -2
  68. data/docs/doc/Doing/Errors/EmptyInput.html +2 -2
  69. data/docs/doc/Doing/Errors/NoResults.html +2 -2
  70. data/docs/doc/Doing/Errors/PluginException.html +3 -3
  71. data/docs/doc/Doing/Errors/UserCancelled.html +2 -2
  72. data/docs/doc/Doing/Errors/WrongCommand.html +2 -2
  73. data/docs/doc/Doing/Errors.html +1 -1
  74. data/docs/doc/Doing/Hooks.html +6 -6
  75. data/docs/doc/Doing/Item.html +50 -16
  76. data/docs/doc/Doing/Items.html +10 -10
  77. data/docs/doc/Doing/LogAdapter.html +24 -24
  78. data/docs/doc/Doing/Note.html +7 -7
  79. data/docs/doc/Doing/Pager.html +4 -4
  80. data/docs/doc/Doing/Plugins.html +7 -7
  81. data/docs/doc/Doing/Prompt.html +59 -14
  82. data/docs/doc/Doing/Section.html +6 -6
  83. data/docs/doc/Doing/TemplateString.html +8 -8
  84. data/docs/doc/Doing/Types.html +46 -1
  85. data/docs/doc/Doing/Util/Backup.html +10 -10
  86. data/docs/doc/Doing/Util.html +15 -15
  87. data/docs/doc/Doing/WWID.html +73 -61
  88. data/docs/doc/Doing.html +3 -3
  89. data/docs/doc/FalseClass.html +235 -0
  90. data/docs/doc/GLI/Commands/Help.html +3 -3
  91. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +17 -17
  92. data/docs/doc/GLI/Commands.html +1 -1
  93. data/docs/doc/GLI.html +1 -1
  94. data/docs/doc/Hash.html +45 -11
  95. data/docs/doc/Numeric.html +5 -5
  96. data/docs/doc/Object.html +203 -0
  97. data/docs/doc/PhraseParser/Operator.html +4 -4
  98. data/docs/doc/PhraseParser/PhraseClause.html +5 -5
  99. data/docs/doc/PhraseParser/Query.html +10 -10
  100. data/docs/doc/PhraseParser/QueryParser.html +2 -2
  101. data/docs/doc/PhraseParser/QueryTransformer.html +2 -2
  102. data/docs/doc/PhraseParser/TermClause.html +5 -5
  103. data/docs/doc/PhraseParser.html +1 -1
  104. data/docs/doc/Status.html +7 -7
  105. data/docs/doc/String.html +306 -3111
  106. data/docs/doc/Symbol.html +45 -11
  107. data/docs/doc/Time.html +6 -6
  108. data/docs/doc/TrueClass.html +235 -0
  109. data/docs/doc/_index.html +37 -19
  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 +240 -576
  114. data/docs/doc/top-level-namespace.html +2 -2
  115. data/doing.rdoc +297 -169
  116. data/example_plugin.rb +2 -2
  117. data/lib/completion/_doing.zsh +35 -31
  118. data/lib/completion/doing.bash +30 -19
  119. data/lib/completion/doing.fish +81 -67
  120. data/lib/doing/array/array.rb +4 -0
  121. data/lib/doing/array/nested_hash.rb +17 -0
  122. data/lib/doing/{array.rb → array/tags.rb} +7 -25
  123. data/lib/doing/changelog/change.rb +26 -11
  124. data/lib/doing/changelog/changes.rb +16 -4
  125. data/lib/doing/{array_chronify.rb → chronify/array.rb} +0 -0
  126. data/lib/doing/chronify/chronify.rb +5 -0
  127. data/lib/doing/{numeric_chronify.rb → chronify/numeric.rb} +0 -0
  128. data/lib/doing/{string_chronify.rb → chronify/string.rb} +0 -0
  129. data/lib/doing/colors.rb +115 -54
  130. data/lib/doing/configuration.rb +9 -6
  131. data/lib/doing/good.rb +72 -0
  132. data/lib/doing/hash.rb +4 -0
  133. data/lib/doing/help_monkey_patch.rb +6 -5
  134. data/lib/doing/hooks.rb +3 -3
  135. data/lib/doing/item.rb +19 -15
  136. data/lib/doing/items.rb +2 -2
  137. data/lib/doing/log_adapter.rb +35 -2
  138. data/lib/doing/normalize.rb +188 -0
  139. data/lib/doing/pager.rb +1 -0
  140. data/lib/doing/plugins/export/dayone_export.rb +1 -1
  141. data/lib/doing/plugins/export/html_export.rb +1 -1
  142. data/lib/doing/plugins/export/json_export.rb +1 -1
  143. data/lib/doing/plugins/export/markdown_export.rb +1 -1
  144. data/lib/doing/plugins/export/template_export.rb +3 -1
  145. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  146. data/lib/doing/plugins/import/doing_import.rb +1 -1
  147. data/lib/doing/plugins/import/timing_import.rb +1 -1
  148. data/lib/doing/prompt.rb +9 -3
  149. data/lib/doing/string/highlight.rb +95 -0
  150. data/lib/doing/string/query.rb +129 -0
  151. data/lib/doing/string/string.rb +12 -0
  152. data/lib/doing/string/tags.rb +164 -0
  153. data/lib/doing/string/transform.rb +168 -0
  154. data/lib/doing/string/truncate.rb +75 -0
  155. data/lib/doing/string/url.rb +82 -0
  156. data/lib/doing/template_string.rb +2 -24
  157. data/lib/doing/types.rb +9 -0
  158. data/lib/doing/util.rb +20 -16
  159. data/lib/doing/version.rb +1 -1
  160. data/lib/doing/wwid.rb +91 -51
  161. data/lib/doing.rb +5 -6
  162. data/lib/examples/commands/wiki.rb +6 -7
  163. data/lib/examples/plugins/wiki_export/wiki_export.rb +1 -1
  164. data/lib/helpers/threaded_tests.rb +69 -79
  165. data/lib/helpers/threaded_tests_string.rb +50 -0
  166. data/scripts/deploy.rb +107 -0
  167. data/scripts/runtests.sh +4 -0
  168. metadata +65 -8
  169. data/lib/doing/string.rb +0 -765
  170. data/lib/doing/symbol.rb +0 -28
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',
@@ -45,8 +46,7 @@ module Doing
45
46
  'templates' => {
46
47
  'default' => {
47
48
  'date_format' => '%Y-%m-%d %H:%M',
48
- 'template' => '%reset%cyan%shortdate %boldwhite%80║ title %dark%boldmagenta[%boldwhite%-10section%boldmagenta]%reset
49
- %yellow%interval%boldred%duration%dark%white%80_14┃ note',
49
+ 'template' => '%reset%cyan%shortdate %boldwhite%80║ title %boldmagenta[%boldwhite%-10section%boldmagenta]%reset %yellow%interval%boldred%duration%white%80_14┃ note',
50
50
  'wrap_width' => 0,
51
51
  'order' => 'asc'
52
52
  },
@@ -63,8 +63,7 @@ module Doing
63
63
  },
64
64
  'recent' => {
65
65
  'date_format' => '%_I:%M%P',
66
- 'template' => '%reset%cyan%shortdate %boldwhite%80║ title %dark%boldmagenta[%boldwhite%-10section%boldmagenta]%reset
67
- %yellow%interval%boldred%duration%dark%white%80_14┃ note',
66
+ 'template' => '%reset%cyan%shortdate %boldwhite%80║ title %boldmagenta[%boldwhite%-10section%boldmagenta]%reset %yellow%interval%boldred%duration%white%80_14┃ note',
68
67
  'wrap_width' => 88,
69
68
  'count' => 10,
70
69
  'order' => 'asc'
@@ -180,6 +179,10 @@ module Doing
180
179
  end
181
180
  end
182
181
 
182
+ def fetch(*path, default)
183
+ @settings.dig(*path) || default
184
+ end
185
+
183
186
  ##
184
187
  ## Resolve a fuzzy-matched key path
185
188
  ##
@@ -314,7 +317,7 @@ module Doing
314
317
 
315
318
  @ignore_local = opt[:ignore_local] if opt[:ignore_local]
316
319
 
317
- config = read_config.dup
320
+ config = read_config.clone
318
321
 
319
322
  plugin_config = Util.deep_merge_hashes(DEFAULTS['plugins'], config['plugins'] || {})
320
323
 
@@ -322,7 +325,7 @@ module Doing
322
325
 
323
326
  Plugins.plugins.each do |_type, plugins|
324
327
  plugins.each do |title, plugin|
325
- plugin_config[title] = plugin[:config] if plugin[:config] && !plugin[:config].empty?
328
+ plugin_config[title] = plugin[:config] if plugin[:config].good?
326
329
  config['export_templates'][title] ||= nil if plugin[:templates] && !plugin[:templates].empty?
327
330
  end
328
331
  end
data/lib/doing/good.rb ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doing
4
+ # Object helpers
5
+ class ::Object
6
+ ##
7
+ ## Tests if object is nil or empty
8
+ ##
9
+ ## @return [Boolean] true if object is defined and
10
+ ## has content
11
+ ##
12
+ def good?
13
+ !nil? && !empty?
14
+ end
15
+ end
16
+
17
+ class ::String
18
+ ##
19
+ ## Tests if object is nil or empty
20
+ ##
21
+ ## @return [Boolean] true if object is defined and
22
+ ## has content
23
+ ##
24
+ def good?
25
+ !strip.empty?
26
+ end
27
+ end
28
+
29
+ class ::Array
30
+ ##
31
+ ## Tests if object is nil or empty
32
+ ##
33
+ ## @return [Boolean] true if object is defined and
34
+ ## has content
35
+ ##
36
+ def good?
37
+ !nil? && !empty?
38
+ end
39
+ end
40
+
41
+ class ::FalseClass
42
+ ##
43
+ ## Tests if object is nil or empty
44
+ ##
45
+ ## @return [Boolean] true if object is defined and
46
+ ## has content
47
+ ##
48
+ def good?
49
+ false
50
+ end
51
+
52
+ def normalize_tag_sort
53
+ :time
54
+ end
55
+ end
56
+
57
+ class ::TrueClass
58
+ ##
59
+ ## Tests if object is nil or empty
60
+ ##
61
+ ## @return [Boolean] true if object is defined and
62
+ ## has content
63
+ ##
64
+ def good?
65
+ true
66
+ end
67
+
68
+ def normalize_tag_sort
69
+ :name
70
+ end
71
+ end
72
+ end
data/lib/doing/hash.rb CHANGED
@@ -34,6 +34,10 @@ module Doing
34
34
  replace deep_thaw
35
35
  end
36
36
 
37
+ def clone
38
+ Marshal.load(Marshal.dump(self))
39
+ end
40
+
37
41
  # Turn all keys into string
38
42
  #
39
43
  # Return a copy of the hash where all its keys are strings
@@ -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/hooks.rb CHANGED
@@ -10,8 +10,8 @@ module Doing
10
10
  post_local_config: [], # wwid
11
11
  post_read: [], # wwid
12
12
  pre_entry_add: [], # wwid, new_entry
13
- post_entry_added: [], # wwid, new_entry.dup
14
- post_entry_updated: [], # wwid, entry
13
+ post_entry_added: [], # wwid, new_entry
14
+ post_entry_updated: [], # wwid, entry, old_entry
15
15
  post_entry_removed: [], # wwid, entry.dup
16
16
  pre_export: [], # wwid, format, entries
17
17
  pre_write: [], # wwid, file
@@ -57,7 +57,7 @@ module Doing
57
57
 
58
58
  def self.trigger(event, *args)
59
59
  hooks = @registry[event]
60
- return if hooks.nil? || hooks.empty?
60
+ return unless hooks.good?
61
61
 
62
62
  # sort and call hooks according to priority and load order
63
63
  hooks.sort_by { |h| @hook_priority[h] }.each do |hook|
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,13 +393,13 @@ 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
 
400
400
  # outputs item in Doing file format, including leading tab
401
401
  def to_s
402
- "\t- #{@date.strftime('%Y-%m-%d %H:%M')} | #{@title}#{@note.empty? ? '' : "\n#{@note}"}"
402
+ "\t- #{@date.strftime('%Y-%m-%d %H:%M')} | #{@title}#{@note.good? ? "\n#{@note}" : ''}"
403
403
  end
404
404
 
405
405
  ##
@@ -429,6 +429,10 @@ module Doing
429
429
  %(<Doing::Item @date=#{@date}>)
430
430
  end
431
431
 
432
+ def clone
433
+ Marshal.load(Marshal.dump(self))
434
+ end
435
+
432
436
  private
433
437
 
434
438
  def should?(key)
@@ -457,7 +461,7 @@ module Doing
457
461
  end
458
462
 
459
463
  def all_searches?(searches, case_type: :smart)
460
- return true if searches.nil? || searches.empty?
464
+ return true unless searches.good?
461
465
 
462
466
  text = @title + @note.to_s
463
467
  searches.each do |s|
@@ -468,7 +472,7 @@ module Doing
468
472
  end
469
473
 
470
474
  def no_searches?(searches, case_type: :smart)
471
- return true if searches.nil? || searches.empty?
475
+ return true unless searches.good?
472
476
 
473
477
  text = @title + @note.to_s
474
478
  searches.each do |s|
@@ -479,7 +483,7 @@ module Doing
479
483
  end
480
484
 
481
485
  def any_searches?(searches, case_type: :smart)
482
- return true if searches.nil? || searches.empty?
486
+ return true unless searches.good?
483
487
 
484
488
  text = @title + @note.to_s
485
489
  searches.each do |s|
@@ -490,7 +494,7 @@ module Doing
490
494
  end
491
495
 
492
496
  def all_tags?(tags)
493
- return true if tags.nil? || tags.empty?
497
+ return true unless tags.good?
494
498
 
495
499
  tags.each do |tag|
496
500
  return false unless @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
@@ -499,7 +503,7 @@ module Doing
499
503
  end
500
504
 
501
505
  def no_tags?(tags)
502
- return true if tags.nil? || tags.empty?
506
+ return true unless tags.good?
503
507
 
504
508
  tags.each do |tag|
505
509
  return false if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
@@ -508,7 +512,7 @@ module Doing
508
512
  end
509
513
 
510
514
  def any_tags?(tags)
511
- return true if tags.nil? || tags.empty?
515
+ return true unless tags.good?
512
516
 
513
517
  tags.each do |tag|
514
518
  return true if @title =~ /@#{tag.wildcard_to_rx}(?= |\(|\Z)/i
@@ -537,7 +541,7 @@ module Doing
537
541
  end
538
542
 
539
543
  def any_values?(queries)
540
- return true if queries.nil? || queries.empty?
544
+ return true unless queries.good?
541
545
 
542
546
  queries.each do |q|
543
547
  parts = split_value_query(q)
@@ -547,7 +551,7 @@ module Doing
547
551
  end
548
552
 
549
553
  def all_values?(queries)
550
- return true if queries.nil? || queries.empty?
554
+ return true unless queries.good?
551
555
 
552
556
  queries.each do |q|
553
557
  parts = split_value_query(q)
@@ -557,7 +561,7 @@ module Doing
557
561
  end
558
562
 
559
563
  def no_values?(queries)
560
- return true if queries.nil? || queries.empty?
564
+ return true unless queries.good?
561
565
 
562
566
  queries.each do |q|
563
567
  parts = split_value_query(q)
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