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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31a6d83b17c11473a1b540ed85ee8d9f9eb18e7c0e19e2a5ba3d5dec32ecec48
4
- data.tar.gz: 8c98bf481ccb61042260928daf5f2b89783b9cdb577db44ff5ce6c9ddd264579
3
+ metadata.gz: 3b612ae41c1fc8d8b0026ece90e73dae10192904a4ff739a8e11b2185e12c6f4
4
+ data.tar.gz: ae0ff52ce13d86c9fa32210d1d0121ac52a891aa87e5a951ee6c3e7796fe1a06
5
5
  SHA512:
6
- metadata.gz: 0c70f51608c1d81770bf4cbe084f445da6a1aac249243e8c05ebb8fca375ef21c33d9b7bb118085d60853b483480675c4ed723ed9fd5074067fd1d12d6fc990e
7
- data.tar.gz: ec49a4f24e8384a56fb24add427e26b56df0b414fb3916830b414440f92a97a6183762696f7e995f0a12baab224c7176ac1cc0a43610b1200b3ad6db9240eb0f
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 ||= begin
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
@@ -1,4 +1,7 @@
1
1
  module CommandProposal
2
2
  class ApplicationJob < ActiveJob::Base
3
+ rescue_from(StandardError) do |exception|
4
+ Rails.logger.error "[#{self.class.name}] Job failed and will not retry: #{exception.to_s}"
5
+ end
3
6
  end
4
7
  end
@@ -18,8 +18,8 @@
18
18
  <% end %>
19
19
  </td>
20
20
  <td><%= iteration.status.capitalize %></td>
21
- <!-- <td><%= iteration.comments.count %></td> -->
22
- <!-- <td><%= link_to "Diff", cmd_path(@task, iteration: @iteration.id, diff: iteration.id) %></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,7 @@ module CommandProposal
10
10
  :approval_required,
11
11
  # Optional
12
12
  :proposal_callback,
13
+ :approval_callback,
13
14
  :success_callback,
14
15
  :failed_callback,
15
16
  )
@@ -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
- result = @session.eval("_ = (#{@iteration.code})").inspect # rubocop:disable Security/Eval - Eval is scary, but in this case it's exactly what we need.
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, "#{result || 'nil'}"].compact.join("\n")
123
+ @iteration.result = [output, result].compact.join("\n")
99
124
  end
100
125
 
101
126
  def bring_function
@@ -1,3 +1,3 @@
1
1
  module CommandProposal
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.11"
3
3
  end
@@ -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.7
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-14 00:00:00.000000000 Z
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: '5.0'
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: '5.0'
26
+ version: 5.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: font-awesome-rails
29
29
  requirement: !ruby/object:Gem::Requirement