hookapp 2.0.7 → 2.0.8

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS.md +4 -0
  3. data/CHANGELOG.md +5 -0
  4. data/LICENSE +21 -0
  5. data/README.md +31 -21
  6. data/bin/hook +57 -67
  7. data/hook.rdoc +15 -10
  8. data/html/App.html +107 -0
  9. data/html/GLI/Commands/Doc.html +91 -0
  10. data/html/GLI/Commands/MarkdownDocumentListener.html +521 -0
  11. data/html/GLI/Commands.html +91 -0
  12. data/html/GLI.html +91 -0
  13. data/html/Hook.html +100 -0
  14. data/html/HookApp.html +1002 -0
  15. data/html/Hooker.html +141 -0
  16. data/html/README_rdoc.html +354 -0
  17. data/html/String.html +335 -0
  18. data/html/created.rid +9 -0
  19. data/html/css/fonts.css +167 -0
  20. data/html/css/rdoc.css +639 -0
  21. data/html/fonts/Lato-Light.ttf +0 -0
  22. data/html/fonts/Lato-LightItalic.ttf +0 -0
  23. data/html/fonts/Lato-Regular.ttf +0 -0
  24. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  25. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  26. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  27. data/html/images/add.png +0 -0
  28. data/html/images/arrow_up.png +0 -0
  29. data/html/images/brick.png +0 -0
  30. data/html/images/brick_link.png +0 -0
  31. data/html/images/bug.png +0 -0
  32. data/html/images/bullet_black.png +0 -0
  33. data/html/images/bullet_toggle_minus.png +0 -0
  34. data/html/images/bullet_toggle_plus.png +0 -0
  35. data/html/images/date.png +0 -0
  36. data/html/images/delete.png +0 -0
  37. data/html/images/find.png +0 -0
  38. data/html/images/loadingAnimation.gif +0 -0
  39. data/html/images/macFFBgHack.png +0 -0
  40. data/html/images/package.png +0 -0
  41. data/html/images/page_green.png +0 -0
  42. data/html/images/page_white_text.png +0 -0
  43. data/html/images/page_white_width.png +0 -0
  44. data/html/images/plugin.png +0 -0
  45. data/html/images/ruby.png +0 -0
  46. data/html/images/tag_blue.png +0 -0
  47. data/html/images/tag_green.png +0 -0
  48. data/html/images/transparent.png +0 -0
  49. data/html/images/wrench.png +0 -0
  50. data/html/images/wrench_orange.png +0 -0
  51. data/html/images/zoom.png +0 -0
  52. data/html/index.html +317 -0
  53. data/html/js/darkfish.js +84 -0
  54. data/html/js/navigation.js +105 -0
  55. data/html/js/navigation.js.gz +0 -0
  56. data/html/js/search.js +110 -0
  57. data/html/js/search_index.js +1 -0
  58. data/html/js/search_index.js.gz +0 -0
  59. data/html/js/searcher.js +229 -0
  60. data/html/js/searcher.js.gz +0 -0
  61. data/html/table_of_contents.html +365 -0
  62. data/lib/hook/hookapp.rb +9 -10
  63. data/lib/hook/markdown_document_listener.rb +12 -2
  64. data/lib/hook/version.rb +1 -1
  65. data/test/hook_scripts_test.rb +1 -1
  66. metadata +58 -2
