doing 2.1.89 → 2.1.90

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 (242) hide show
  1. checksums.yaml +4 -4
  2. data/.irbrc +2 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +251 -0
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +1 -1
  8. data/Rakefile +5 -3
  9. data/bin/commands/changes.rb +3 -1
  10. data/bin/commands/choose.rb +2 -0
  11. data/bin/commands/colors.rb +5 -3
  12. data/bin/commands/commands_accepting.rb +3 -3
  13. data/bin/commands/completion.rb +2 -1
  14. data/bin/commands/config.rb +8 -6
  15. data/bin/commands/done.rb +19 -12
  16. data/bin/commands/finish.rb +4 -2
  17. data/bin/commands/grep.rb +9 -5
  18. data/bin/commands/import.rb +14 -11
  19. data/bin/commands/install_fzf.rb +4 -2
  20. data/bin/commands/last.rb +31 -27
  21. data/bin/commands/meanwhile.rb +6 -2
  22. data/bin/commands/note.rb +6 -3
  23. data/bin/commands/now.rb +2 -0
  24. data/bin/commands/open.rb +6 -1
  25. data/bin/commands/plugins.rb +2 -0
  26. data/bin/commands/recent.rb +47 -33
  27. data/bin/commands/reset.rb +7 -3
  28. data/bin/commands/rotate.rb +6 -3
  29. data/bin/commands/sections.rb +3 -3
  30. data/bin/commands/select.rb +2 -0
  31. data/bin/commands/show.rb +24 -20
  32. data/bin/commands/since.rb +10 -3
  33. data/bin/commands/tag.rb +18 -16
  34. data/bin/commands/tag_dir.rb +5 -2
  35. data/bin/commands/tags.rb +17 -17
  36. data/bin/commands/template.rb +8 -2
  37. data/bin/commands/today.rb +10 -2
  38. data/bin/commands/undo.rb +2 -0
  39. data/bin/commands/update.rb +9 -7
  40. data/bin/commands/view.rb +11 -8
  41. data/bin/commands/views.rb +2 -0
  42. data/bin/commands/yesterday.rb +6 -1
  43. data/bin/doing +54 -57
  44. data/docs/doc/Array.html +3 -3
  45. data/docs/doc/BooleanTermParser/Clause.html +3 -3
  46. data/docs/doc/BooleanTermParser/Operator.html +3 -3
  47. data/docs/doc/BooleanTermParser/Query.html +3 -3
  48. data/docs/doc/BooleanTermParser/QueryParser.html +3 -3
  49. data/docs/doc/BooleanTermParser/QueryTransformer.html +3 -3
  50. data/docs/doc/BooleanTermParser.html +3 -3
  51. data/docs/doc/Doing/ArrayCleanup.html +3 -3
  52. data/docs/doc/Doing/ArrayNestedHash.html +3 -3
  53. data/docs/doc/Doing/ArrayTags.html +9 -9
  54. data/docs/doc/Doing/ByDayExport.html +3 -3
  55. data/docs/doc/Doing/CSVExport.html +4 -4
  56. data/docs/doc/Doing/CalendarImport.html +4 -4
  57. data/docs/doc/Doing/Change.html +3 -3
  58. data/docs/doc/Doing/Changes.html +3 -3
  59. data/docs/doc/Doing/ChronifyArray.html +3 -3
  60. data/docs/doc/Doing/ChronifyNumeric.html +3 -3
  61. data/docs/doc/Doing/ChronifyString.html +6 -6
  62. data/docs/doc/Doing/Color.html +88 -47
  63. data/docs/doc/Doing/Completion/BashCompletions.html +3 -3
  64. data/docs/doc/Doing/Completion/FigCompletions.html +3 -3
  65. data/docs/doc/Doing/Completion/FishCompletions.html +3 -3
  66. data/docs/doc/Doing/Completion/StringUtils.html +3 -3
  67. data/docs/doc/Doing/Completion/ZshCompletions.html +3 -3
  68. data/docs/doc/Doing/Completion.html +5 -5
  69. data/docs/doc/Doing/Configuration.html +6 -6
  70. data/docs/doc/Doing/DayOneRenderer.html +3 -3
  71. data/docs/doc/Doing/DayoneExport.html +4 -4
  72. data/docs/doc/Doing/DoingExport.html +5 -5
  73. data/docs/doc/Doing/DoingImport.html +4 -4
  74. data/docs/doc/Doing/Entry.html +3 -3
  75. data/docs/doc/Doing/Errors/DoingNoTraceError.html +3 -3
  76. data/docs/doc/Doing/Errors/DoingRuntimeError.html +3 -3
  77. data/docs/doc/Doing/Errors/DoingStandardError.html +3 -3
  78. data/docs/doc/Doing/Errors/EmptyInput.html +3 -3
  79. data/docs/doc/Doing/Errors/HistoryLimitError.html +3 -3
  80. data/docs/doc/Doing/Errors/InvalidPlugin.html +3 -3
  81. data/docs/doc/Doing/Errors/MissingBackupFile.html +3 -3
  82. data/docs/doc/Doing/Errors/NoResults.html +3 -3
  83. data/docs/doc/Doing/Errors/PluginException.html +3 -3
  84. data/docs/doc/Doing/Errors/UserCancelled.html +3 -3
  85. data/docs/doc/Doing/Errors/WrongCommand.html +3 -3
  86. data/docs/doc/Doing/Errors.html +3 -3
  87. data/docs/doc/Doing/HTMLExport.html +4 -4
  88. data/docs/doc/Doing/Hooks.html +3 -16
  89. data/docs/doc/Doing/Item.html +4 -4
  90. data/docs/doc/Doing/ItemDates.html +3 -3
  91. data/docs/doc/Doing/ItemQuery.html +3 -3
  92. data/docs/doc/Doing/ItemState.html +3 -3
  93. data/docs/doc/Doing/ItemTags.html +3 -3
  94. data/docs/doc/Doing/Items.html +3 -3
  95. data/docs/doc/Doing/JSONExport.html +4 -4
  96. data/docs/doc/Doing/JSONImport.html +4 -4
  97. data/docs/doc/Doing/Logger.html +183 -3
  98. data/docs/doc/Doing/MarkdownExport.html +4 -4
  99. data/docs/doc/Doing/Note.html +3 -3
  100. data/docs/doc/Doing/Pager.html +54 -58
  101. data/docs/doc/Doing/Plugins.html +3 -3
  102. data/docs/doc/Doing/Prompt.html +4 -4
  103. data/docs/doc/Doing/PromptChoose.html +3 -3
  104. data/docs/doc/Doing/PromptFZF.html +3 -3
  105. data/docs/doc/Doing/PromptInput.html +3 -3
  106. data/docs/doc/Doing/PromptSTD.html +3 -3
  107. data/docs/doc/Doing/PromptYN.html +3 -3
  108. data/docs/doc/Doing/Section.html +3 -3
  109. data/docs/doc/Doing/StringHighlight.html +3 -3
  110. data/docs/doc/Doing/StringNormalize.html +3 -3
  111. data/docs/doc/Doing/StringQuery.html +4 -4
  112. data/docs/doc/Doing/StringTags.html +3 -3
  113. data/docs/doc/Doing/StringTransform.html +3 -3
  114. data/docs/doc/Doing/StringTruncate.html +3 -3
  115. data/docs/doc/Doing/StringURL.html +3 -3
  116. data/docs/doc/Doing/SymbolNormalize.html +5 -5
  117. data/docs/doc/Doing/TaskPaperExport.html +4 -4
  118. data/docs/doc/Doing/TemplateExport.html +5 -5
  119. data/docs/doc/Doing/TemplateString.html +7 -7
  120. data/docs/doc/Doing/TimingImport.html +4 -4
  121. data/docs/doc/Doing/Types.html +3 -3
  122. data/docs/doc/Doing/Util/Backup.html +4 -17
  123. data/docs/doc/Doing/Util.html +56 -61
  124. data/docs/doc/Doing/Version.html +3 -3
  125. data/docs/doc/Doing/WWID.html +6 -4
  126. data/docs/doc/Doing.html +4 -4
  127. data/docs/doc/FalseClass.html +3 -3
  128. data/docs/doc/GLI/Commands/Help.html +5 -5
  129. data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +3 -3
  130. data/docs/doc/GLI/Commands.html +3 -3
  131. data/docs/doc/GLI.html +3 -3
  132. data/docs/doc/Hash.html +4 -4
  133. data/docs/doc/Numeric.html +3 -3
  134. data/docs/doc/Object.html +3 -3
  135. data/docs/doc/PhraseParser/Operator.html +3 -3
  136. data/docs/doc/PhraseParser/PhraseClause.html +3 -3
  137. data/docs/doc/PhraseParser/Query.html +3 -3
  138. data/docs/doc/PhraseParser/QueryParser.html +3 -3
  139. data/docs/doc/PhraseParser/QueryTransformer.html +3 -3
  140. data/docs/doc/PhraseParser/TermClause.html +3 -3
  141. data/docs/doc/PhraseParser.html +3 -3
  142. data/docs/doc/Status.html +3 -3
  143. data/docs/doc/String.html +51 -5
  144. data/docs/doc/Symbol.html +3 -3
  145. data/docs/doc/Time.html +3 -3
  146. data/docs/doc/TrueClass.html +3 -3
  147. data/docs/doc/_index.html +4 -4
  148. data/docs/doc/class_list.html +6 -3
  149. data/docs/doc/css/full_list.css +3 -3
  150. data/docs/doc/css/style.css +6 -0
  151. data/docs/doc/file.README.html +3 -3
  152. data/docs/doc/file_list.html +5 -2
  153. data/docs/doc/frames.html +1 -1
  154. data/docs/doc/index.html +3 -3
  155. data/docs/doc/js/app.js +294 -264
  156. data/docs/doc/js/full_list.js +30 -4
  157. data/docs/doc/method_list.html +443 -392
  158. data/docs/doc/top-level-namespace.html +3 -3
  159. data/doing.gemspec +2 -0
  160. data/doing.rdoc +1 -1
  161. data/example_plugin.rb +1 -4
  162. data/lib/doing/add_options.rb +2 -2
  163. data/lib/doing/array/cleanup.rb +2 -0
  164. data/lib/doing/array/nested_hash.rb +2 -0
  165. data/lib/doing/boolean_term_parser.rb +3 -3
  166. data/lib/doing/changelog/changes.rb +4 -5
  167. data/lib/doing/changelog/version.rb +8 -11
  168. data/lib/doing/chronify/array.rb +4 -4
  169. data/lib/doing/chronify/string.rb +5 -4
  170. data/lib/doing/cli_status.rb +7 -2
  171. data/lib/doing/colors.rb +93 -51
  172. data/lib/doing/completion/bash_completion.rb +36 -39
  173. data/lib/doing/completion/completion_string.rb +2 -1
  174. data/lib/doing/completion/fig_completion.rb +33 -33
  175. data/lib/doing/completion/fish_completion.rb +22 -23
  176. data/lib/doing/completion/zsh_completion.rb +5 -5
  177. data/lib/doing/completion.rb +7 -4
  178. data/lib/doing/configuration.rb +21 -13
  179. data/lib/doing/errors.rb +1 -4
  180. data/lib/doing/good.rb +1 -1
  181. data/lib/doing/hash.rb +4 -4
  182. data/lib/doing/help_monkey_patch.rb +1 -1
  183. data/lib/doing/hooks.rb +6 -2
  184. data/lib/doing/item/dates.rb +3 -1
  185. data/lib/doing/item/query.rb +10 -10
  186. data/lib/doing/item/state.rb +2 -0
  187. data/lib/doing/logger.rb +113 -45
  188. data/lib/doing/markdown_document_listener.rb +25 -25
  189. data/lib/doing/normalize.rb +1 -1
  190. data/lib/doing/pager.rb +73 -29
  191. data/lib/doing/plugin_manager.rb +4 -5
  192. data/lib/doing/plugins/export/byday.rb +1 -1
  193. data/lib/doing/plugins/export/dayone_export.rb +28 -27
  194. data/lib/doing/plugins/export/doing_export.rb +1 -1
  195. data/lib/doing/plugins/export/html_export.rb +3 -3
  196. data/lib/doing/plugins/export/json_export.rb +4 -5
  197. data/lib/doing/plugins/export/markdown_export.rb +10 -2
  198. data/lib/doing/plugins/export/taskpaper_export.rb +1 -0
  199. data/lib/doing/plugins/export/template_export.rb +110 -107
  200. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  201. data/lib/doing/plugins/import/doing_import.rb +2 -2
  202. data/lib/doing/plugins/import/timing_import.rb +3 -3
  203. data/lib/doing/prompt/choose.rb +5 -6
  204. data/lib/doing/prompt/fzf.rb +3 -2
  205. data/lib/doing/prompt/input.rb +7 -6
  206. data/lib/doing/prompt/yn.rb +9 -11
  207. data/lib/doing/string/tags.rb +7 -4
  208. data/lib/doing/string/transform.rb +15 -10
  209. data/lib/doing/string/truncate.rb +1 -0
  210. data/lib/doing/string/url.rb +1 -1
  211. data/lib/doing/template_string.rb +13 -9
  212. data/lib/doing/time.rb +4 -2
  213. data/lib/doing/util.rb +12 -11
  214. data/lib/doing/util_backup.rb +29 -26
  215. data/lib/doing/version.rb +3 -1
  216. data/lib/doing/wwid/display.rb +182 -151
  217. data/lib/doing/wwid/editor.rb +13 -12
  218. data/lib/doing/wwid/filetools.rb +13 -11
  219. data/lib/doing/wwid/filter.rb +41 -40
  220. data/lib/doing/wwid/guess.rb +6 -8
  221. data/lib/doing/wwid/interactive.rb +9 -9
  222. data/lib/doing/wwid/modify.rb +53 -53
  223. data/lib/doing/wwid/timers.rb +4 -5
  224. data/lib/doing/wwid/wwid.rb +0 -0
  225. data/lib/doing/wwid/wwidutil.rb +8 -10
  226. data/lib/examples/commands/wiki.rb +2 -0
  227. data/lib/examples/plugins/capture_thing_import.rb +1 -1
  228. data/lib/examples/plugins/say_export.rb +1 -2
  229. data/lib/examples/plugins/wiki_export/wiki_export.rb +3 -4
  230. data/lib/helpers/fzf/test/test_go.rb +5 -5
  231. data/lib/helpers/threaded_tests.rb +20 -20
  232. data/lib/helpers/threaded_tests_string.rb +2 -0
  233. data/rdoc_to_mmd.rb +5 -4
  234. data/rdocfixer.rb +1 -2
  235. data/scripts/deploy.rb +3 -4
  236. data/scripts/generate_bash_completions.rb +40 -43
  237. data/scripts/generate_fish_completions.rb +17 -15
  238. data/scripts/generate_zsh_completions.rb +9 -7
  239. data/scripts/setting_replace.rb +1 -0
  240. data/scripts/sort_commands.rb +4 -2
  241. data/yard_templates/default/method_details/setup.rb +3 -1
  242. metadata +3 -1
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.36
9
+ &mdash; Documentation by YARD 0.9.37
10
10
 
