doing 2.0.9.pre → 2.0.10

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +20 -0
  3. data/.yardoc/complete +0 -0
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/.yardoc/proxy_types +0 -0
  7. data/.yardopts +1 -0
  8. data/CHANGELOG.md +1 -1
  9. data/Gemfile.lock +30 -10
  10. data/README.md +1 -1
  11. data/Rakefile +8 -1
  12. data/bin/doing +76 -30
  13. data/doc/Array.html +135 -0
  14. data/doc/Doing/Color.html +506 -0
  15. data/doc/Doing/Configuration.html +680 -0
  16. data/doc/Doing/Errors/DoingNoTraceError.html +186 -0
  17. data/doc/Doing/Errors/DoingRuntimeError.html +186 -0
  18. data/doc/Doing/Errors/DoingStandardError.html +186 -0
  19. data/doc/Doing/Errors/EmptyInput.html +186 -0
  20. data/doc/Doing/Errors/NoResults.html +186 -0
  21. data/doc/Doing/Errors/PluginException.html +248 -0
  22. data/doc/Doing/Errors/UserCancelled.html +186 -0
  23. data/doc/Doing/Errors/WrongCommand.html +186 -0
  24. data/doc/Doing/Errors.html +191 -0
  25. data/doc/Doing/Hooks.html +364 -0
  26. data/doc/Doing/Item.html +1385 -0
  27. data/doc/Doing/Items.html +393 -0
  28. data/doc/Doing/LogAdapter.html +1650 -0
  29. data/doc/Doing/Note.html +535 -0
  30. data/doc/Doing/Pager.html +268 -0
  31. data/doc/Doing/Plugins.html +849 -0
  32. data/doc/Doing/Util.html +870 -0
  33. data/doc/Doing/WWID.html +4827 -0
  34. data/doc/Doing.html +145 -0
  35. data/doc/GLI/Commands/MarkdownDocumentListener.html +763 -0
  36. data/doc/GLI/Commands.html +115 -0
  37. data/doc/GLI.html +115 -0
  38. data/doc/Hash.html +332 -0
  39. data/doc/Status.html +292 -0
  40. data/doc/String.html +1714 -0
  41. data/doc/Symbol.html +250 -0
  42. data/doc/Time.html +182 -0
  43. data/doc/_index.html +411 -0
  44. data/doc/class_list.html +51 -0
  45. data/doc/css/common.css +1 -0
  46. data/doc/css/full_list.css +58 -0
  47. data/doc/css/style.css +497 -0
  48. data/doc/file.README.html +123 -0
  49. data/doc/file_list.html +56 -0
  50. data/doc/frames.html +17 -0
  51. data/doc/index.html +123 -0
  52. data/doc/js/app.js +314 -0
  53. data/doc/js/full_list.js +216 -0
  54. data/doc/js/jquery.js +4 -0
  55. data/doc/method_list.html +1867 -0
  56. data/doc/top-level-namespace.html +112 -0
  57. data/doing.gemspec +5 -1
  58. data/doing.rdoc +86 -16
  59. data/example_plugin.rb +6 -6
  60. data/lib/doing/array.rb +1 -1
  61. data/lib/doing/configuration.rb +14 -12
  62. data/lib/doing/hash.rb +1 -1
  63. data/lib/doing/item.rb +101 -17
  64. data/lib/doing/log_adapter.rb +123 -113
  65. data/lib/doing/note.rb +1 -1
  66. data/lib/doing/plugin_manager.rb +5 -5
  67. data/lib/doing/plugins/export/csv_export.rb +1 -1
  68. data/lib/doing/plugins/export/template_export.rb +5 -7
  69. data/lib/doing/plugins/import/calendar_import.rb +1 -1
  70. data/lib/doing/plugins/import/doing_import.rb +4 -4
  71. data/lib/doing/plugins/import/timing_import.rb +5 -3
  72. data/lib/doing/string.rb +75 -22
  73. data/lib/doing/symbol.rb +9 -5
  74. data/lib/doing/time.rb +1 -1
  75. data/lib/doing/util.rb +18 -11
  76. data/lib/doing/version.rb +1 -1
  77. data/lib/doing/wwid.rb +419 -326
  78. data/lib/doing/wwidfile.rb +5 -5
  79. data/lib/doing.rb +2 -1
  80. data/lib/examples/plugins/say_export.rb +6 -6
  81. data/rdocfixer.rb +1 -1
  82. data/yard_templates/default/method_details/setup.rb +3 -0
  83. metadata +117 -4
