Class: Mushy::SimplePythonProgram
- Inherits:
-
Bash
- Object
- Flux
- Bash
- Mushy::SimplePythonProgram
show all
- Defined in:
- lib/mushy/fluxs/simple_python_program.rb
Instance Attribute Summary
Attributes inherited from Flux
#config, #flow, #id, #masher, #parent_fluxs, #subscribed_to, #type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Flux
#convert_this_to_an_array, #convert_to_symbolized_hash, #execute, #execute_single_event, #group_these_results, #guard, #ignore_these_results, inherited, #initialize, #join_these_results, #limit_these_results, #merge_these_results, #model_these_results, #outgoing_split_these_results, #shape_these, #sort_these_results, #standardize_these
Constructor Details
This class inherits a constructor from Mushy::Flux
Class Method Details
.default_config ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/mushy/fluxs/simple_python_program.rb', line 5
def self.default_config
Mushy::Bash.details[:config].tap do |config|
config.delete :command
config.delete :directory
config[:fluxGroup] = { name: 'Execute' }
end
end
|
.details ⇒ Object
13
14
15
|
# File 'lib/mushy/fluxs/simple_python_program.rb', line 13
def self.details
nil
end
|
Instance Method Details
#adjust(data, event, config) ⇒ Object
35
36
37
|
# File 'lib/mushy/fluxs/simple_python_program.rb', line 35
def adjust data, event, config
data
end
|
#process(event, config) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/mushy/fluxs/simple_python_program.rb', line 17
def process event, config
lines = python_program(event, config)
.split('\n')
.map { |x| x.rstrip }
.select { |x| x && x != '' }
.map { |x| x.gsub('"', '\"') }
config[:command] = "python -c \"#{lines.join(';')}\""
result = super event, config
return nil unless result[:success]
adjust SymbolizedHash.new(JSON.parse(result[:text])), event, config
end
|