class Lamby::Runner
Constants
- PATTERNS
Public Class Methods
call(event)
click to toggle source
# File lib/lamby/runner.rb, line 18 def call(event) new(event).call end
handle?(event)
click to toggle source
# File lib/lamby/runner.rb, line 14 def handle?(event) event.dig 'lamby', 'runner' end
new(event)
click to toggle source
# File lib/lamby/runner.rb, line 24 def initialize(event) @event = event @body = '' end
Public Instance Methods
call()
click to toggle source
# File lib/lamby/runner.rb, line 29 def call validate! status = Open3.popen3(command, chdir: chdir) do |_stdin, stdout, stderr, thread| @body << stdout.read @body << stderr.read puts @body thread.value.exitstatus end [status, {}, StringIO.new(@body)] end
command()
click to toggle source
# File lib/lamby/runner.rb, line 40 def command @event.dig 'lamby', 'runner' end
Private Instance Methods
chdir()
click to toggle source
# File lib/lamby/runner.rb, line 46 def chdir defined?(::Rails) ? ::Rails.root : Dir.pwd end
pattern?()
click to toggle source
# File lib/lamby/runner.rb, line 55 def pattern? PATTERNS.any? { |p| p === command } end
validate!()
click to toggle source
# File lib/lamby/runner.rb, line 50 def validate! return if pattern? raise UnknownCommandPattern.new(command) end