data/lib/doing/string.rb CHANGED
@@ -2,14 +2,59 @@
2
2
 
3
3
  module Doing
4
4
  ##
5
- ## @brief String helpers
5
+ ## String helpers
6
6
  ##
7
7
  class ::String
8
8
  include Doing::Color
9
- def to_rx(distance)
10
- gsub(/(.)/, "\\1.{0,#{distance}}")
9
+ ##
10
+ ## Determines if receiver is surrounded by slashes or starts with single quote
11
+ ##
12
+ ## @return True if regex, False otherwise.
13
+ ##
14
+ def is_rx?
15
+ self =~ %r{(^/.*?/$|^')}
11
16
  end
12
17
 
18
+ ##
19
+ ## Convert string to fuzzy regex. Characters in words
20
+ ## can be separated by up to *distance* characters in
21
+ ## haystack, spaces indicate unlimited distance.
22
+ ##
23
+ ## @example "this word".to_rx(2) =>
24
+ ## /t.{0,3}h.{0,3}i.{0,3}s.{0,3}.*?w.{0,3}o.{0,3}r.{0,3}d/
25
+ ##
26
+ ## @param distance [Integer] Allowed distance
27
+ ## between characters
28
+ ## @param case_type The case type
29
+ ##
30
+ ## @return [Regexp] Regex pattern
31
+ ##
32
+ def to_rx(distance: 3, case_type: :smart)
33
+ case_sensitive = case case_type
34
+ when :smart
35
+ self =~ /[A-Z]/ ? true : false
36
+ when :sensitive
37
+ true
38
+ else
39
+ false
40
+ end
41
+
42
+ pattern = case dup.strip
43
+ when %r{^/.*?/$}
44
+ sub(%r{/(.*?)/}, '\1')
45
+ when /^'/
46
+ sub(/^'(.*?)'?$/, '\1')
47
+ else
48
+ split(/ +/).map { |w| w.split('').join(".{0,#{distance}}") }.join('.*?')
49
+ end
50
+ Regexp.new(pattern, !case_sensitive)
51
+ end
52
+
53
+ ##
54
+ ## Test string for truthiness (0, "f", "false", "n", "no" all return false, case insensitive, otherwise true)
55
+ ##
56
+ ## @return [Boolean] String is truthy
57
+ ##
13
58
  def truthy?
14
59
  if self =~ /^(0|f(alse)?|n(o)?)$/i
15
60
  false
@@ -18,10 +63,18 @@ module Doing
18
63
  end
19
64
  end
20
65
 
66
+ ## @param (see #highlight_tags)
21
67
  def highlight_tags!(color = 'yellow')
22
68
  replace highlight_tags(color)
23
69
  end
24
70
 
71
+ ##
72
+ ## Colorize @tags with ANSI escapes
73
+ ##
74
+ ## @param color [String] color (see #Color)
75
+ ##
76
+ ## @return [String] string with @tags highlighted
77
+ ##
25
78
  def highlight_tags(color = 'yellow')
26
79
  escapes = scan(/(\e\[[\d;]+m)[^\e]+@/)
27
80
  tag_color = Doing::Color.send(color)
@@ -34,7 +87,7 @@ module Doing
34
87
  end
35
88
 
36
89
  ##
37
- ## @brief Test if line should be ignored
90
+ ## Test if line should be ignored
38
91
  ##
39
92
  ## @return [Boolean] line is empty or comment
40
93
  ##
@@ -44,7 +97,7 @@ module Doing
44
97
  end
45
98
 
46
99
  ##
47
- ## @brief Truncate to nearest word
100
+ ## Truncate to nearest word
48
101
  ##
49
102
  ## @param len The length
50
103
  ##
@@ -68,7 +121,7 @@ module Doing
68
121
  end
69
122
 
70
123
  ##
71
- ## @brief Truncate string in the middle
124
+ ## Truncate string in the middle
72
125
  ##
73
126
  ## @param len The length
74
127
  ## @param ellipsis The ellipsis
@@ -87,7 +140,7 @@ module Doing
87
140
  end
88
141
 
89
142
  ##
90
- ## @brief Remove color escape codes
143
+ ## Remove color escape codes
91
144
  ##
92
145
  ## @return clean string
93
146
  ##
@@ -100,7 +153,7 @@ module Doing
100
153
  end
101
154
 
102
155
  ##
103
- ## @brief Wrap string at word breaks, respecting tags
156
+ ## Wrap string at word breaks, respecting tags
104
157
  ##
105
158
  ## @param len [Integer] The length
106
159
  ## @param offset [Integer] (Optional) The width to pad each subsequent line
@@ -134,7 +187,7 @@ module Doing
134
187
  end
135
188
 
136
189
  ##
137
- ## @brief Capitalize on the first character on string
190
+ ## Capitalize on the first character on string
138
191
  ##
139
192
  ## @return Capitalized string
140
193
  ##
@@ -145,12 +198,12 @@ module Doing
145
198
  end
146
199
 
147
200
  ##
148
- ## @brief Convert a sort order string to a qualified type
201
+ ## Convert a sort order string to a qualified type
149
202
  ##
150
- ## @return (String) 'asc' or 'desc'
203
+ ## @return [String] 'asc' or 'desc'
151
204
  ##
152
- def normalize_order!
153
- replace normalize_order
205
+ def normalize_order!(default = 'asc')
206
+ replace normalize_order(default)
154
207
  end
155
208
 
156
209
  def normalize_order(default = 'asc')
@@ -165,9 +218,9 @@ module Doing
165
218
  end
166
219
 
167
220
  ##
168
- ## @brief Convert a case sensitivity string to a symbol
221
+ ## Convert a case sensitivity string to a symbol
169
222
  ##
170
- ## @return Symbol :smart, :sensitive, :insensitive
223
+ ## @return Symbol :smart, :sensitive, :ignore
171
224
  ##
172
225
  def normalize_case!
173
226
  replace normalize_case
@@ -178,7 +231,7 @@ module Doing
178
231
  when /^c/i
179
232
  :sensitive
180
233
  when /^i/i
181
- :insensitive
234
+ :ignore
182
235
  when /^s/i
183
236
  :smart
184
237
  else
@@ -187,12 +240,12 @@ module Doing
187
240
  end
188
241
 
189
242
  ##
190
- ## @brief Convert a boolean string to a symbol
243
+ ## Convert a boolean string to a symbol
191
244
  ##
192
245
  ## @return Symbol :and, :or, or :not
193
246
  ##
194
- def normalize_bool!
195
- replace normalize_bool
247
+ def normalize_bool!(default = :and)
248
+ replace normalize_bool(default)
196
249
  end
197
250
 
198
251
  def normalize_bool(default = :and)
@@ -290,7 +343,7 @@ module Doing
290
343
  end
291
344
 
292
345
  ##
293
- ## @brief Remove duplicate tags, leaving only first occurrence
346
+ ## Remove duplicate tags, leaving only first occurrence
294
347
  ##
295
348
  ## @return Deduplicated string
296
349
  ##
@@ -316,9 +369,9 @@ module Doing
316
369
  end
317
370
 
318
371
  ##
319
- ## @brief Turn raw urls into HTML links
372
+ ## Turn raw urls into HTML links
320
373
  ##
321
- ## @param opt (Hash) Additional Options
374
+ ## @param opt [Hash] Additional Options
322
375
  ##
323
376
  def link_urls!(opt = {})
324
377
  replace link_urls(opt)
data/lib/doing/symbol.rb CHANGED
@@ -2,15 +2,19 @@
2
2
 
3
3
  module Doing
4
4
  ##
5
- ## @brief Symbol helpers
5
+ ## Symbol helpers
6
6
  ##
7
7
  class ::Symbol
8
- def normalize_bool
9
- to_s.normalize_bool
8
+ def normalize_bool(default = :and)
9
+ to_s.normalize_bool(default)
10
10
  end
11
11
 
12
- def normalize_order
13
- to_s.normalize_order
12
+ def normalize_order(default = 'asc')
13
+ to_s.normalize_order(default)
14
+ end
15
+
16
+ def normalize_case
17
+ self
14
18
  end
15
19
  end
16
20
  end
data/lib/doing/time.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Doing
2
2
  ##
3
- ## @brief Date helpers
3
+ ## Date helpers
4
4
  ##
5
5
  class ::Time
6
6
  def relative_date
data/lib/doing/util.rb CHANGED
@@ -14,9 +14,9 @@ module Doing
14
14
  end
15
15
 
16
16
  ##
17
- ## @brief Test if command line tool is available
17
+ ## Test if command line tool is available
18
18
  ##
19
- ## @param cli (String) The name or path of the cli
19
+ ## @param cli [String] The name or path of the cli
20
20
  ##
21
21
  def exec_available(cli)
22
22
  return false if cli.nil?
@@ -40,9 +40,14 @@ module Doing
40
40
  end
41
41
  end
42
42
 
43
- # Non-destructive version of deep_merge_hashes! See that method.
43
+ # Non-destructive version of deep_merge_hashes! See that
44
+ # method.
45
+ #
46
+ # @return the merged hashes.
47
+ #
48
+ # @param [Hash] master_hash The master hash
49
+ # @param [Hash] other_hash The other hash
44
50
  #
45
- # Returns the merged hashes.
46
51
  def deep_merge_hashes(master_hash, other_hash)
47
52
  deep_merge_hashes!(master_hash.dup, other_hash)
48
53
  end
@@ -90,11 +95,11 @@ module Doing
90
95
  end
91
96
 
92
97
  ##
93
- ## @brief Write content to a file
98
+ ## Write content to a file
94
99
  ##
95
- ## @param file (String) The path to the file to (over)write
96
- ## @param content (String) The content to write to the file
97
- ## @param backup (Boolean) create a ~ backup
100
+ ## @param file [String] The path to the file to (over)write
101
+ ## @param content [String] The content to write to the file
102
+ ## @param backup [Boolean] create a ~ backup
98
103
  ##
99
104
  def write_to_file(file, content, backup: true)
100
105
  unless file
@@ -143,6 +148,8 @@ module Doing
143
148
  end
144
149
 
145
150
  def find_default_editor(editor_for = 'default')
151
+ # return nil unless $stdout.isatty || ENV['DOING_EDITOR_TEST']
152
+
146
153
  if ENV['DOING_EDITOR_TEST']
147
154
  return ENV['EDITOR']
148
155
  end
@@ -156,20 +163,20 @@ module Doing
156
163
 
157
164
  if editor_config[editor_for]
158
165
  editor = editor_config[editor_for]
159
- Doing.logger.debug('Editor:', "Using #{editor} from config 'editors->#{editor_for}'")
166
+ # Doing.logger.debug('Editor:', "Using #{editor} from config 'editors->#{editor_for}'")
160
167
  return editor unless editor.nil? || editor.empty?
161
168
  end
162
169
 
163
170
  if editor_for != 'editor' && editor_config['default']
164
171
  editor = editor_config['default']
165
- Doing.logger.debug('Editor:', "Using #{editor} from config: 'editors->default'")
172
+ # Doing.logger.debug('Editor:', "Using #{editor} from config: 'editors->default'")
166
173
  return editor unless editor.nil? || editor.empty?
167
174
  end
168
175
 
169
176
  editor ||= ENV['DOING_EDITOR'] || ENV['GIT_EDITOR'] || ENV['EDITOR']
170
177
 
171
178
  unless editor.nil? || editor.empty?
172
- Doing.logger.debug('Editor:', "Found editor in environment variables: #{editor}")
179
+ # Doing.logger.debug('Editor:', "Found editor in environment variables: #{editor}")
173
180
  return editor
174
181
  end
175
182
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '2.0.9.pre'
2
+ VERSION = '2.0.10'
3
3
  end