@@ -0,0 +1,229 @@
1
+ Searcher = function(data) {
2
+ this.data = data;
3
+ this.handlers = [];
4
+ }
5
+
6
+ Searcher.prototype = new function() {
7
+ // search is performed in chunks of 1000 for non-blocking user input
8
+ var CHUNK_SIZE = 1000;
9
+ // do not try to find more than 100 results
10
+ var MAX_RESULTS = 100;
11
+ var huid = 1;
12
+ var suid = 1;
13
+ var runs = 0;
14
+
15
+ this.find = function(query) {
16
+ var queries = splitQuery(query);
17
+ var regexps = buildRegexps(queries);
18
+ var highlighters = buildHilighters(queries);
19
+ var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
+ var _this = this;
21
+
22
+ this.currentSuid = state.n;
23
+
24
+ if (!query) return;
25
+
26
+ var run = function() {
27
+ // stop current search thread if new search started
28
+ if (state.n != _this.currentSuid) return;
29
+
30
+ var results =
31
+ performSearch(_this.data, regexps, queries, highlighters, state);
32
+ var hasMore = (state.limit > 0 && state.pass < 4);
33
+
34
+ triggerResults.call(_this, results, !hasMore);
35
+ if (hasMore) {
36
+ setTimeout(run, 2);
37
+ }
38
+ runs++;
39
+ };
40
+ runs = 0;
41
+
42
+ // start search thread
43
+ run();
44
+ }
45
+
46
+ /* ----- Events ------ */
47
+ this.ready = function(fn) {
48
+ fn.huid = huid;
49
+ this.handlers.push(fn);
50
+ }
51
+
52
+ /* ----- Utilities ------ */
53
+ function splitQuery(query) {
54
+ return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
55
+ return string.match(/\S/);
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ return queries.map(function(query) {
61
+ return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
62
+ });
63
+ }
64
+
65
+ function buildHilighters(queries) {
66
+ return queries.map(function(query) {
67
+ return query.split('').map(function(l, i) {
68
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
+ }).join('');
70
+ });
71
+ }
72
+
73
+ // function longMatchRegexp(index, longIndex, regexps) {
74
+ // for (var i = regexps.length - 1; i >= 0; i--){
75
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
+ // };
77
+ // return true;
78
+ // }
79
+
80
+
81
+ /* ----- Mathchers ------ */
82
+
83
+ /*
84
+ * This record matches if the index starts with queries[0] and the record
85
+ * matches all of the regexps
86
+ */
87
+ function matchPassBeginning(index, longIndex, queries, regexps) {
88
+ if (index.indexOf(queries[0]) != 0) return false;
89
+ for (var i=1, l = regexps.length; i < l; i++) {
90
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
+ return false;
92
+ };
93
+ return true;
94
+ }
95
+
96
+ /*
97
+ * This record matches if the longIndex starts with queries[0] and the
98
+ * longIndex matches all of the regexps
99
+ */
100
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
101
+ if (longIndex.indexOf(queries[0]) != 0) return false;
102
+ for (var i=1, l = regexps.length; i < l; i++) {
103
+ if (!longIndex.match(regexps[i]))
104
+ return false;
105
+ };
106
+ return true;
107
+ }
108
+
109
+ /*
110
+ * This record matches if the index contains queries[0] and the record
111
+ * matches all of the regexps
112
+ */
113
+ function matchPassContains(index, longIndex, queries, regexps) {
114
+ if (index.indexOf(queries[0]) == -1) return false;
115
+ for (var i=1, l = regexps.length; i < l; i++) {
116
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
+ return false;
118
+ };
119
+ return true;
120
+ }
121
+
122
+ /*
123
+ * This record matches if regexps[0] matches the index and the record
124
+ * matches all of the regexps
125
+ */
126
+ function matchPassRegexp(index, longIndex, queries, regexps) {
127
+ if (!index.match(regexps[0])) return false;
128
+ for (var i=1, l = regexps.length; i < l; i++) {
129
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
+ return false;
131
+ };
132
+ return true;
133
+ }
134
+
135
+
136
+ /* ----- Highlighters ------ */
137
+ function highlightRegexp(info, queries, regexps, highlighters) {
138
+ var result = createResult(info);
139
+ for (var i=0, l = regexps.length; i < l; i++) {
140
+ result.title = result.title.replace(regexps[i], highlighters[i]);
141
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
+ };
143
+ return result;
144
+ }
145
+
146
+ function hltSubstring(string, pos, length) {
147
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
+ }
149
+
150
+ function highlightQuery(info, queries, regexps, highlighters) {
151
+ var result = createResult(info);
152
+ var pos = 0;
153
+ var lcTitle = result.title.toLowerCase();
154
+
155
+ pos = lcTitle.indexOf(queries[0]);
156
+ if (pos != -1) {
157
+ result.title = hltSubstring(result.title, pos, queries[0].length);
158
+ }
159
+
160
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ result.title = result.title.replace(regexps[i], highlighters[i]);
163
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
+ };
165
+ return result;
166
+ }
167
+
168
+ function createResult(info) {
169
+ var result = {};
170
+ result.title = info[0];
171
+ result.namespace = info[1];
172
+ result.path = info[2];
173
+ result.params = info[3];
174
+ result.snippet = info[4];
175
+ result.badge = info[6];
176
+ return result;
177
+ }
178
+
179
+ /* ----- Searching ------ */
180
+ function performSearch(data, regexps, queries, highlighters, state) {
181
+ var searchIndex = data.searchIndex;
182
+ var longSearchIndex = data.longSearchIndex;
183
+ var info = data.info;
184
+ var result = [];
185
+ var i = state.from;
186
+ var l = searchIndex.length;
187
+ var togo = CHUNK_SIZE;
188
+ var matchFunc, hltFunc;
189
+
190
+ while (state.pass < 4 && state.limit > 0 && togo > 0) {
191
+ if (state.pass == 0) {
192
+ matchFunc = matchPassBeginning;
193
+ hltFunc = highlightQuery;
194
+ } else if (state.pass == 1) {
195
+ matchFunc = matchPassLongIndex;
196
+ hltFunc = highlightQuery;
197
+ } else if (state.pass == 2) {
198
+ matchFunc = matchPassContains;
199
+ hltFunc = highlightQuery;
200
+ } else if (state.pass == 3) {
201
+ matchFunc = matchPassRegexp;
202
+ hltFunc = highlightRegexp;
203
+ }
204
+
205
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
206
+ if (info[i].n == state.n) continue;
207
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
208
+ info[i].n = state.n;
209
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
210
+ state.limit--;
211
+ }
212
+ };
213
+ if (searchIndex.length <= i) {
214
+ state.pass++;
215
+ i = state.from = 0;
216
+ } else {
217
+ state.from = i;
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+
223
+ function triggerResults(results, isLast) {
224
+ this.handlers.forEach(function(fn) {
225
+ fn.call(this, results, isLast)
226
+ });
227
+ }
228
+ }
229
+
Binary file
@@ -0,0 +1,365 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>Table of Contents - hookapp</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" class="table-of-contents">
25
+ <main role="main">
26
+ <h1 class="class">Table of Contents - hookapp</h1>
27
+
28
+ <h2 id="pages">Pages</h2>
29
+ <ul>
30
+ <li class="file">
31
+ <a href="README_rdoc.html">README</a>
32
+
33
+ <ul>
34
+ <li><a href="README_rdoc.html#label-hookapp">hookapp</a>
35
+ <li><a href="README_rdoc.html#label-hook+-+CLI+interface+for+Hook.app+-28macOS-29">hook - CLI interface for Hook.app (macOS)</a>
36
+ <li><a href="README_rdoc.html#label-Global+Options">Global Options</a>
37
+ <li><a href="README_rdoc.html#label--help">–help</a>
38
+ <li><a href="README_rdoc.html#label--version">–version</a>
39
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
40
+ <li><a href="README_rdoc.html#label-Command-3A+clip-7Ccp++FILE_OR_URL">Command: <code>clip|cp FILE_OR_URL</code></a>
41
+ <li><a href="README_rdoc.html#label-Options">Options</a>
42
+ <li><a href="README_rdoc.html#label-a-7C--app+APP_NAME">-a|–app APP_NAME</a>
43
+ <li><a href="README_rdoc.html#label-m-7C--markdown">-m|–markdown</a>
44
+ <li><a href="README_rdoc.html#label-Command-3A+clone++SOURCE+TARGET">Command: <code>clone SOURCE TARGET</code></a>
45
+ <li><a href="README_rdoc.html#label-Command-3A+find-7Csearch++-5BSEARCH_STRING-5D">Command: <code>find|search [SEARCH_STRING]</code></a>
46
+ <li><a href="README_rdoc.html#label-Options">Options</a>
47
+ <li><a href="README_rdoc.html#label-o-7C--output_format+FORMAT">-o|–output_format FORMAT</a>
48
+ <li><a href="README_rdoc.html#label-f-7C--files_only">-f|–files_only</a>
49
+ <li><a href="README_rdoc.html#label-n-7C--names_only">-n|–names_only</a>
50
+ <li><a href="README_rdoc.html#label--null">–null</a>
51
+ <li><a href="README_rdoc.html#label-Command-3A+from++APPLICATION_NAME">Command: <code>from APPLICATION_NAME</code></a>
52
+ <li><a href="README_rdoc.html#label-Options">Options</a>
53
+ <li><a href="README_rdoc.html#label-c-7C--copy">-c|–copy</a>
54
+ <li><a href="README_rdoc.html#label-m-7C--markdown">-m|–markdown</a>
55
+ <li><a href="README_rdoc.html#label-Command-3A+help++command">Command: <code>help command</code></a>
56
+ <li><a href="README_rdoc.html#label-Options">Options</a>
57
+ <li><a href="README_rdoc.html#label-c">-c</a>
58
+ <li><a href="README_rdoc.html#label-Command-3A+link-7Cln++SOURCE...+TARGET">Command: <code>link|ln SOURCE... TARGET</code></a>
59
+ <li><a href="README_rdoc.html#label-Options">Options</a>
60
+ <li><a href="README_rdoc.html#label-a-7C--all">-a|–all</a>
61
+ <li><a href="README_rdoc.html#label-p-7C--paste">-p|–paste</a>
62
+ <li><a href="README_rdoc.html#label-Command-3A+list-7Cls++-5BFILE_OR_URL-5D...">Command: <code>list|ls [FILE_OR_URL]...</code></a>
63
+ <li><a href="README_rdoc.html#label-Options">Options</a>
64
+ <li><a href="README_rdoc.html#label-o-7C--output_format+FORMAT">-o|–output_format FORMAT</a>
65
+ <li><a href="README_rdoc.html#label-f-7C--files_only">-f|–files_only</a>
66
+ <li><a href="README_rdoc.html#label--null">–null</a>
67
+ <li><a href="README_rdoc.html#label-s-7C--select">-<a href="no-">s|–</a>select</a>
68
+ <li><a href="README_rdoc.html#label-Command-3A+open-7Cgui++FILE_OR_URL">Command: <code>open|gui FILE_OR_URL</code></a>
69
+ <li><a href="README_rdoc.html#label-Command-3A+percent++STRING">Command: <code>percent STRING</code></a>
70
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
71
+ <li><a href="README_rdoc.html#label-Command-3A+decode++STRING">Command: <code>decode STRING</code></a>
72
+ <li><a href="README_rdoc.html#label-Command-3A+encode++STRING">Command: <code>encode STRING</code></a>
73
+ <li><a href="README_rdoc.html#label-Command-3A+remove-7Crm++FILE_OR_URL...">Command: <code>remove|rm FILE_OR_URL...</code></a>
74
+ <li><a href="README_rdoc.html#label-Options">Options</a>
75
+ <li><a href="README_rdoc.html#label-a-7C--all">-a|–all</a>
76
+ <li><a href="README_rdoc.html#label-f-7C--force">-f|–force</a>
77
+ <li><a href="README_rdoc.html#label-Command-3A+scripts++SHELL">Command: <code>scripts SHELL</code></a>
78
+ <li><a href="README_rdoc.html#label-Command-3A+select++FILE_OR_URL">Command: <code>select FILE_OR_URL</code></a>
79
+ </ul>
80
+ </li>
81
+ </ul>
82
+
83
+ <h2 id="classes">Classes and Modules</h2>
84
+ <ul>
85
+ <li class="class">
86
+ <a href="App.html">App</a>
87
+ </li>
88
+ <li class="module">
89
+ <a href="GLI.html">GLI</a>
90
+ </li>
91
+ <li class="module">
92
+ <a href="GLI/Commands.html">GLI::Commands</a>
93
+ </li>
94
+ <li class="module">
95
+ <a href="GLI/Commands/Doc.html">GLI::Commands::Doc</a>
96
+ </li>
97
+ <li class="class">
98
+ <a href="GLI/Commands/MarkdownDocumentListener.html">GLI::Commands::MarkdownDocumentListener</a>
99
+ </li>
100
+ <li class="module">
101
+ <a href="Hook.html">Hook</a>
102
+ </li>
103
+ <li class="class">
104
+ <a href="HookApp.html">HookApp</a>
105
+ </li>
106
+ <li class="class">
107
+ <a href="Hooker.html">Hooker</a>
108
+ </li>
109
+ <li class="class">
110
+ <a href="String.html">String</a>
111
+ </li>
112
+ </ul>
113
+
114
+ <h2 id="methods">Methods</h2>
115
+ <ul>
116
+
117
+ <li class="method">
118
+ <a href="Hooker.html#method-c-new">::new</a>
119
+ &mdash;
120
+ <span class="container">Hooker</span>
121
+
122
+ <li class="method">
123
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-c-new">::new</a>
124
+ &mdash;
125
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
126
+
127
+ <li class="method">
128
+ <a href="HookApp.html#method-i-all_bookmarks">#all_bookmarks</a>
129
+ &mdash;
130
+ <span class="container">HookApp</span>
131
+
132
+ <li class="method">
133
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-beginning">#beginning</a>
134
+ &mdash;
135
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
136
+
137
+ <li class="method">
138
+ <a href="HookApp.html#method-i-bookmark_for">#bookmark_for</a>
139
+ &mdash;
140
+ <span class="container">HookApp</span>
141
+
142
+ <li class="method">
143
+ <a href="HookApp.html#method-i-bookmark_from_app">#bookmark_from_app</a>
144
+ &mdash;
145
+ <span class="container">HookApp</span>
146
+
147
+ <li class="method">
148
+ <a href="String.html#method-i-cap">#cap</a>
149
+ &mdash;
150
+ <span class="container">String</span>
151
+
152
+ <li class="method">
153
+ <a href="String.html#method-i-cap-21">#cap!</a>
154
+ &mdash;
155
+ <span class="container">String</span>
156
+
157
+ <li class="method">
158
+ <a href="String.html#method-i-clip">#clip</a>
159
+ &mdash;
160
+ <span class="container">String</span>
161
+
162
+ <li class="method">
163
+ <a href="HookApp.html#method-i-clip_bookmark">#clip_bookmark</a>
164
+ &mdash;
165
+ <span class="container">HookApp</span>
166
+
167
+ <li class="method">
168
+ <a href="HookApp.html#method-i-clone_hooks">#clone_hooks</a>
169
+ &mdash;
170
+ <span class="container">HookApp</span>
171
+
172
+ <li class="method">
173
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-command">#command</a>
174
+ &mdash;
175
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
176
+
177
+ <li class="method">
178
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-commands">#commands</a>
179
+ &mdash;
180
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
181
+
182
+ <li class="method">
183
+ <a href="HookApp.html#method-i-copy_bookmark">#copy_bookmark</a>
184
+ &mdash;
185
+ <span class="container">HookApp</span>
186
+
187
+ <li class="method">
188
+ <a href="HookApp.html#method-i-decode">#decode</a>
189
+ &mdash;
190
+ <span class="container">HookApp</span>
191
+
192
+ <li class="method">
193
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-default_command">#default_command</a>
194
+ &mdash;
195
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
196
+
197
+ <li class="method">
198
+ <a href="HookApp.html#method-i-delete_all_hooks">#delete_all_hooks</a>
199
+ &mdash;
200
+ <span class="container">HookApp</span>
201
+
202
+ <li class="method">
203
+ <a href="HookApp.html#method-i-delete_hooks">#delete_hooks</a>
204
+ &mdash;
205
+ <span class="container">HookApp</span>
206
+
207
+ <li class="method">
208
+ <a href="HookApp.html#method-i-encode">#encode</a>
209
+ &mdash;
210
+ <span class="container">HookApp</span>
211
+
212
+ <li class="method">
213
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-end_command">#end_command</a>
214
+ &mdash;
215
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
216
+
217
+ <li class="method">
218
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-end_commands">#end_commands</a>
219
+ &mdash;
220
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
221
+
222
+ <li class="method">
223
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-end_options">#end_options</a>
224
+ &mdash;
225
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
226
+
227
+ <li class="method">
228
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-ending">#ending</a>
229
+ &mdash;
230
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
231
+
232
+ <li class="method">
233
+ <a href="String.html#method-i-escape_quotes">#escape_quotes</a>
234
+ &mdash;
235
+ <span class="container">String</span>
236
+
237
+ <li class="method">
238
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-flag">#flag</a>
239
+ &mdash;
240
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
241
+
242
+ <li class="method">
243
+ <a href="HookApp.html#method-i-format_regex">#format_regex</a>
244
+ &mdash;
245
+ <span class="container">HookApp</span>
246
+
247
+ <li class="method">
248
+ <a href="HookApp.html#method-i-get_hooks">#get_hooks</a>
249
+ &mdash;
250
+ <span class="container">HookApp</span>
251
+
252
+ <li class="method">
253
+ <a href="HookApp.html#method-i-link_all">#link_all</a>
254
+ &mdash;
255
+ <span class="container">HookApp</span>
256
+
257
+ <li class="method">
258
+ <a href="HookApp.html#method-i-link_files">#link_files</a>
259
+ &mdash;
260
+ <span class="container">HookApp</span>
261
+
262
+ <li class="method">
263
+ <a href="HookApp.html#method-i-linked_bookmarks">#linked_bookmarks</a>
264
+ &mdash;
265
+ <span class="container">HookApp</span>
266
+
267
+ <li class="method">
268
+ <a href="String.html#method-i-nil_if_missing">#nil_if_missing</a>
269
+ &mdash;
270
+ <span class="container">String</span>
271
+
272
+ <li class="method">
273
+ <a href="HookApp.html#method-i-open_gui">#open_gui</a>
274
+ &mdash;
275
+ <span class="container">HookApp</span>
276
+
277
+ <li class="method">
278
+ <a href="HookApp.html#method-i-open_linked">#open_linked</a>
279
+ &mdash;
280
+ <span class="container">HookApp</span>
281
+
282
+ <li class="method">
283
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-options">#options</a>
284
+ &mdash;
285
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
286
+
287
+ <li class="method">
288
+ <a href="HookApp.html#method-i-output_array">#output_array</a>
289
+ &mdash;
290
+ <span class="container">HookApp</span>
291
+
292
+ <li class="method">
293
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-program_desc">#program_desc</a>
294
+ &mdash;
295
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
296
+
297
+ <li class="method">
298
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-program_long_desc">#program_long_desc</a>
299
+ &mdash;
300
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
301
+
302
+ <li class="method">
303
+ <a href="HookApp.html#method-i-search_bookmarks">#search_bookmarks</a>
304
+ &mdash;
305
+ <span class="container">HookApp</span>
306
+
307
+ <li class="method">
308
+ <a href="HookApp.html#method-i-search_name">#search_name</a>
309
+ &mdash;
310
+ <span class="container">HookApp</span>
311
+
312
+ <li class="method">
313
+ <a href="HookApp.html#method-i-search_path_or_address">#search_path_or_address</a>
314
+ &mdash;
315
+ <span class="container">HookApp</span>
316
+
317
+ <li class="method">
318
+ <a href="HookApp.html#method-i-select_hook">#select_hook</a>
319
+ &mdash;
320
+ <span class="container">HookApp</span>
321
+
322
+ <li class="method">
323
+ <a href="String.html#method-i-split_hook">#split_hook</a>
324
+ &mdash;
325
+ <span class="container">String</span>
326
+
327
+ <li class="method">
328
+ <a href="String.html#method-i-split_hooks">#split_hooks</a>
329
+ &mdash;
330
+ <span class="container">String</span>
331
+
332
+ <li class="method">
333
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-switch">#switch</a>
334
+ &mdash;
335
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
336
+
337
+ <li class="method">
338
+ <a href="String.html#method-i-valid_hook">#valid_hook</a>
339
+ &mdash;
340
+ <span class="container">String</span>
341
+
342
+ <li class="method">
343
+ <a href="String.html#method-i-valid_hook-21">#valid_hook!</a>
344
+ &mdash;
345
+ <span class="container">String</span>
346
+
347
+ <li class="method">
348
+ <a href="HookApp.html#method-i-validate_format">#validate_format</a>
349
+ &mdash;
350
+ <span class="container">HookApp</span>
351
+
352
+ <li class="method">
353
+ <a href="GLI/Commands/MarkdownDocumentListener.html#method-i-version">#version</a>
354
+ &mdash;
355
+ <span class="container">GLI::Commands::MarkdownDocumentListener</span>
356
+ </ul>
357
+ </main>
358
+
359
+
360
+ <footer id="validator-badges" role="contentinfo">
361
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
362
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.2.
363
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
364
+ </footer>
365
+
data/lib/hook/hookapp.rb CHANGED
@@ -233,7 +233,8 @@ class HookApp
233
233
  raise "Error processing available hooks" if options.empty?