11
11
  </title>
12
12
 
@@ -216,9 +216,9 @@
216
216
  </div>
217
217
 
218
218
  <div id="footer">
219
- Generated on Mon May 19 04:38:00 2025 by
219
+ Generated on Thu Oct 23 08:05:56 2025 by
220
220
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
221
- 0.9.36 (ruby-3.4.4).
221
+ 0.9.37 (ruby-3.4.4).
222
222
  </div>
223
223
 
224
224
  </div>
data/doing.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Ensure we require the local version and not one we might have installed already
2
4
  require './lib/doing/version'
3
5
  Gem::Specification.new do |s|
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.1.89
8
+ v2.1.90
9
9
 
10
10
  === Global Options
11
11
  === --config_file arg
data/example_plugin.rb CHANGED
@@ -83,7 +83,6 @@ module Doing
83
83
  }
84
84
  end
85
85
 
86
-
87
86
  #-------------------------------------------------------
88
87
  ## Output a template. Only required if template(s) are
89
88
  ## included in settings. The method should return a
@@ -106,7 +105,6 @@ module Doing
106
105
  'On %date, you were %title, recorded in section %section%took'
107
106
  end
108
107
 
109
-
110
108
  ##
111
109
  ## Render data received from an output
112
110
  ## command
@@ -122,7 +120,7 @@ module Doing
122
120
  ##
