command_proposal 1.0.10 → 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: ab98adfd455b086e6e9837ebabb3461fadfe73e95060b7061e61e05c4eae374a
4
- data.tar.gz: 8449a6b67001d913bd5cf8a9e89bb8a3fe730dc384449fb51957a8eb018c53af
3
+ metadata.gz: 3b612ae41c1fc8d8b0026ece90e73dae10192904a4ff739a8e11b2185e12c6f4
4
+ data.tar.gz: ae0ff52ce13d86c9fa32210d1d0121ac52a891aa87e5a951ee6c3e7796fe1a06
5
5
  SHA512:
6
- metadata.gz: 277d11f925f481a5c5a8f53a4f17dce9725305964f04473cebd92693f0684335e5d77161966186444f29e5fcb113571feb029662bb4b3d82a7182bee38ea89ff
7
- data.tar.gz: 02c2e3f743f0dd76bbabe43c3fe0f22d332af4d03a5d9561ee1a459e62f185b515f8961ee8a2f96d3ce0424c1153f10769759daed07f38441c8d41abe4eb4f4b
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
- ::CommandProposal::Services::CommandInterpreter.command(
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
- params.except(:action, :controller)
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
- 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.
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, "#{result || 'nil'}"].compact.join("\n")
123
+ @iteration.result = [output, result].compact.join("\n")
108
124
  end
109
125
 
110
126
  def bring_function
@@ -1,3 +1,3 @@
1
1
  module CommandProposal
2
- VERSION = "1.0.10"
2
+ VERSION = "1.0.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_proposal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls