myask 0.0.1 → 1.1.0

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 (183) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/bin/myask +1 -1
  4. data/html/App.html +116 -0
  5. data/html/MyAsk/Api/Helper.html +207 -0
  6. data/html/MyAsk/Api/Invitation.html +212 -0
  7. data/html/MyAsk/Api/Project.html +355 -0
  8. data/html/MyAsk/Api/ProjectHelper.html +299 -0
  9. data/html/MyAsk/Api/Question.html +261 -0
  10. data/html/MyAsk/Api.html +120 -0
  11. data/html/MyAsk/Config.html +195 -0
  12. data/html/MyAsk/ConfigHelper.html +251 -0
  13. data/html/MyAsk/Prompt.html +221 -0
  14. data/html/MyAsk/PromptHelper.html +330 -0
  15. data/html/MyAsk.html +114 -0
  16. data/html/README_rdoc.html +394 -0
  17. data/html/created.rid +14 -0
  18. data/html/css/fonts.css +167 -0
  19. data/html/css/rdoc.css +681 -0
  20. data/html/fonts/Lato-Light.ttf +0 -0
  21. data/html/fonts/Lato-LightItalic.ttf +0 -0
  22. data/html/fonts/Lato-Regular.ttf +0 -0
  23. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  24. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  25. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  26. data/html/images/add.png +0 -0
  27. data/html/images/arrow_up.png +0 -0
  28. data/html/images/brick.png +0 -0
  29. data/html/images/brick_link.png +0 -0
  30. data/html/images/bug.png +0 -0
  31. data/html/images/bullet_black.png +0 -0
  32. data/html/images/bullet_toggle_minus.png +0 -0
  33. data/html/images/bullet_toggle_plus.png +0 -0
  34. data/html/images/date.png +0 -0
  35. data/html/images/delete.png +0 -0
  36. data/html/images/find.png +0 -0
  37. data/html/images/loadingAnimation.gif +0 -0
  38. data/html/images/macFFBgHack.png +0 -0
  39. data/html/images/package.png +0 -0
  40. data/html/images/page_green.png +0 -0
  41. data/html/images/page_white_text.png +0 -0
  42. data/html/images/page_white_width.png +0 -0
  43. data/html/images/plugin.png +0 -0
  44. data/html/images/ruby.png +0 -0
  45. data/html/images/tag_blue.png +0 -0
  46. data/html/images/tag_green.png +0 -0
  47. data/html/images/transparent.png +0 -0
  48. data/html/images/wrench.png +0 -0
  49. data/html/images/wrench_orange.png +0 -0
  50. data/html/images/zoom.png +0 -0
  51. data/html/index.html +403 -0
  52. data/html/js/darkfish.js +120 -0
  53. data/html/js/navigation.js +105 -0
  54. data/html/js/navigation.js.gz +0 -0
  55. data/html/js/search.js +110 -0
  56. data/html/js/search_index.js +1 -0
  57. data/html/js/search_index.js.gz +0 -0
  58. data/html/js/searcher.js +229 -0
  59. data/html/js/searcher.js.gz +0 -0
  60. data/html/table_of_contents.html +257 -0
  61. data/lib/myask/prompt_helper.rb +4 -1
  62. data/lib/myask/version.rb +1 -1
  63. data/pkg/myask-0.0.1/Gemfile +10 -0
  64. data/pkg/myask-0.0.1/Gemfile.lock +70 -0
  65. data/pkg/myask-0.0.1/README.rdoc +6 -0
  66. data/pkg/myask-0.0.1/Rakefile +21 -0
  67. data/pkg/myask-0.0.1/bin/myask +101 -0
  68. data/pkg/myask-0.0.1/lib/myask/api/api_helper.rb +45 -0
  69. data/pkg/myask-0.0.1/lib/myask/api/invitation.rb +49 -0
  70. data/pkg/myask-0.0.1/lib/myask/api/project.rb +193 -0
  71. data/pkg/myask-0.0.1/lib/myask/api/project_helper.rb +46 -0
  72. data/pkg/myask-0.0.1/lib/myask/api/question.rb +99 -0
  73. data/pkg/myask-0.0.1/lib/myask/config.rb +37 -0
  74. data/pkg/myask-0.0.1/lib/myask/config_helper.rb +28 -0
  75. data/pkg/myask-0.0.1/lib/myask/prompt.rb +63 -0
  76. data/pkg/myask-0.0.1/lib/myask/prompt_helper.rb +83 -0
  77. data/pkg/myask-0.0.1/lib/myask/version.rb +3 -0
  78. data/pkg/myask-0.0.1/lib/myask.rb +28 -0
  79. data/pkg/myask-0.0.1/myask.gemspec +22 -0
  80. data/pkg/myask-0.0.1/myask.rdoc +138 -0
  81. data/pkg/myask-0.0.1/test/default_test.rb +14 -0
  82. data/pkg/myask-0.0.1/test/test_helper.rb +4 -0
  83. data/pkg/myask-0.0.1.gem +0 -0
  84. data/pkg/myask-1.0.0/Gemfile +10 -0
  85. data/pkg/myask-1.0.0/Gemfile.lock +70 -0
  86. data/pkg/myask-1.0.0/README.rdoc +6 -0
  87. data/pkg/myask-1.0.0/Rakefile +21 -0
  88. data/pkg/myask-1.0.0/bin/myask +101 -0
  89. data/pkg/myask-1.0.0/html/App.html +116 -0
  90. data/pkg/myask-1.0.0/html/MyAsk/Api/Helper.html +207 -0
  91. data/pkg/myask-1.0.0/html/MyAsk/Api/Invitation.html +212 -0
  92. data/pkg/myask-1.0.0/html/MyAsk/Api/Project.html +355 -0
  93. data/pkg/myask-1.0.0/html/MyAsk/Api/ProjectHelper.html +299 -0
  94. data/pkg/myask-1.0.0/html/MyAsk/Api/Question.html +261 -0
  95. data/pkg/myask-1.0.0/html/MyAsk/Api.html +120 -0
  96. data/pkg/myask-1.0.0/html/MyAsk/Config.html +195 -0
  97. data/pkg/myask-1.0.0/html/MyAsk/ConfigHelper.html +251 -0
  98. data/pkg/myask-1.0.0/html/MyAsk/Prompt.html +221 -0
  99. data/pkg/myask-1.0.0/html/MyAsk/PromptHelper.html +330 -0
  100. data/pkg/myask-1.0.0/html/MyAsk.html +114 -0
  101. data/pkg/myask-1.0.0/html/README_rdoc.html +394 -0
  102. data/pkg/myask-1.0.0/html/created.rid +14 -0
  103. data/pkg/myask-1.0.0/html/css/fonts.css +167 -0
  104. data/pkg/myask-1.0.0/html/css/rdoc.css +681 -0
  105. data/pkg/myask-1.0.0/html/fonts/Lato-Light.ttf +0 -0
  106. data/pkg/myask-1.0.0/html/fonts/Lato-LightItalic.ttf +0 -0
  107. data/pkg/myask-1.0.0/html/fonts/Lato-Regular.ttf +0 -0
  108. data/pkg/myask-1.0.0/html/fonts/Lato-RegularItalic.ttf +0 -0
  109. data/pkg/myask-1.0.0/html/fonts/SourceCodePro-Bold.ttf +0 -0
  110. data/pkg/myask-1.0.0/html/fonts/SourceCodePro-Regular.ttf +0 -0
  111. data/pkg/myask-1.0.0/html/images/add.png +0 -0
  112. data/pkg/myask-1.0.0/html/images/arrow_up.png +0 -0
  113. data/pkg/myask-1.0.0/html/images/brick.png +0 -0
  114. data/pkg/myask-1.0.0/html/images/brick_link.png +0 -0
  115. data/pkg/myask-1.0.0/html/images/bug.png +0 -0
  116. data/pkg/myask-1.0.0/html/images/bullet_black.png +0 -0
  117. data/pkg/myask-1.0.0/html/images/bullet_toggle_minus.png +0 -0
  118. data/pkg/myask-1.0.0/html/images/bullet_toggle_plus.png +0 -0
  119. data/pkg/myask-1.0.0/html/images/date.png +0 -0
  120. data/pkg/myask-1.0.0/html/images/delete.png +0 -0
  121. data/pkg/myask-1.0.0/html/images/find.png +0 -0
  122. data/pkg/myask-1.0.0/html/images/loadingAnimation.gif +0 -0
  123. data/pkg/myask-1.0.0/html/images/macFFBgHack.png +0 -0
  124. data/pkg/myask-1.0.0/html/images/package.png +0 -0
  125. data/pkg/myask-1.0.0/html/images/page_green.png +0 -0
  126. data/pkg/myask-1.0.0/html/images/page_white_text.png +0 -0
  127. data/pkg/myask-1.0.0/html/images/page_white_width.png +0 -0
  128. data/pkg/myask-1.0.0/html/images/plugin.png +0 -0
  129. data/pkg/myask-1.0.0/html/images/ruby.png +0 -0
  130. data/pkg/myask-1.0.0/html/images/tag_blue.png +0 -0
  131. data/pkg/myask-1.0.0/html/images/tag_green.png +0 -0
  132. data/pkg/myask-1.0.0/html/images/transparent.png +0 -0
  133. data/pkg/myask-1.0.0/html/images/wrench.png +0 -0
  134. data/pkg/myask-1.0.0/html/images/wrench_orange.png +0 -0
  135. data/pkg/myask-1.0.0/html/images/zoom.png +0 -0
  136. data/pkg/myask-1.0.0/html/index.html +403 -0
  137. data/pkg/myask-1.0.0/html/js/darkfish.js +120 -0
  138. data/pkg/myask-1.0.0/html/js/navigation.js +105 -0
  139. data/pkg/myask-1.0.0/html/js/navigation.js.gz +0 -0
  140. data/pkg/myask-1.0.0/html/js/search.js +110 -0
  141. data/pkg/myask-1.0.0/html/js/search_index.js +1 -0
  142. data/pkg/myask-1.0.0/html/js/search_index.js.gz +0 -0
  143. data/pkg/myask-1.0.0/html/js/searcher.js +229 -0
  144. data/pkg/myask-1.0.0/html/js/searcher.js.gz +0 -0
  145. data/pkg/myask-1.0.0/html/table_of_contents.html +257 -0
  146. data/pkg/myask-1.0.0/lib/myask/api/api_helper.rb +45 -0
  147. data/pkg/myask-1.0.0/lib/myask/api/invitation.rb +49 -0
  148. data/pkg/myask-1.0.0/lib/myask/api/project.rb +193 -0
  149. data/pkg/myask-1.0.0/lib/myask/api/project_helper.rb +46 -0
  150. data/pkg/myask-1.0.0/lib/myask/api/question.rb +99 -0
  151. data/pkg/myask-1.0.0/lib/myask/config.rb +37 -0
  152. data/pkg/myask-1.0.0/lib/myask/config_helper.rb +28 -0
  153. data/pkg/myask-1.0.0/lib/myask/prompt.rb +63 -0
  154. data/pkg/myask-1.0.0/lib/myask/prompt_helper.rb +83 -0
  155. data/pkg/myask-1.0.0/lib/myask/version.rb +3 -0
  156. data/pkg/myask-1.0.0/lib/myask.rb +28 -0
  157. data/pkg/myask-1.0.0/myask.gemspec +22 -0
  158. data/pkg/myask-1.0.0/myask.rdoc +138 -0
  159. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Gemfile +10 -0
  160. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Gemfile.lock +70 -0
  161. data/pkg/myask-1.0.0/pkg/myask-0.0.1/README.rdoc +6 -0
  162. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Rakefile +21 -0
  163. data/pkg/myask-1.0.0/pkg/myask-0.0.1/bin/myask +101 -0
  164. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/api_helper.rb +45 -0
  165. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/invitation.rb +49 -0
  166. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/project.rb +193 -0
  167. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/project_helper.rb +46 -0
  168. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/question.rb +99 -0
  169. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/config.rb +37 -0
  170. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/config_helper.rb +28 -0
  171. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/prompt.rb +63 -0
  172. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/prompt_helper.rb +83 -0
  173. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/version.rb +3 -0
  174. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask.rb +28 -0
  175. data/pkg/myask-1.0.0/pkg/myask-0.0.1/myask.gemspec +22 -0
  176. data/pkg/myask-1.0.0/pkg/myask-0.0.1/myask.rdoc +138 -0
  177. data/pkg/myask-1.0.0/pkg/myask-0.0.1/test/default_test.rb +14 -0
  178. data/pkg/myask-1.0.0/pkg/myask-0.0.1/test/test_helper.rb +4 -0
  179. data/pkg/myask-1.0.0/pkg/myask-0.0.1.gem +0 -0
  180. data/pkg/myask-1.0.0/test/default_test.rb +14 -0
  181. data/pkg/myask-1.0.0/test/test_helper.rb +4 -0
  182. data/pkg/myask-1.0.0.gem +0 -0
  183. metadata +179 -2