123
121
  ## @return [String] Rendered output
124
122
  ##
125
- def self.render(wwid, items, variables: {})
123
+ def self.render(_wwid, items, variables: {})
126
124
  return unless items.good?
127
125
 
128
126
  config = Doing.config.settings
@@ -154,7 +152,6 @@ module Doing
154
152
  finished_at = i.end_date
155
153
  took += finished_at.strftime('%A %B %e at %I:%M%p')
156
154
 
157
-
158
155
  took += ' and it took'
159
156
  took += interval.time_string(format: :natural)
160
157
  end
@@ -45,7 +45,7 @@ def add_options(type, cmd, default_template: 'default')
45
45
  cmd.arg_name 'FORMAT'
46
46
  cmd.flag %i[o output], type: ExportTemplate
47
47
 
48
- cmd.desc "Output using a template from configuration"
48
+ cmd.desc 'Output using a template from configuration'
49
49
  cmd.arg_name 'TEMPLATE_KEY'
50
50
  cmd.flag [:config_template], type: TemplateName, default_value: default_template
51
51
 
@@ -57,7 +57,7 @@ def add_options(type, cmd, default_template: 'default')
57
57
  cmd.arg_name 'FORMAT'
58
58
  cmd.flag %i[o output]
59
59
 
60
- cmd.desc "Output using a template from configuration"
60
+ cmd.desc 'Output using a template from configuration'
61
61
  cmd.arg_name 'TEMPLATE_KEY'
