command_proposal 1.0.7 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/command_proposal/application_helper.rb +1 -4
- data/app/jobs/command_proposal/application_job.rb +3 -0
- data/app/views/command_proposal/tasks/_past_iterations_list.html.erb +2 -2
- data/lib/command_proposal/configuration.rb +1 -0
- data/lib/command_proposal/services/runner.rb +27 -2
- data/lib/command_proposal/version.rb +1 -1
- data/lib/command_proposal.rb +6 -0
- metadata +4 -4
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
|
@@ -48,10 +48,7 @@ module CommandProposal
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def engine
|
51
|
-
@engine ||=
|
52
|
-
name = `rails routes | grep command_proposal_engine`[/\w*command_proposal_engine/]
|
53
|
-
send(name)
|
54
|
-
end
|
51
|
+
@engine ||= send(::CommandProposal.engine_name)
|
55
52
|
end
|
56
53
|
|
57
54
|
# Runner controller doesn't map to a model, so needs special handling
|
@@ -18,8 +18,8 @@
|
|
18
18
|
<% end %>
|
19
19
|
</td>
|
20
20
|
<td><%= iteration.status.capitalize %></td>
|
21
|
-
<!-- <td
|
22
|
-
<!-- <td
|
21
|
+
<!-- <td><%#= iteration.comments.count %></td> -->
|
22
|
+
<!-- <td><%#= link_to "Diff", cmd_path(@task, iteration: @iteration.id, diff: iteration.id) %></td> -->
|
23
23
|
</tr>
|
24
24
|
<% end %>
|
25
25
|
</tbody>
|
@@ -10,6 +10,31 @@ module CommandProposal
|
|
10
10
|
new.execute(task.primary_iteration)
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.command(friendly_id, user, params={})
|
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(
|
20
|
+
::CommandProposal::Task.find_by!(friendly_id: friendly_id).primary_iteration,
|
21
|
+
:run,
|
22
|
+
user,
|
23
|
+
{ args: params }
|
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
|
36
|
+
end
|
37
|
+
|
13
38
|
def initialize
|
14
39
|
@session = session
|
15
40
|
end
|
@@ -65,7 +90,7 @@ module CommandProposal
|
|
65
90
|
begin
|
66
91
|
# Run bring functions in here so we can capture any string outputs
|
67
92
|
# OR! Run the full runner and instead of saving to an iteration, return the string for prepending here
|
68
|
-
|
93
|
+
@session.eval("_ = (#{@iteration.code})").inspect # rubocop:disable Security/Eval - Eval is scary, but in this case it's exactly what we need.
|
69
94
|
status = :success
|
70
95
|
rescue Exception => e # rubocop:disable Lint/RescueException - Yes, rescue full Exception so that we can catch typos in evals as well
|
71
96
|
status = :failed
|
@@ -95,7 +120,7 @@ module CommandProposal
|
|
95
120
|
|
96
121
|
$stdout = stored_stdout
|
97
122
|
@iteration.status = status
|
98
|
-
@iteration.result = [output,
|
123
|
+
@iteration.result = [output, result].compact.join("\n")
|
99
124
|
end
|
100
125
|
|
101
126
|
def bring_function
|
data/lib/command_proposal.rb
CHANGED
@@ -22,6 +22,12 @@ module CommandProposal
|
|
22
22
|
@configuration = ::CommandProposal::Configuration.new
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.engine_name
|
26
|
+
@engine_name ||= begin
|
27
|
+
`rails routes | grep command_proposal_engine`[/\w*command_proposal_engine/]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
def self.configure
|
26
32
|
yield(configuration)
|
27
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_proposal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rocco Nicholls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: font-awesome-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|