234
234
 
235
235
  args = ['--layout=reverse-list',
236
- '--header="esc: cancel, tab: multi-select, return: open > "',
236
+ '--header="esc: cancel, tab: multi-select, ctrl-a: select all, return: open"',
237
+ '--bind ctrl-a:select-all',
237
238
  '--prompt=" Select hooks > "',
238
239
  '--multi',
239
240
  '--tabstop=4',
@@ -246,16 +247,12 @@ class HookApp
246
247
  fzf = File.join(File.dirname(__FILE__), '../helpers/fuzzyfilefinder')
247
248
 
248
249
  sel = `echo #{Shellwords.escape(options.join("\n"))} | '#{fzf}' #{args.join(' ')}`.chomp
249
- res = sel.split(/\n/).map { |s|
250
+ res = sel.split(/\n/).map do |s|
250
251
  ps = s.split(/\t/)
251
252
  { name: ps[0], path: ps[1], url: ps[2] }
252
- }
253
-
254
- if res.size == 0
255
- raise 'Cancelled (empty response)'
256
253
  end
257
254
 
258
- res
255
+ res || []
259
256
  end
260
257
 
261
258
  # Open the Hook GUI for browsing/performing actions on a file or url
@@ -281,9 +278,11 @@ class HookApp
281
278
  warn "No hooks found for #{url}"
282
279
  else
283
280
  res = select_hook(marks)
284
- res.each {|mark|
285
- `open '#{mark[:url]}'`
286
- }
281
+ unless res.empty?
282
+ res.each {|mark|
283
+ `open '#{mark[:url]}'`
284
+ }
285
+ end
287
286
  end
288
287
  end
289
288
 
@@ -15,6 +15,7 @@ module GLI
15
15
  @io = File.new('README.md', 'w')
16
16
  @nest = '#'
17
17
  @arg_name_formatter = GLI::Commands::HelpModules::ArgNameFormatter.new
18
+ @parent_command = []
18
19
  end
19
20
 
20
21
  def beginning
@@ -26,6 +27,12 @@ module GLI
26
27
  @io.puts IO.read('CREDITS.md')
27
28
  @io.puts
28
29
  end
30
+
31
+ if File.exist?('AUTHORS.md')
32
+ @io.puts IO.read('AUTHORS.md')
33
+ @io.puts
34
+ end
35
+
29
36
  if File.exist?('LICENSE.md')
30
37
  @io.puts IO.read('LICENSE.md')
31
38
  @io.puts
@@ -89,7 +96,7 @@ module GLI
89
96
  name = "[no-]#{name}" if name.to_s.length > 1
90
97
  aliases = aliases.map { |_| _.to_s.length > 1 ? "[no-]#{_}" : _ }
91
98
  end
92
- invocations = ([name] + aliases).map { |_| "`" + add_dashes(_) + "`" }.join('|')
99
+ invocations = ([name] + aliases).map { |_| "`" + add_dashes(_).strip + "`" }.join('|')
93
100
  @io.puts header("#{invocations}", 2)
94
101
  @io.puts
95
102
  @io.puts String(desc).strip
@@ -109,8 +116,10 @@ module GLI
109
116
 
110
117
  # Gives you a command in the current context and creates a new context of this command
111
118
  def command(name, aliases, desc, long_desc, arg_name, arg_options)
119
+ @parent_command.push ([name] + aliases).join('|')
112
120
  arg_name_fmt = @arg_name_formatter.format(arg_name, arg_options, [])
113
- @io.puts header("`$ #{@exe}` <mark>`#{([name] + aliases).join('|')}`</mark> `#{arg_name_fmt}`", 1)
121
+ arg_name_fmt = " `#{arg_name_fmt.strip}`" if arg_name_fmt
122
+ @io.puts header("`$ #{@exe}` <mark>`#{@parent_command.join(' ')}`</mark>#{arg_name_fmt}", 1)
114
123
  @io.puts
115
124
  @io.puts "*#{String(desc).strip}*"
116
125
  @io.puts
@@ -121,6 +130,7 @@ module GLI
121
130
 
122
131
  # Ends a command, and "pops" you back up one context
123
132
  def end_command(_name)
133
+ @parent_command.pop
124
134
  decrement_nest
125
135
  @io.puts "* * * * * *\n\n" unless @nest.size > 2
126
136
  end