62
62
  cmd.flag [:config_template], type: TemplateName
63
63
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  module ArrayCleanup
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  ##
3
5
  ## Array helpers
@@ -15,10 +15,10 @@ module BooleanTermParser
15
15
  end
16
16
 
17
17
  class QueryTransformer < Parslet::Transform
18
- rule(:clause => subtree(:clause)) do
18
+ rule(clause: subtree(:clause)) do
19
19
  Clause.new(clause[:operator]&.to_s, clause[:term].to_s)
20
20
  end
21
- rule(:query => sequence(:clauses)) { Query.new(clauses) }
21
+ rule(query: sequence(:clauses)) { Query.new(clauses) }
22
22
  end
23
23
 
24
24
  class Operator
@@ -49,7 +49,7 @@ module BooleanTermParser
49
49
  attr_accessor :should_terms, :must_not_terms, :must_terms
50
50
 
51
51
  def initialize(clauses)
52
- grouped = clauses.chunk { |c| c.operator }.to_h
52
+ grouped = clauses.chunk(&:operator).to_h
53
53
  self.should_terms = grouped.fetch(:should, []).map(&:term)
54
54
  self.must_not_terms = grouped.fetch(:must_not, []).map(&:term)
55
55
  self.must_terms = grouped.fetch(:must, []).map(&:term)