@@ -0,0 +1,110 @@
1
+ Search = function(data, input, result) {
2
+ this.data = data;
3
+ this.input = input;
4
+ this.result = result;
5
+
6
+ this.current = null;
7
+ this.view = this.result.parentNode;
8
+ this.searcher = new Searcher(data.index);
9
+ this.init();
10
+ }
11
+
12
+ Search.prototype = Object.assign({}, Navigation, new function() {
13
+ var suid = 1;
14
+
15
+ this.init = function() {
16
+ var _this = this;
17
+ var observer = function(e) {
18
+ switch(e.key) {
19
+ case 'ArrowUp':
20
+ case 'ArrowDown':
21
+ return;
22
+ }
23
+ _this.search(_this.input.value);
24
+ };
25
+ this.input.addEventListener('keyup', observer);
26
+ this.input.addEventListener('click', observer); // mac's clear field
27
+
28
+ this.searcher.ready(function(results, isLast) {
29
+ _this.addResults(results, isLast);
30
+ })
31
+
32
+ this.initNavigation();
33
+ this.setNavigationActive(false);
34
+ }
35
+
36
+ this.search = function(value, selectFirstMatch) {
37
+ value = value.trim().toLowerCase();
38
+ if (value) {
39
+ this.setNavigationActive(true);
40
+ } else {
41
+ this.setNavigationActive(false);
42
+ }
43
+
44
+ if (value == '') {
45
+ this.lastQuery = value;
46
+ this.result.innerHTML = '';
47
+ this.result.setAttribute('aria-expanded', 'false');
48
+ this.setNavigationActive(false);
49
+ } else if (value != this.lastQuery) {
50
+ this.lastQuery = value;
51
+ this.result.setAttribute('aria-busy', 'true');
52
+ this.result.setAttribute('aria-expanded', 'true');
53
+ this.firstRun = true;
54
+ this.searcher.find(value);
55
+ }
56
+ }
57
+
58
+ this.addResults = function(results, isLast) {
59
+ var target = this.result;
60
+ if (this.firstRun && (results.length > 0 || isLast)) {
61
+ this.current = null;
62
+ this.result.innerHTML = '';
63
+ }
64
+
65
+ for (var i=0, l = results.length; i < l; i++) {
66
+ var item = this.renderItem.call(this, results[i]);
67
+ item.setAttribute('id', 'search-result-' + target.childElementCount);
68
+ target.appendChild(item);
69
+ };
70
+
71
+ if (this.firstRun && results.length > 0) {
72
+ this.firstRun = false;
73
+ this.current = target.firstChild;
74
+ this.current.classList.add('search-selected');
75
+ }
76
+ //TODO: ECMAScript
77
+ //if (jQuery.browser.msie) this.$element[0].className += '';
78
+
79
+ if (isLast) this.result.setAttribute('aria-busy', 'false');
80
+ }
81
+
82
+ this.move = function(isDown) {
83
+ if (!this.current) return;
84
+ var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
85
+ if (next) {
86
+ this.current.classList.remove('search-selected');
87
+ next.classList.add('search-selected');
88
+ this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
89
+ this.scrollIntoView(next, this.view);
90
+ this.current = next;
91
+ this.input.value = next.firstChild.firstChild.text;
92
+ this.input.select();
93
+ }
94
+ return true;
95
+ }
96
+
97
+ this.hlt = function(html) {
98
+ return this.escapeHTML(html).
99
+ replace(/\u0001/g, '<em>').
100
+ replace(/\u0002/g, '</em>');
101
+ }
102
+
103
+ this.escapeHTML = function(html) {
104
+ return html.replace(/[&<>"`']/g, function(c) {
105
+ return '&#' + c.charCodeAt(0) + ';';
106
+ });
107
+ }
108
+
109
+ });
110
+
@@ -0,0 +1 @@
1
+ var search_data = {"index":{"searchIndex":["app","myask","api","helper","invitation","project","projecthelper","question","config","confighelper","prompt","prompthelper","myask","get_config()","get_initial_question()","make_request()","new()","new()","new()","new()","new()","new()","new()","new()","poll_for_response()","project_id_from_selection()","save_config()","select_project()","show_project_info()","submit_question()","readme"],"longSearchIndex":["app","myask","myask::api","myask::api::helper","myask::api::invitation","myask::api::project","myask::api::projecthelper","myask::api::question","myask::config","myask::confighelper","myask::prompt","myask::prompthelper","myask","myask::confighelper#get_config()","myask::prompthelper#get_initial_question()","myask::api::helper::make_request()","myask::api::invitation::new()","myask::api::project::new()","myask::api::projecthelper::new()","myask::api::question::new()","myask::config::new()","myask::confighelper::new()","myask::prompt::new()","myask::prompthelper::new()","myask::prompthelper#poll_for_response()","myask::api::projecthelper#project_id_from_selection()","myask::confighelper#save_config()","myask::api::projecthelper#select_project()","myask::api::projecthelper#show_project_info()","myask::prompthelper#submit_question()",""],"info":[["App","","App.html","",""],["MyAsk","","MyAsk.html","",""],["MyAsk::Api","","MyAsk/Api.html","",""],["MyAsk::Api::Helper","","MyAsk/Api/Helper.html","",""],["MyAsk::Api::Invitation","","MyAsk/Api/Invitation.html","",""],["MyAsk::Api::Project","","MyAsk/Api/Project.html","",""],["MyAsk::Api::ProjectHelper","","MyAsk/Api/ProjectHelper.html","",""],["MyAsk::Api::Question","","MyAsk/Api/Question.html","",""],["MyAsk::Config","","MyAsk/Config.html","",""],["MyAsk::ConfigHelper","","MyAsk/ConfigHelper.html","",""],["MyAsk::Prompt","","MyAsk/Prompt.html","",""],["MyAsk::PromptHelper","","MyAsk/PromptHelper.html","",""],["Myask","","Myask.html","",""],["get_config","MyAsk::ConfigHelper","MyAsk/ConfigHelper.html#method-i-get_config","()",""],["get_initial_question","MyAsk::PromptHelper","MyAsk/PromptHelper.html#method-i-get_initial_question","()",""],["make_request","MyAsk::Api::Helper","MyAsk/Api/Helper.html#method-c-make_request","(method, uri, api_key, payload = nil)",""],["new","MyAsk::Api::Invitation","MyAsk/Api/Invitation.html#method-c-new","(c)",""],["new","MyAsk::Api::Project","MyAsk/Api/Project.html#method-c-new","(c)",""],["new","MyAsk::Api::ProjectHelper","MyAsk/Api/ProjectHelper.html#method-c-new","(global_options, options, args)",""],["new","MyAsk::Api::Question","MyAsk/Api/Question.html#method-c-new","(c)",""],["new","MyAsk::Config","MyAsk/Config.html#method-c-new","(c)",""],["new","MyAsk::ConfigHelper","MyAsk/ConfigHelper.html#method-c-new","(global_options, options, args)",""],["new","MyAsk::Prompt","MyAsk/Prompt.html#method-c-new","(c)",""],["new","MyAsk::PromptHelper","MyAsk/PromptHelper.html#method-c-new","(global_options, options, args)",""],["poll_for_response","MyAsk::PromptHelper","MyAsk/PromptHelper.html#method-i-poll_for_response","(api_host, auth_token, question_id)",""],["project_id_from_selection","MyAsk::Api::ProjectHelper","MyAsk/Api/ProjectHelper.html#method-i-project_id_from_selection","()",""],["save_config","MyAsk::ConfigHelper","MyAsk/ConfigHelper.html#method-i-save_config","()",""],["select_project","MyAsk::Api::ProjectHelper","MyAsk/Api/ProjectHelper.html#method-i-select_project","(projects)",""],["show_project_info","MyAsk::Api::ProjectHelper","MyAsk/Api/ProjectHelper.html#method-i-show_project_info","(project_id)",""],["submit_question","MyAsk::PromptHelper","MyAsk/PromptHelper.html#method-i-submit_question","(api_host, auth_token, project_id, content, context_ids)",""],["README","","README_rdoc.html","","<p>myask\n<p>Describe your project here\n<p>myask - Describe your application here\n"]]}}
@@ -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
+
@@ -0,0 +1,257 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+
8
+ <title>Table of Contents - Your application title</title>
9
+
10
+ <meta name="keywords" content="ruby,documentation,Table of Contents - Your application title">
11
+
12
+
13
+ <meta name="description" content="Table of Contents - Your application title: myask Describe your project here == myask - Describe your application here v0. tt&gt; Shows a list of commands or help for one command Gets help for ">
14
+
15
+ <script type="text/javascript">
16
+ var rdoc_rel_prefix = "./";
17
+ var index_rel_prefix = "./";
18
+ </script>
19
+
20
+ <script src="./js/navigation.js" defer></script>
21
+ <script src="./js/search.js" defer></script>
22
+ <script src="./js/search_index.js" defer></script>
23
+ <script src="./js/searcher.js" defer></script>
24
+ <script src="./js/darkfish.js" defer></script>
25
+
26
+ <link href="./css/fonts.css" rel="stylesheet">
27
+ <link href="./css/rdoc.css" rel="stylesheet">
28
+
29
+
30
+ <body id="top" class="table-of-contents">
31
+ <div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
32
+ <span aria-hidden="true">&#9776;</span>
33
+ </div>
34
+
35
+
36
+ <nav id="navigation" role="navigation">
37
+ <div id="project-navigation">
38
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
39
+ <h2>
40
+ <a href="./index.html" rel="home">Home</a>
41
+ </h2>
42
+
43
+ <div id="table-of-contents-navigation">
44
+ <a href="./table_of_contents.html#pages">Pages</a>
45
+ <a href="./table_of_contents.html#classes">Classes</a>
46
+ <a href="./table_of_contents.html#methods">Methods</a>
47
+ </div>
48
+ </div>
49
+
50
+
51
+ <div id="search-section" role="search" class="project-section initially-hidden">
52
+ <form action="#" method="get" accept-charset="utf-8">
53
+ <div id="search-field-wrapper">
54
+ <input id="search-field" role="combobox" aria-label="Search"
55
+ aria-autocomplete="list" aria-controls="search-results"
56
+ type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
57
+ title="Type to search, Up and Down to navigate, Enter to load">
58
+ </div>
59
+
60
+ <ul id="search-results" aria-label="Search Results"
61
+ aria-busy="false" aria-expanded="false"
62
+ aria-atomic="false" class="initially-hidden"></ul>
63
+ </form>
64
+ </div>
65
+
66
+ </div>
67
+
68
+ <footer id="validator-badges" role="contentinfo">
69
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
70
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.13.0.
71
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
72
+ </footer>
73
+
74
+ </nav>
75
+ <main role="main">
76
+ <h1 class="class">Table of Contents - Your application title</h1>
77
+
78
+ <h2 id="pages">Pages</h2>
79
+ <ul>
80
+ <li class="file">
81
+ <a href="README_rdoc.html">README</a>
82
+
83
+ <ul>
84
+ <li><a href="README_rdoc.html#label-myask">myask</a>
85
+ <li><a href="README_rdoc.html#label-myask+-+Describe+your+application+here">myask - Describe your application here</a>
86
+ <li><a href="README_rdoc.html#label-Global+Options">Global Options</a>
87
+ <li><a href="README_rdoc.html#label--api_host+arg">–api_host arg</a>
88
+ <li><a href="README_rdoc.html#label--api_key+arg">–api_key arg</a>
89
+ <li><a href="README_rdoc.html#label--project+arg">–project arg</a>
90
+ <li><a href="README_rdoc.html#label--help">–help</a>
91
+ <li><a href="README_rdoc.html#label---5Bno--5Djson">–[no-]json</a>
92
+ <li><a href="README_rdoc.html#label---5Bno--5Dsilent">–[no-]silent</a>
93
+ <li><a href="README_rdoc.html#label--version">–version</a>
94
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
95
+ <li><a href="README_rdoc.html#label-Command-3A+config+">Command: <code>config </code></a>
96
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
97
+ <li><a href="README_rdoc.html#label-Command-3A+save+">Command: <code>save </code></a>
98
+ <li><a href="README_rdoc.html#label-Command-3A+show+">Command: <code>show </code></a>
99
+ <li><a href="README_rdoc.html#label-Command-3A+help++command">Command: <code>help command</code></a>
100
+ <li><a href="README_rdoc.html#label-Options">Options</a>
101
+ <li><a href="README_rdoc.html#label-c">-c</a>
102
+ <li><a href="README_rdoc.html#label-Command-3A+initconfig+">Command: <code>initconfig </code></a>
103
+ <li><a href="README_rdoc.html#label-Options">Options</a>
104
+ <li><a href="README_rdoc.html#label---5Bno--5Dforce">–[no-]force</a>
105
+ <li><a href="README_rdoc.html#label-Command-3A+invitation+">Command: <code>invitation </code></a>
106
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
107
+ <li><a href="README_rdoc.html#label-Command-3A+list+">Command: <code>list </code></a>
108
+ <li><a href="README_rdoc.html#label-Command-3A+send+">Command: <code>send </code></a>
109
+ <li><a href="README_rdoc.html#label-Command-3A+project+">Command: <code>project </code></a>
110
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
111
+ <li><a href="README_rdoc.html#label-Command-3A+create+">Command: <code>create </code></a>
112
+ <li><a href="README_rdoc.html#label-Command-3A+delete+">Command: <code>delete </code></a>
113
+ <li><a href="README_rdoc.html#label-Command-3A+edit++project">Command: <code>edit project</code></a>
114
+ <li><a href="README_rdoc.html#label-Command-3A+set++project">Command: <code>set project</code></a>
115
+ <li><a href="README_rdoc.html#label-Command-3A+show++project">Command: <code>show project</code></a>
116
+ <li><a href="README_rdoc.html#label-Command-3A+prompt+">Command: <code>prompt </code></a>
117
+ <li><a href="README_rdoc.html#label-Command-3A+question+">Command: <code>question </code></a>
118
+ <li><a href="README_rdoc.html#label-Commands">Commands</a>
119
+ <li><a href="README_rdoc.html#label-Command-3A+delete++question_id">Command: <code>delete question_id</code></a>
120
+ <li><a href="README_rdoc.html#label-Command-3A+show++question_id">Command: <code>show question_id</code></a>
121
+ </ul>
122
+ </li>
123
+ </ul>
124
+
125
+ <h2 id="classes">Classes and Modules</h2>
126
+ <ul>
127
+ <li class="class">
128
+ <a href="App.html">App</a>
129
+ </li>
130
+ <li class="module">
131
+ <a href="MyAsk.html">MyAsk</a>
132
+ </li>
133
+ <li class="module">
134
+ <a href="MyAsk/Api.html">MyAsk::Api</a>
135
+ </li>
136
+ <li class="class">
137
+ <a href="MyAsk/Api/Helper.html">MyAsk::Api::Helper</a>
138
+ </li>
139
+ <li class="class">
140
+ <a href="MyAsk/Api/Invitation.html">MyAsk::Api::Invitation</a>
141
+ </li>
142
+ <li class="class">
143
+ <a href="MyAsk/Api/Project.html">MyAsk::Api::Project</a>
144
+ </li>
145
+ <li class="class">
146
+ <a href="MyAsk/Api/ProjectHelper.html">MyAsk::Api::ProjectHelper</a>
147
+ </li>
148
+ <li class="class">
149
+ <a href="MyAsk/Api/Question.html">MyAsk::Api::Question</a>
150
+ </li>
151
+ <li class="class">
152
+ <a href="MyAsk/Config.html">MyAsk::Config</a>
153
+ </li>
154
+ <li class="class">
155
+ <a href="MyAsk/ConfigHelper.html">MyAsk::ConfigHelper</a>
156
+ </li>
157
+ <li class="class">
158
+ <a href="MyAsk/Prompt.html">MyAsk::Prompt</a>
159
+ </li>
160
+ <li class="class">
161
+ <a href="MyAsk/PromptHelper.html">MyAsk::PromptHelper</a>
162
+ </li>
163
+ <li class="module">
164
+ <a href="Myask.html">Myask</a>
165
+ </li>
166
+ </ul>
167
+
168
+ <h2 id="methods">Methods</h2>
169
+ <ul>
170
+
171
+ <li class="method">
172
+ <a href="MyAsk/Api/Helper.html#method-c-make_request">::make_request</a>
173
+ &mdash;
174
+ <span class="container">MyAsk::Api::Helper</span>
175
+
176
+ <li class="method">
177
+ <a href="MyAsk/Api/Invitation.html#method-c-new">::new</a>
178
+ &mdash;
179
+ <span class="container">MyAsk::Api::Invitation</span>
180
+
181
+ <li class="method">
182
+ <a href="MyAsk/Api/Project.html#method-c-new">::new</a>
183
+ &mdash;
184
+ <span class="container">MyAsk::Api::Project</span>
185
+
186
+ <li class="method">
187
+ <a href="MyAsk/Api/ProjectHelper.html#method-c-new">::new</a>
188
+ &mdash;
189
+ <span class="container">MyAsk::Api::ProjectHelper</span>
190
+
191
+ <li class="method">
192
+ <a href="MyAsk/Config.html#method-c-new">::new</a>
193
+ &mdash;
194
+ <span class="container">MyAsk::Config</span>
195
+
196
+ <li class="method">
197
+ <a href="MyAsk/Api/Question.html#method-c-new">::new</a>
198
+ &mdash;
199
+ <span class="container">MyAsk::Api::Question</span>
200
+
201
+ <li class="method">
202
+ <a href="MyAsk/ConfigHelper.html#method-c-new">::new</a>
203
+ &mdash;
204
+ <span class="container">MyAsk::ConfigHelper</span>
205
+
206
+ <li class="method">
207
+ <a href="MyAsk/Prompt.html#method-c-new">::new</a>
208
+ &mdash;
209
+ <span class="container">MyAsk::Prompt</span>
210
+
211
+ <li class="method">
212
+ <a href="MyAsk/PromptHelper.html#method-c-new">::new</a>
213
+ &mdash;
214
+ <span class="container">MyAsk::PromptHelper</span>
215
+
216
+ <li class="method">
217
+ <a href="MyAsk/ConfigHelper.html#method-i-get_config">#get_config</a>
218
+ &mdash;
219
+ <span class="container">MyAsk::ConfigHelper</span>
220
+
221
+ <li class="method">
222
+ <a href="MyAsk/PromptHelper.html#method-i-get_initial_question">#get_initial_question</a>
223
+ &mdash;
224
+ <span class="container">MyAsk::PromptHelper</span>
225
+
226
+ <li class="method">
227
+ <a href="MyAsk/PromptHelper.html#method-i-poll_for_response">#poll_for_response</a>
228
+ &mdash;
229
+ <span class="container">MyAsk::PromptHelper</span>
230
+
231
+ <li class="method">
232
+ <a href="MyAsk/Api/ProjectHelper.html#method-i-project_id_from_selection">#project_id_from_selection</a>
233
+ &mdash;
234
+ <span class="container">MyAsk::Api::ProjectHelper</span>
235
+
236
+ <li class="method">
237
+ <a href="MyAsk/ConfigHelper.html#method-i-save_config">#save_config</a>
238
+ &mdash;
239
+ <span class="container">MyAsk::ConfigHelper</span>
240
+
241
+ <li class="method">
242
+ <a href="MyAsk/Api/ProjectHelper.html#method-i-select_project">#select_project</a>
243
+ &mdash;
244
+ <span class="container">MyAsk::Api::ProjectHelper</span>
245
+
246
+ <li class="method">
247
+ <a href="MyAsk/Api/ProjectHelper.html#method-i-show_project_info">#show_project_info</a>
248
+ &mdash;
249
+ <span class="container">MyAsk::Api::ProjectHelper</span>
250
+
251
+ <li class="method">
252
+ <a href="MyAsk/PromptHelper.html#method-i-submit_question">#submit_question</a>
253
+ &mdash;
254
+ <span class="container">MyAsk::PromptHelper</span>
255
+ </ul>
256
+ </main>
257
+
@@ -0,0 +1,45 @@
1
+ module MyAsk
2
+ module Api
3
+ class Helper
4
+
5
+ def self.make_request(method, uri, api_key, payload = nil)
6
+ http = Net::HTTP.new(uri.host, uri.port)
7
+ http.use_ssl = true if uri.scheme == 'https'
8
+
9
+ if method == "Get"
10
+ request = Net::HTTP::Get.new(uri.request_uri)
11
+ request['Authorization'] = "Bearer #{api_key}"
12
+ request["Content-Type"] = "application/json"
13
+ response = http.request(request)
14
+ elsif method == "Delete"
15
+ request = Net::HTTP::Delete.new(uri.request_uri)
16
+ request['Authorization'] = "Bearer #{api_key}"
17
+ request["Content-Type"] = "application/json"
18
+ request.body = payload.to_json
19
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
20
+ http.request(request)
21
+ end
22
+ elsif method == "Patch"
23
+ request = Net::HTTP::Patch.new(uri.request_uri)
24
+ request['Authorization'] = "Bearer #{api_key}"
25
+ request["Content-Type"] = "application/json"
26
+ request.body = payload.to_json
27
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
28
+ http.request(request)
29
+ end
30
+ else
31
+ request = Net::HTTP::Post.new(uri.request_uri)
32
+ request['Authorization'] = "Bearer #{api_key}"
33
+ request["Content-Type"] = "application/json"
34
+ request.body = payload.to_json
35
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
36
+ http.request(request)
37
+ end
38
+ end
39
+
40
+ response
41
+ end
42
+
43
+ end
44
+ end
45
+ end