command_proposal 1.0.10 → 1.0.11
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/lib/command_proposal/services/runner.rb +20 -4
- data/lib/command_proposal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b612ae41c1fc8d8b0026ece90e73dae10192904a4ff739a8e11b2185e12c6f4
|
4
|
+
data.tar.gz: ae0ff52ce13d86c9fa32210d1d0121ac52a891aa87e5a951ee6c3e7796fe1a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f5742d0fb9bbf6b642e978a3ce6f017dfdeca31b9c3776ee720b1b8e27d4ade589bc9f776ef4fb0a4c16891c4617aa5c21b375760d75e2d3ce3d1172261fca2
|
7
|
+
data.tar.gz: 17a14923c1c3b23942005d8d448bb621e4aafa72c4bf4ae75a8a9bb863e682b05f2fd0d0caf55ca70b087cb376598615c81574bec62a96fdaac6f5afee018402
|
@@ -11,12 +11,28 @@ module CommandProposal
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.command(friendly_id, user, params={})
|
14
|
-
|
14
|
+
# Hack magic because requires are not playing well with spring
|
15
|
+
require "command_proposal/services/command_interpreter"
|
16
|
+
|
17
|
+
params = params.to_unsafe_h if params.is_a?(ActionController::Parameters)
|
18
|
+
|
19
|
+
iteration = ::CommandProposal::Services::CommandInterpreter.command(
|
15
20
|
::CommandProposal::Task.find_by!(friendly_id: friendly_id).primary_iteration,
|
16
21
|
:run,
|
17
22
|
user,
|
18
|
-
|
23
|
+
{ args: params }
|
19
24
|
)
|
25
|
+
|
26
|
+
start = Time.current
|
27
|
+
wait_time = 5 # seconds
|
28
|
+
loop do
|
29
|
+
sleep 0.4
|
30
|
+
|
31
|
+
break if iteration.reload.complete?
|
32
|
+
break if Time.current - start > wait_time
|
33
|
+
end
|
34
|
+
|
35
|
+
iteration
|
20
36
|
end
|
21
37
|
|
22
38
|
def initialize
|
@@ -74,7 +90,7 @@ module CommandProposal
|
|
74
90
|
begin
|
75
91
|
# Run bring functions in here so we can capture any string outputs
|
76
92
|
# OR! Run the full runner and instead of saving to an iteration, return the string for prepending here
|
77
|
-
|
93
|
+
@session.eval("_ = (#{@iteration.code})").inspect # rubocop:disable Security/Eval - Eval is scary, but in this case it's exactly what we need.
|
78
94
|
status = :success
|
79
95
|
rescue Exception => e # rubocop:disable Lint/RescueException - Yes, rescue full Exception so that we can catch typos in evals as well
|
80
96
|
status = :failed
|
@@ -104,7 +120,7 @@ module CommandProposal
|
|
104
120
|
|
105
121
|
$stdout = stored_stdout
|
106
122
|
@iteration.status = status
|
107
|
-
@iteration.result = [output,
|
123
|
+
@iteration.result = [output, result].compact.join("\n")
|
108
124
|
end
|
109
125
|
|
110
126
|
def bring_function
|