command_proposal 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +77 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/command_proposal_manifest.js +1 -0
  6. data/app/assets/javascripts/command_proposal/_codemirror.js +9814 -0
  7. data/app/assets/javascripts/command_proposal/_helpers.js +9 -0
  8. data/app/assets/javascripts/command_proposal/codemirror-addon-searchcursor.js +296 -0
  9. data/app/assets/javascripts/command_proposal/codemirror-keymap-sublime.js +720 -0
  10. data/app/assets/javascripts/command_proposal/codemirror-mode-ruby.js +303 -0
  11. data/app/assets/javascripts/command_proposal/console.js +195 -0
  12. data/app/assets/javascripts/command_proposal/feed.js +51 -0
  13. data/app/assets/javascripts/command_proposal/terminal.js +40 -0
  14. data/app/assets/javascripts/command_proposal.js +1 -0
  15. data/app/assets/stylesheets/command_proposal/_variables.scss +0 -0
  16. data/app/assets/stylesheets/command_proposal/codemirror-rubyblue.scss +27 -0
  17. data/app/assets/stylesheets/command_proposal/codemirror.scss +367 -0
  18. data/app/assets/stylesheets/command_proposal/command_proposal.scss +1 -0
  19. data/app/assets/stylesheets/command_proposal/components.scss +31 -0
  20. data/app/assets/stylesheets/command_proposal/containers.scss +4 -0
  21. data/app/assets/stylesheets/command_proposal/icons.scss +12 -0
  22. data/app/assets/stylesheets/command_proposal/tables.scss +76 -0
  23. data/app/assets/stylesheets/command_proposal/terminal.scss +72 -0
  24. data/app/assets/stylesheets/command_proposal.scss +5 -0
  25. data/app/controllers/command_proposal/engine_controller.rb +6 -0
  26. data/app/controllers/command_proposal/iterations_controller.rb +83 -0
  27. data/app/controllers/command_proposal/runner_controller.rb +86 -0
  28. data/app/controllers/command_proposal/tasks_controller.rb +97 -0
  29. data/app/helpers/command_proposal/application_helper.rb +58 -0
  30. data/app/helpers/command_proposal/icons_helper.rb +15 -0
  31. data/app/helpers/command_proposal/params_helper.rb +63 -0
  32. data/app/helpers/command_proposal/permissions_helper.rb +42 -0
  33. data/app/jobs/command_proposal/application_job.rb +4 -0
  34. data/app/jobs/command_proposal/command_runner_job.rb +11 -0
  35. data/app/models/command_proposal/comment.rb +14 -0
  36. data/app/models/command_proposal/iteration.rb +78 -0
  37. data/app/models/command_proposal/service/external_belong.rb +48 -0
  38. data/app/models/command_proposal/service/json_wrapper.rb +18 -0
  39. data/app/models/command_proposal/service/proposal_presenter.rb +39 -0
  40. data/app/models/command_proposal/task.rb +106 -0
  41. data/app/views/command_proposal/tasks/_console_show.html.erb +44 -0
  42. data/app/views/command_proposal/tasks/_function_show.html.erb +54 -0
  43. data/app/views/command_proposal/tasks/_lines.html.erb +8 -0
  44. data/app/views/command_proposal/tasks/_module_show.html.erb +33 -0
  45. data/app/views/command_proposal/tasks/_past_iterations_list.html.erb +20 -0
  46. data/app/views/command_proposal/tasks/_task_detail_table.html.erb +31 -0
  47. data/app/views/command_proposal/tasks/_task_show.html.erb +55 -0
  48. data/app/views/command_proposal/tasks/error.html.erb +4 -0
  49. data/app/views/command_proposal/tasks/form.html.erb +64 -0
  50. data/app/views/command_proposal/tasks/index.html.erb +44 -0
  51. data/app/views/command_proposal/tasks/show.html.erb +10 -0
  52. data/config/routes.rb +11 -0
  53. data/lib/command_proposal/configuration.rb +41 -0
  54. data/lib/command_proposal/engine.rb +6 -0
  55. data/lib/command_proposal/services/command_interpreter.rb +108 -0
  56. data/lib/command_proposal/services/runner.rb +157 -0
  57. data/lib/command_proposal/version.rb +3 -0
  58. data/lib/command_proposal.rb +27 -0
  59. data/lib/generators/command_proposal/install/install_generator.rb +28 -0
  60. data/lib/generators/command_proposal/install/templates/initializer.rb +47 -0
  61. data/lib/generators/command_proposal/install/templates/install_command_proposal.rb +40 -0
  62. data/lib/tasks/command_proposal_tasks.rake +4 -0
  63. metadata +167 -0