@@ -6,7 +6,8 @@ module Doing
6
6
  attr_reader :changes
7
7
  attr_writer :changes_only
8
8
 
9
- def initialize(lookup: nil, search: nil, changes: false, sort: :desc, prefix: false, only: %i[changed new improved fixed])
9
+ def initialize(lookup: nil, search: nil, changes: false, sort: :desc, prefix: false,
10
+ only: %i[changed new improved fixed])
10
11
  @changes_only = changes
11
12
  @prefix = prefix
12
13
  @only = only
@@ -28,7 +29,7 @@ module Doing
28
29
  end
29
30
 
30
31
  def versions
31
- @changes.select { |change| change.entries&.count > 0 }.map { |change| change.version }
32
+ @changes.select { |change| change.entries&.count&.> 0 }.map(&:version)
32
33
  end
33
34
 
34
35
  def interactive
@@ -45,7 +46,7 @@ module Doing
45
46
 
46
47
  def to_s
47
48
  if @changes_only
48
- @changes.map(&:changes_only).delete_if(&:empty?).join().gsub(/\n+/, "\n").force_encoding('utf-8')
49
+ @changes.map(&:changes_only).delete_if(&:empty?).join.gsub(/\n+/, "\n").force_encoding('utf-8')
49
50
  else
50
51
  @changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
51
52
  end
@@ -67,8 +68,6 @@ module Doing
67
68
  end
68
69
 
69
70
  def lookup(lookup_version)
70
- range = []
71
-
72
71
  if lookup_version =~ /([\d.]+) *(?:-|to)+ *([\d.]+)/
73
72
  m = Regexp.last_match
74
73
  lookup("> #{m[1]}")
@@ -36,7 +36,6 @@ module Doing
36
36
  val.is_a?(String)
37
37
  end
38
38
 
39
-
40
39
  def compare(other, comp, inclusive: false)
41
40
  case comp
42
41
  when :older
@@ -81,18 +80,16 @@ module Doing
81
80
  true
82
81
  elsif wild?(other.min)
83
82
  @min.to_s =~ /^#{other.min}/ ? true : false
84
- else
85
- if @min == other.min
86
- if other.patch.nil?
87
- true
88
- elsif wild?(other.patch)
89
- @patch.to_s =~ /^#{other.patch}/ ? true : false
90
- else
91
- @patch == other.patch
92
- end
83
+ elsif @min == other.min
84
+ if other.patch.nil?
85
+ true
86
+ elsif wild?(other.patch)
87
+ @patch.to_s =~ /^#{other.patch}/ ? true : false
93
88
  else
94
- false
89
+ @patch == other.patch
95
90
  end
91
+ else
92
+ false
96
93
  end
97
94
  end
98
95
  end
@@ -9,12 +9,12 @@ module Doing
9
9
 
10
10
  if d.zero? && h > 24
11
11
  d = (h / 24).floor
12
- h = h % 24
12
+ h %= 24
13
13
  end
14
14
 
15
15
  if d > 365
