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.
- checksums.yaml +4 -4
- data/.yardoc/checksums +20 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +30 -10
- data/README.md +1 -1
- data/Rakefile +8 -1
- data/bin/doing +76 -30
- data/doc/Array.html +135 -0
- data/doc/Doing/Color.html +506 -0
- data/doc/Doing/Configuration.html +680 -0
- data/doc/Doing/Errors/DoingNoTraceError.html +186 -0
- data/doc/Doing/Errors/DoingRuntimeError.html +186 -0
- data/doc/Doing/Errors/DoingStandardError.html +186 -0
- data/doc/Doing/Errors/EmptyInput.html +186 -0
- data/doc/Doing/Errors/NoResults.html +186 -0
- data/doc/Doing/Errors/PluginException.html +248 -0
- data/doc/Doing/Errors/UserCancelled.html +186 -0
- data/doc/Doing/Errors/WrongCommand.html +186 -0
- data/doc/Doing/Errors.html +191 -0
- data/doc/Doing/Hooks.html +364 -0
- data/doc/Doing/Item.html +1385 -0
- data/doc/Doing/Items.html +393 -0
- data/doc/Doing/LogAdapter.html +1650 -0
- data/doc/Doing/Note.html +535 -0
- data/doc/Doing/Pager.html +268 -0
- data/doc/Doing/Plugins.html +849 -0
- data/doc/Doing/Util.html +870 -0
- data/doc/Doing/WWID.html +4827 -0
- data/doc/Doing.html +145 -0
- data/doc/GLI/Commands/MarkdownDocumentListener.html +763 -0
- data/doc/GLI/Commands.html +115 -0
- data/doc/GLI.html +115 -0
- data/doc/Hash.html +332 -0
- data/doc/Status.html +292 -0
- data/doc/String.html +1714 -0
- data/doc/Symbol.html +250 -0
- data/doc/Time.html +182 -0
- data/doc/_index.html +411 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +497 -0
- data/doc/file.README.html +123 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +123 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1867 -0
- data/doc/top-level-namespace.html +112 -0
- data/doing.gemspec +5 -1
- data/doing.rdoc +86 -16
- data/example_plugin.rb +6 -6
- data/lib/doing/array.rb +1 -1
- data/lib/doing/configuration.rb +14 -12
- data/lib/doing/hash.rb +1 -1
- data/lib/doing/item.rb +101 -17
- data/lib/doing/log_adapter.rb +123 -113
- data/lib/doing/note.rb +1 -1
- data/lib/doing/plugin_manager.rb +5 -5
- data/lib/doing/plugins/export/csv_export.rb +1 -1
- data/lib/doing/plugins/export/template_export.rb +5 -7
- data/lib/doing/plugins/import/calendar_import.rb +1 -1
- data/lib/doing/plugins/import/doing_import.rb +4 -4
- data/lib/doing/plugins/import/timing_import.rb +5 -3
- data/lib/doing/string.rb +75 -22
- data/lib/doing/symbol.rb +9 -5
- data/lib/doing/time.rb +1 -1
- data/lib/doing/util.rb +18 -11
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +419 -326
- data/lib/doing/wwidfile.rb +5 -5
- data/lib/doing.rb +2 -1
- data/lib/examples/plugins/say_export.rb +6 -6
- data/rdocfixer.rb +1 -1
- data/yard_templates/default/method_details/setup.rb +3 -0
- metadata +117 -4
data/lib/doing/string.rb
CHANGED
@@ -2,14 +2,59 @@
|
|
2
2
|
|
3
3
|
module Doing
|
4
4
|
##
|
5
|
-
##
|
5
|
+
## String helpers
|
6
6
|
##
|
7
7
|
class ::String
|
8
8
|
include Doing::Color
|
9
|
-
|
10
|
-
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
201
|
+
## Convert a sort order string to a qualified type
|
149
202
|
##
|
150
|
-
## @return
|
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
|
-
##
|
221
|
+
## Convert a case sensitivity string to a symbol
|
169
222
|
##
|
170
|
-
## @return Symbol :smart, :sensitive, :
|
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
|
-
:
|
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
|
-
##
|
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
|
-
##
|
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
|
-
##
|
372
|
+
## Turn raw urls into HTML links
|
320
373
|
##
|
321
|
-
## @param opt
|
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
|
-
##
|
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
data/lib/doing/util.rb
CHANGED
@@ -14,9 +14,9 @@ module Doing
|
|
14
14
|
end
|
15
15
|
|
16
16
|
##
|
17
|
-
##
|
17
|
+
## Test if command line tool is available
|
18
18
|
##
|
19
|
-
## @param 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
|
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
|
-
##
|
98
|
+
## Write content to a file
|
94
99
|
##
|
95
|
-
## @param file
|
96
|
-
## @param content
|
97
|
-
## @param 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