@@ -0,0 +1,51 @@
1
+ docReady(function() {
2
+ var terminals = document.querySelectorAll("[data-feed]")
3
+ var queue = Promise.resolve()
4
+ var continue_statuses = ["started", "approved", "cancelling"]
5
+
6
+ terminals.forEach(function(terminal) {
7
+ if (continue_statuses.includes(terminal.dataset.status)) {
8
+ pingFeed(terminal)
9
+ }
10
+ })
11
+
12
+ function pingFeed(terminal) {
13
+ queue = queue.then(async function() {
14
+ $.rails.refreshCSRFTokens()
15
+
16
+ var res = await fetch(terminal.dataset.feed, {
17
+ method: "GET",
18
+ headers: {
19
+ "Content-Type": "text/html",
20
+ "X-CSRF-Token": $.rails.csrfToken()
21
+ },
22
+ }).then(function(res) {
23
+ if (res.ok) {
24
+ return res.json()
25
+ } else {
26
+ throw new Error("Server error")
27
+ }
28
+ }).catch(function(err) {
29
+ console.log("err:", err);
30
+ })
31
+
32
+ var json = await res
33
+
34
+ if (terminal.nextElementSibling && terminal.nextElementSibling.CodeMirror) {
35
+ terminal.nextElementSibling.CodeMirror.doc.setValue(json.result || "")
36
+ } else {
37
+ terminal.innerHTML = json.result_html
38
+ }
39
+ document.querySelector("td[data-iteration-status]").innerText = json.status
40
+ document.querySelector("td[data-iteration-duration]").innerText = json.duration
41
+
42
+ if (continue_statuses.includes(json.status)) {
43
+ setTimeout(function() { pingFeed(terminal) }, 1000)
44
+ } else {
45
+ if (document.querySelector(".cancel-btn")) {
46
+ document.querySelector(".cancel-btn").remove()
47
+ }
48
+ }
49
+ })
50
+ }
51
+ })
@@ -0,0 +1,40 @@
1
+ docReady(function() {
2
+ var terminals = document.querySelectorAll(".cmd-terminal")
3
+
4
+ function setReadOnlyUI(cm) {
5
+ cm.getWrapperElement().classList.add("CodeMirror-readonly")
6
+
7
+ pencil = document.createElement("i")
8
+ pencil.className = "fa fa-pencil fa-stack-1x"
9
+
10
+ ban = document.createElement("i")
11
+ ban.className = "fa fa-ban fa-stack-2x fa-flip-horizontal"
12
+
13
+ stack = document.createElement("span")
14
+ stack.className = "fa-stack fa-2x"
15
+ stack.append(pencil)
16
+ stack.append(ban)
17
+
18
+ cm.getWrapperElement().append(stack)
19
+ }
20
+
21
+ terminals.forEach(function(terminal) {
22
+ var cm = CodeMirror.fromTextArea(
23
+ terminal,
24
+ {
25
+ tabSize: 2,
26
+ lineNumbers: true,
27
+ readOnly: terminal.readOnly || false,
28
+ mode: "ruby",
29
+ theme: "rubyblue",
30
+ keyMap: "sublime",
31
+ viewportMargin: Infinity,
32
+ height: "auto",
33
+ }
34
+ )
35
+
36
+ if (terminal.readOnly) {
37
+ setReadOnlyUI(cm)
38
+ }
39
+ })
40
+ })
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,27 @@
1
+ .cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
2
+ .cm-s-rubyblue div.CodeMirror-selected { background: #38566F; }
3
+ .cm-s-rubyblue .CodeMirror-line::selection, .cm-s-rubyblue .CodeMirror-line > span::selection, .cm-s-rubyblue .CodeMirror-line > span > span::selection { background: rgba(56, 86, 111, 0.99); }
4
+ .cm-s-rubyblue .CodeMirror-line::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 86, 111, 0.99); }
5
+ .cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }
6
+ .cm-s-rubyblue .CodeMirror-guttermarker { color: white; }
7
+ .cm-s-rubyblue .CodeMirror-guttermarker-subtle { color: #3E7087; }
8
+ .cm-s-rubyblue .CodeMirror-linenumber { color: white; }
9
+ .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white; }
10
+
11
+ .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
12
+ .cm-s-rubyblue span.cm-atom, .cm-s-rubyblue span.cm-tag { color: #F4D20B; }
13
+ .cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
14
+ .cm-s-rubyblue span.cm-keyword { color: #C678DD; }
15
+ .cm-s-rubyblue span.cm-property { color: lightgrey; }
16
+ .cm-s-rubyblue span.cm-string { color: #7BD827; }
17
+ .cm-s-rubyblue span.cm-meta { color: #C678DD; }
18
+ .cm-s-rubyblue span.cm-variable { color: #61AFEF; }
19
+ .cm-s-rubyblue span.cm-variable-2 { color: #E06C75; }
20
+ .cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def, .cm-s-rubyblue span.cm-type { color: #61AFEF; }
21
+ .cm-s-rubyblue span.cm-bracket { color: #C678DD; }
22
+ .cm-s-rubyblue span.cm-link { color: #F4C20B; }
23
+ .cm-s-rubyblue span.CodeMirror-matchingbracket { color:#C678DD !important; }
24
+ .cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
25
+ .cm-s-rubyblue span.cm-error { color: #AF2018; }
26
+
27
+ .cm-s-rubyblue .CodeMirror-activeline-background { background: #173047; }
@@ -0,0 +1,367 @@
1
+ /* BASICS */
2
+
3
+ .CodeMirror {
4
+ /* Set height, width, borders, and global font properties here */
5
+ font-family: monospace;
6
+ height: auto;
7
+ color: black;
8
+ direction: ltr;
9
+ }
10
+
11
+ /* PADDING */
12
+
13
+ .CodeMirror-lines {
14
+ padding: 4px 0; /* Vertical padding around content */
15
+ }
16
+ .CodeMirror pre.CodeMirror-line,
17
+ .CodeMirror pre.CodeMirror-line-like {
18
+ padding: 0 4px; /* Horizontal padding of content */
19
+ }
20
+
21
+ .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
22
+ background-color: white; /* The little square between H and V scrollbars */
23
+ }
24
+
25
+ /* GUTTER */
26
+
27
+ .CodeMirror-gutters {
28
+ border-right: 1px solid #ddd;
29
+ background-color: #f7f7f7;
30
+ white-space: nowrap;
31
+ }
32
+ .CodeMirror-linenumbers {}
33
+ .CodeMirror-linenumber {
34
+ padding: 0 3px 0 5px;
35
+ min-width: 20px;
36
+ text-align: right;
37
+ color: #999;
38
+ white-space: nowrap;
39
+ }
40
+
41
+ .CodeMirror-guttermarker { color: black; }
42
+ .CodeMirror-guttermarker-subtle { color: #999; }
43
+
44
+ /* CURSOR */
45
+
46
+ .CodeMirror-cursor {
47
+ border-left: 1px solid black;
48
+ border-right: none;
49
+ width: 0;
50
+ }
51
+ /* Shown when moving in bi-directional text */
52
+ .CodeMirror div.CodeMirror-secondarycursor {
53
+ border-left: 1px solid silver;
54
+ }
55
+ .cm-fat-cursor .CodeMirror-cursor {
56
+ width: auto;
57
+ border: 0 !important;
58
+ background: #7e7;
59
+ }
60
+ .cm-fat-cursor div.CodeMirror-cursors {
61
+ z-index: 1;
62
+ }
63
+ .cm-fat-cursor-mark {
64
+ background-color: rgba(20, 255, 20, 0.5);
65
+ -webkit-animation: blink 1.06s steps(1) infinite;
66
+ -moz-animation: blink 1.06s steps(1) infinite;
67
+ animation: blink 1.06s steps(1) infinite;
68
+ }
69
+ .cm-animate-fat-cursor {
70
+ width: auto;
71
+ border: 0;
72
+ -webkit-animation: blink 1.06s steps(1) infinite;
73
+ -moz-animation: blink 1.06s steps(1) infinite;
74
+ animation: blink 1.06s steps(1) infinite;
75
+ background-color: #7e7;
76
+ }
77
+ @-moz-keyframes blink {
78
+ 0% {}
79
+ 50% { background-color: transparent; }
80
+ 100% {}
81
+ }
82
+ @-webkit-keyframes blink {
83
+ 0% {}
84
+ 50% { background-color: transparent; }
85
+ 100% {}
86
+ }
87
+ @keyframes blink {
88
+ 0% {}
89
+ 50% { background-color: transparent; }
90
+ 100% {}
91
+ }
92
+
93
+ /* Can style cursor different in overwrite (non-insert) mode */
94
+ .CodeMirror-overwrite .CodeMirror-cursor {}
95
+
96
+ .cm-tab { display: inline-block; text-decoration: inherit; }
97
+
98
+ .CodeMirror-rulers {
99
+ position: absolute;
100
+ left: 0; right: 0; top: -50px; bottom: 0;
101
+ overflow: hidden;
102
+ }
103
+ .CodeMirror-ruler {
104
+ border-left: 1px solid #ccc;
105
+ top: 0; bottom: 0;
106
+ position: absolute;
107
+ }
108
+
109
+ /* DEFAULT THEME */
110
+
111
+ .cm-s-default .cm-header {color: blue;}
112
+ .cm-s-default .cm-quote {color: #090;}
113
+ .cm-negative {color: #d44;}
114
+ .cm-positive {color: #292;}
115
+ .cm-header, .cm-strong {font-weight: bold;}
116
+ .cm-em {font-style: italic;}
117
+ .cm-link {text-decoration: underline;}
118
+ .cm-strikethrough {text-decoration: line-through;}
119
+
120
+ .cm-s-default .cm-keyword {color: #708;}
121
+ .cm-s-default .cm-atom {color: #219;}
122
+ .cm-s-default .cm-number {color: #164;}
123
+ .cm-s-default .cm-def {color: #00f;}
124
+ .cm-s-default .cm-variable,
125
+ .cm-s-default .cm-punctuation,
126
+ .cm-s-default .cm-property,
127
+ .cm-s-default .cm-operator {}
128
+ .cm-s-default .cm-variable-2 {color: #05a;}
129
+ .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
130
+ .cm-s-default .cm-comment {color: #a50;}
131
+ .cm-s-default .cm-string {color: #a11;}
132
+ .cm-s-default .cm-string-2 {color: #f50;}
133
+ .cm-s-default .cm-meta {color: #555;}
134
+ .cm-s-default .cm-qualifier {color: #555;}
135
+ .cm-s-default .cm-builtin {color: #30a;}
136
+ .cm-s-default .cm-bracket {color: #997;}
137
+ .cm-s-default .cm-tag {color: #170;}
138
+ .cm-s-default .cm-attribute {color: #00c;}
139
+ .cm-s-default .cm-hr {color: #999;}
140
+ .cm-s-default .cm-link {color: #00c;}
141
+
142
+ .cm-s-default .cm-error {color: #f00;}
143
+ .cm-invalidchar {color: #f00;}
144
+
145
+ .CodeMirror-composing { border-bottom: 2px solid; }
146
+
147
+ /* Default styles for common addons */
148
+
149
+ div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
150
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
151
+ .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
152
+ .CodeMirror-activeline-background {background: #e8f2ff;}
153
+
154
+ /* STOP */
155
+
156
+ /* The rest of this file contains styles related to the mechanics of
157
+ the editor. You probably shouldn't touch them. */
158
+
159
+ .CodeMirror {
160
+ position: relative;
161
+ overflow: hidden;
162
+ background: white;
163
+ }
164
+
165
+ .CodeMirror-scroll {
166
+ overflow: scroll !important; /* Things will break if this is overridden */
167
+ /* 50px is the magic margin used to hide the element's real scrollbars */
168
+ /* See overflow: hidden in .CodeMirror */
169
+ margin-bottom: -50px; margin-right: -50px;
170
+ padding-bottom: 50px;
171
+ height: 100%;
172
+ outline: none; /* Prevent dragging from highlighting the element */
173
+ position: relative;
174
+ }
175
+ .CodeMirror-sizer {
176
+ position: relative;
177
+ border-right: 50px solid transparent;
178
+ }
179
+
180
+ /* The fake, visible scrollbars. Used to force redraw during scrolling
181
+ before actual scrolling happens, thus preventing shaking and
182
+ flickering artifacts. */
183
+ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
184
+ position: absolute;
185
+ z-index: 6;
186
+ display: none;
187
+ outline: none;
188
+ }
189
+ .CodeMirror-vscrollbar {
190
+ right: 0; top: 0;
191
+ overflow-x: hidden;
192
+ overflow-y: scroll;
193
+ }
194
+ .CodeMirror-hscrollbar {
195
+ bottom: 0; left: 0;
196
+ overflow-y: hidden;
197
+ overflow-x: scroll;
198
+ }
199
+ .CodeMirror-scrollbar-filler {
200
+ right: 0; bottom: 0;
201
+ }
202
+ .CodeMirror-gutter-filler {
203
+ left: 0; bottom: 0;
204
+ }
205
+
206
+ .CodeMirror-gutters {
207
+ position: absolute; left: 0; top: 0;
208
+ min-height: 100%;
209
+ z-index: 3;
210
+ }
211
+ .CodeMirror-gutter {
212
+ white-space: normal;
213
+ height: 100%;
214
+ display: inline-block;
215
+ vertical-align: top;
216
+ margin-bottom: -50px;
217
+ }
218
+ .CodeMirror-gutter-wrapper {
219
+ position: absolute;
220
+ z-index: 4;
221
+ background: none !important;
222
+ border: none !important;
223
+ }
224
+ .CodeMirror-gutter-background {
225
+ position: absolute;
226
+ top: 0; bottom: 0;
227
+ z-index: 4;
228
+ }
229
+ .CodeMirror-gutter-elt {
230
+ position: absolute;
231
+ cursor: default;
232
+ z-index: 4;
233
+ }
234
+ .CodeMirror-gutter-wrapper ::selection { background-color: transparent }
235
+ .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
236
+
237
+ .CodeMirror-lines {
238
+ cursor: text;
239
+ min-height: 1px; /* prevents collapsing before first draw */
240
+ }
241
+ .CodeMirror pre.CodeMirror-line,
242
+ .CodeMirror pre.CodeMirror-line-like {
243
+ /* Reset some styles that the rest of the page might have set */
244
+ -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
245
+ border-width: 0;
246
+ background: transparent;
247
+ font-family: inherit;
248
+ font-size: inherit;
249
+ margin: 0;
250
+ white-space: pre;
251
+ word-wrap: normal;
252
+ line-height: inherit;
253
+ color: inherit;
254
+ z-index: 2;
255
+ position: relative;
256
+ overflow: visible;
257
+ -webkit-tap-highlight-color: transparent;
258
+ -webkit-font-variant-ligatures: contextual;
259
+ font-variant-ligatures: contextual;
260
+ }
261
+ .CodeMirror-wrap pre.CodeMirror-line,
262
+ .CodeMirror-wrap pre.CodeMirror-line-like {
263
+ word-wrap: break-word;
264
+ white-space: pre-wrap;
265
+ word-break: normal;
266
+ }
267
+
268
+ .CodeMirror-linebackground {
269
+ position: absolute;
270
+ left: 0; right: 0; top: 0; bottom: 0;
271
+ z-index: 0;
272
+ }
273
+
274
+ .CodeMirror-linewidget {
275
+ position: relative;
276
+ z-index: 2;
277
+ padding: 0.1px; /* Force widget margins to stay inside of the container */
278
+ }
279
+
280
+ .CodeMirror-widget {}
281
+
282
+ .CodeMirror-rtl pre { direction: rtl; }
283
+
284
+ .CodeMirror-code {
285
+ outline: none;
286
+ }
287
+
288
+ /* Force content-box sizing for the elements where we expect it */
289
+ .CodeMirror-scroll,
290
+ .CodeMirror-sizer,
291
+ .CodeMirror-gutter,
292
+ .CodeMirror-gutters,
293
+ .CodeMirror-linenumber {
294
+ -moz-box-sizing: content-box;
295
+ box-sizing: content-box;
296
+ }
297
+
298
+ .CodeMirror-measure {
299
+ position: absolute;
300
+ width: 100%;
301
+ height: 0;
302
+ overflow: hidden;
303
+ visibility: hidden;
304
+ }
305
+
306
+ .CodeMirror-cursor {
307
+ position: absolute;
308
+ pointer-events: none;
309
+ }
310
+ .CodeMirror-measure pre { position: static; }
311
+
312
+ div.CodeMirror-cursors {
313
+ visibility: hidden;
314
+ position: relative;
315
+ z-index: 3;
316
+ }
317
+ div.CodeMirror-dragcursors {
318
+ visibility: visible;
319
+ }
320
+
321
+ .CodeMirror-focused div.CodeMirror-cursors {
322
+ visibility: visible;
323
+ }
324
+
325
+ .CodeMirror-selected { background: #d9d9d9; }
326
+ .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
327
+ .CodeMirror-crosshair { cursor: crosshair; }
328
+ .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
329
+ .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
330
+
331
+ .cm-searching {
332
+ background-color: #ffa;
333
+ background-color: rgba(255, 255, 0, .4);
334
+ }
335
+
336
+ /* Used to force a border model for a node */
337
+ .cm-force-border { padding-right: .1px; }
338
+
339
+ @media print {
340
+ /* Hide the cursor when printing */
341
+ .CodeMirror div.CodeMirror-cursors {
342
+ visibility: hidden;
343
+ }
344
+ }
345
+
346
+ /* See issue #2901 */
347
+ .cm-tab-wrap-hack:after { content: ''; }
348
+
349
+ /* Help users use markselection to safely style text background */
350
+ span.CodeMirror-selectedtext { background: none; }
351
+
352
+ /* Hide cursor in readonly fields */
353
+ .CodeMirror-readonly .CodeMirror-cursor {
354
+ display: none !important
355
+ }
356
+
357
+ .CodeMirror-readonly .fa-stack {
358
+ position: absolute;
359
+ top: 2px;
360
+ right: 2px;
361
+ z-index: 10;
362
+ font-size: 10px;
363
+ }
364
+
365
+ .CodeMirror-readonly .fa-ban {
366
+ color: tomato;
367
+ }