16
16
  y = (d / 365).floor
17
- d = d % 365
17
+ d %= 365
18
18
  else
19
19
  y = 0
20
20
  end
@@ -41,7 +41,7 @@ module Doing
41
41
 
42
42
  if d.zero? && h > 24
43
43
  d = (h / 24).floor
44
- h = h % 24
44
+ h %= 24
45
45
  end
46
46
  end
47
47
 
@@ -68,7 +68,7 @@ module Doing
68
68
  when :clock
69
69
  if d.zero? && h > 24
70
70
  d = (h / 24).floor
71
- h = h % 24
71
+ h %= 24
72
72
  end
73
73
  format('%<d>02d:%<h>02d:%<m>02d', d: d, h: h, m: m)
74
74
  when :hmclock
@@ -43,8 +43,10 @@ module Doing
43
43
  Doing.logger.debug('Parser:', %(date/time string "#{self}" interpreted as #{res} (#{secs_ago} seconds ago)))
44
44
  else
45
45
  date_string = dup
46
- date_string = 'today' if date_string.match(Types::REGEX_DAY) && now.strftime('%a') =~ /^#{Regexp.last_match(1)}/i
47
- date_string = "#{options[:context].to_s} #{date_string}" if date_string =~ Types::REGEX_TIME && options[:context]
46
+ if date_string.match(Types::REGEX_DAY) && now.strftime('%a') =~ /^#{Regexp.last_match(1)}/i
47
+ date_string = 'today'
48
+ end
49
+ date_string = "#{options[:context]} #{date_string}" if date_string =~ Types::REGEX_TIME && options[:context]
48
50
 
49
51
  res = Chronic.parse(date_string, {
50
52
  guess: options.fetch(:guess, :begin),
@@ -69,7 +71,7 @@ module Doing
69
71
  ##
70
72
  def chronify_qty
71
73
  minutes = 0
72
- case self.strip
74
+ case strip
73
75
  when /^(\d+):(\d\d)$/
74
76
  minutes += Regexp.last_match(1).to_i * 60
75
77
  minutes += Regexp.last_match(2).to_i
@@ -212,7 +214,6 @@ module Doing
212
214
 
213
215
  end
214
216
 
215
-
216
217
  if start.is_a? String
217
218
  Doing.logger.debug('Parser:',
218
219
  "--from string interpreted as time span, from #{start || '12am'} to #{finish || '11:59pm'}")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Status
2
4
  def cols
3
5
  @cols ||= `tput cols`.strip.to_i
@@ -11,11 +13,14 @@ module Status
11
13
  tail = tail.join(', ')
12
14
  end
13
15
  tail.ltrunc!(max_width)
14
- $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail)
16
+ $stderr.print format(
17
+ "#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail
18
+ )
15
19
  end
16
20
 
17
21
  def status(msg, reset: true, end_char: "\n")
18
- $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg, reset ? "\r" : end_char)
22
+ $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg,
23
+ reset ? "\r" : end_char)
19
24
  end
20
25
 
21
26
  def msg(msg, reset: true, color: 'green', end_char: "\n")
data/lib/doing/colors.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  module Doing
5
5
  # Terminal output color functions.
6
6
  module Color
7
- ESCAPE_REGEX = /(?<=\[)(?:(?:(?:[349]|10)[0-9]|[0-9])?;?)+(?=m)/.freeze
7
+ ESCAPE_REGEX = /\e\[[0-9;]*m/.freeze
8
8
  # All available color names. Available as methods and string extensions.
9
9
  #
10
10
  # @example Use a color as a method. Color reset will be added to end of string.
@@ -110,7 +110,9 @@ module Doing
110
110
  compiled = ''
111
111
  normalize_color.split('').each do |char|
112
112
  compiled += char
113
- valid_color = compiled if Color.attributes.include?(compiled.to_sym) || compiled =~ /^([fb]g?)?#([a-f0-9]{6})$/i
113
+ if Color.attributes.include?(compiled.to_sym) || compiled =~ /^([fb]g?)?#([a-f0-9]{6})$/i
114
+ valid_color = compiled
115
+ end
114
116
  end
115
117
 
116
118
  valid_color
@@ -182,13 +184,49 @@ module Doing
182
184
  escape += "\e[#{rgbf}m" if rgbf
183
185
  escape + "\e[#{[fg, bg].delete_if(&:nil?).join(';')}m"
184
186
  end
187
+
188
+ # Define string extension methods for all color attributes
189
+ ATTRIBUTES.each do |c, v|
190
+ new_method = <<-EOSCRIPT
191
+ def #{c}
192
+ result = ''
193
+ result << "\e[#{v}m" if Doing::Color.coloring?
194
+ result << self
195
+ result << "\e[0m" if Doing::Color.coloring?
196
+ result
197
+ end
198
+ EOSCRIPT
199
+
200
+ class_eval(new_method)
201
+
202
+ next unless c =~ /bold/
203
+
204
+ # Accept brightwhite in addition to boldwhite
205
+ new_method = <<-EOSCRIPT
206
+ def #{c.to_s.sub(/bold/, 'bright')}
207
+ result = ''
208
+ result << "\e[#{v}m" if Doing::Color.coloring?
209
+ result << self
210
+ result << "\e[0m" if Doing::Color.coloring?
211
+ result
212
+ end
213
+ EOSCRIPT
214
+
215
+ class_eval(new_method)
216
+ end
217
+
218
+ # Returns an uncolored version of the string, that is all
219
+ # ANSI-sequences are stripped from the string.
220
+ def uncolor
221
+ gsub(ESCAPE_REGEX, '')
222
+ end
185
223
  end
186
224
 
187
225
  class << self
188
226
  # Returns true if the coloring function of this module
189
227
  # is switched on, false otherwise.
190
228
  def coloring?
191
- @coloring
229
+ @coloring.nil? ? true : @coloring
192
230
  end
193
231
 
194
232
  attr_writer :coloring
@@ -236,51 +274,62 @@ module Doing
236
274
 
237
275
  fmt.empty? ? input : format(fmt, colors)
238
276
  end
239
- end
240
277
 
241
- ATTRIBUTES.each do |c, v|
242
- new_method = <<-EOSCRIPT
243
- def #{c}(string = nil)
244
- result = ''
245
- result << "\e[#{v}m" if Doing::Color.coloring?
246
- if block_given?
247
- result << yield
248
- elsif string.respond_to?(:to_str)
249
- result << string.to_str
250
- elsif respond_to?(:to_str)
251
- result << to_str
252
- else
253
- return result #only switch on
278
+ ATTRIBUTES.each do |c, v|
279
+ new_method = <<-EOSCRIPT
280
+ def #{c}(string = nil)
281
+ result = ''
282
+ result << "\e[#{v}m" if Doing::Color.coloring?
283
+ if block_given?
284
+ result << yield
285
+ elsif string.respond_to?(:to_str)
286
+ result << string.to_str
287
+ elsif respond_to?(:to_str)
288
+ result << to_str
289
+ else
290
+ return result #only switch on
291
+ end
292
+ result << "\e[0m" if Doing::Color.coloring?
293
+ result
254
294
  end
255
- result << "\e[0m" if Doing::Color.coloring?
256
- result
257
- end
258
- EOSCRIPT
259
-
260
- module_eval(new_method)
261
-
262
- next unless c =~ /bold/
263
-
264
- # Accept brightwhite in addition to boldwhite
265
- new_method = <<-EOSCRIPT
266
- def #{c.to_s.sub(/bold/, 'bright')}(string = nil)
267
- result = ''
268
- result << "\e[#{v}m" if Doing::Color.coloring?
269
- if block_given?
270
- result << yield
271
- elsif string.respond_to?(:to_str)
272
- result << string.to_str
273
- elsif respond_to?(:to_str)
274
- result << to_str
275
- else
276
- return result #only switch on
295
+ EOSCRIPT
296
+
297
+ module_eval(new_method)
298
+
299
+ next unless c =~ /bold/
300
+
301
+ # Accept brightwhite in addition to boldwhite
302
+ new_method = <<-EOSCRIPT
303
+ def #{c.to_s.sub(/bold/, 'bright')}(string = nil)
304
+ result = ''
305
+ result << "\e[#{v}m" if Doing::Color.coloring?
306
+ if block_given?
307
+ result << yield
308
+ elsif string.respond_to?(:to_str)
309
+ result << string.to_str
310
+ elsif respond_to?(:to_str)
311
+ result << to_str
312
+ else
313
+ return result #only switch on
314
+ end
315
+ result << "\e[0m" if Doing::Color.coloring?
316
+ result
277
317
  end
278
- result << "\e[0m" if Doing::Color.coloring?
279
- result
280
- end
281
- EOSCRIPT
318
+ EOSCRIPT
319
+
320
+ module_eval(new_method)
321
+ end
322
+
323
+ # Returns an array of all Doing::Color attributes as symbols.
324
+ def attributes
325
+ ATTRIBUTE_NAMES
326
+ end
282
327
 
283
- module_eval(new_method)
328
+ # Returns an uncolored version of the string, that is all
329
+ # ANSI-sequences are stripped from the string.
330
+ def uncolor(string)
331
+ string.to_str.gsub(ESCAPE_REGEX, '')
332
+ end
284
333
  end
285
334
 
286
335
  def rgb(hex)
@@ -292,7 +341,6 @@ module Doing
292
341
  %w[r g b].each do |e|
293
342
  t << parts[e].hex
294
343
  end
295
- color =
296
344
  "\e[#{is_bg ? '48' : '38'};2;#{t.join(';')}m"
297
345
  end
298
346
 
@@ -309,11 +357,5 @@ module Doing
309
357
  ''
310
358
  end
311
359
  end
312
-
313
- # Returns an array of all Doing::Color attributes as symbols.
314
- def attributes
315
- ATTRIBUTE_NAMES
316
- end
317
- extend self
318
360
  end
319
361
  end
@@ -11,35 +11,33 @@ module Doing
11
11
  out = []
12
12
  logic = []
13
13
 
14
- @commands.each_with_index do |cmd, i|
14
+ @commands.each_with_index do |cmd, _i|
15
15
  @bar.advance(status: cmd[:commands].first)
16
16
 
17
17
  data = Completion.get_help_sections(cmd[:commands].first)
18
18
 
19
19
  arg = data[:synopsis].join(' ').strip.split(/ /).last
20
- case arg
21
- when /(path|file)/i
22
- type = :file
23
- when /sect/i
24
- type = 'sections'
25
- when /view/i
26
- type = 'views'
20
+ type = case arg
21
+ when /(path|file)/i
22
+ :file
23
+ when /sect/i
24
+ 'sections'
25
+ when /view/i
26
+ 'views'
27
+ end
28
+
29
+ next unless data[:command_options]
30
+
31
+ options = Completion.parse_options(data[:command_options])
32
+ out << command_function(cmd[:commands].first, options, type)
33
+
34
+ if first
35
+ op = 'if'
36
+ first = false
27
37
  else
28
- type = nil
29
- end
30
-
31
- if data[:command_options]
32
- options = Completion.parse_options(data[:command_options])
33
- out << command_function(cmd[:commands].first, options, type)
34
-
35
- if first
36
- op = 'if'
37
- first = false
38
- else
39
- op = 'elif'
40
- end
41
- logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
38
+ op = 'elif'
42
39
  end
40
+ logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
43
41
  end
44
42
 
45
43
  out << <<~EOFUNC
@@ -71,25 +69,23 @@ module Doing
71
69
  short_options << o[:short] if o[:short]
72
70
  end
73
71
 
74
- long = long_options.map! {|o| "--#{o}"}.join(' ')
75
- short = short_options.map! {|o| "-#{o}"}.join(' ')
72
+ long = long_options.map! { |o| "--#{o}" }.join(' ')
73
+ short = short_options.map! { |o| "-#{o}" }.join(' ')
76
74
  words = ''
77
75
  logic = ''
78
- words, logic = get_words(type) if type && type.is_a?(String)
79
-
80
- func = <<~ENDFUNC
81
- _doing_#{command}() {
82
- #{words}
83
- if [[ "$token" == --* ]]; then
84
- COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
85
- elif [[ "$token" == -* ]]; then
86
- COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
87
- #{logic}
88
- fi
89
- }
76
+ words, logic = get_words(type) if type.is_a?(String)
77
+
78
+ <<~ENDFUNC
79
+ _doing_#{command}() {
80
+ #{words}
81
+ if [[ "$token" == --* ]]; then
82
+ COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
83
+ elif [[ "$token" == -* ]]; then
84
+ COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
85
+ #{logic}
86
+ fi
87
+ }
90
88
  ENDFUNC
91
-
92
- func
93
89
  end
94
90
 
95
91
  def get_words(type)
@@ -126,7 +122,8 @@ module Doing
126
122
  data = Completion.get_help_sections
127
123
  @global_options = Completion.parse_options(data[:global_options])
128
124
  @commands = Completion.parse_commands(data[:commands])
129
- @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m", total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'Reading subcommands')
125
+ @bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m",
126
+ total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'Reading subcommands')
130
127
  width = TTY::Screen.columns - 45
131
128
  @bar.resize(width)
132
129
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doing
2
4
  module Completion
3
5
  module StringUtils
4
-
5
6
  ##
6
7
  ## Get short description for command completion
7
8
  ##