mushy 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mushy/flow.rb +6 -0
- data/lib/mushy/flux.rb +3 -5
- data/lib/mushy/fluxs/global_variables.rb +39 -0
- data/lib/mushy/runner.rb +6 -4
- data/mushy.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3310d89eada814ea6146a796ad78267d592b81b2cf7bdc002e765dfb9eb35e20
|
4
|
+
data.tar.gz: 7e2aa3b6a63d8e0f4d9c7291e1c1eecb7103374fa87302c5c4ad4ff1498f05a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff438b38489fc1d26111448873640973e25a9ffb02b4e498bff78919eb4d21bf3a954729c2296f673df218b324c07cc9d9635a0d24081f9b0bef1aa12cd04895
|
7
|
+
data.tar.gz: c5d9e71047c5bbced7129b429144ff9b5b110083e84c5efe8681920b6c0d20948f1445162708e2ba658b9d86ac8a2abb1734a4cd73b4a08e2ec5bd65212f4832
|
data/lib/mushy/flow.rb
CHANGED
@@ -17,6 +17,12 @@ module Mushy
|
|
17
17
|
.flatten
|
18
18
|
end
|
19
19
|
|
20
|
+
def adjust_data data
|
21
|
+
fluxs
|
22
|
+
.select { |x| x.respond_to? :adjust_data }
|
23
|
+
.reduce(data) { |t, i| i.adjust_data t }
|
24
|
+
end
|
25
|
+
|
20
26
|
def self.build_flux record
|
21
27
|
type = record[:type] || record['type'] || record[:flux] || record['flux'] || 'Flux'
|
22
28
|
flux = Object.const_get("Mushy::#{type}").new
|
data/lib/mushy/flux.rb
CHANGED
@@ -39,20 +39,18 @@ module Mushy
|
|
39
39
|
|
40
40
|
incoming_event = SymbolizedHash.new(incoming_event) if incoming_event.is_a?(Hash)
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
incoming_split = masher.mash(config, event)[:incoming_split]
|
42
|
+
incoming_split = masher.mash(config, incoming_event)[:incoming_split]
|
45
43
|
config_considering_an_imcoming_split = config
|
46
44
|
.reject { |x, _| incoming_split && x.to_s == 'join' }
|
47
45
|
.reduce({}) { |t, i| t[i[0]] = i[1]; t }
|
48
46
|
|
49
|
-
events = incoming_split ? incoming_event[incoming_split] : [
|
47
|
+
events = incoming_split ? incoming_event[incoming_split] : [incoming_event]
|
50
48
|
|
51
49
|
results = events.map { |e| execute_single_event e, config_considering_an_imcoming_split }
|
52
50
|
|
53
51
|
return results.first unless incoming_split
|
54
52
|
|
55
|
-
results = join_these_results([results].flatten,
|
53
|
+
results = join_these_results([results].flatten, incoming_event, config[:join]) if config[:join]
|
56
54
|
|
57
55
|
results.flatten
|
58
56
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class GlobalVariables < Flux
|
4
|
+
|
5
|
+
attr_accessor :state
|
6
|
+
|
7
|
+
def self.details
|
8
|
+
{
|
9
|
+
name: 'GlobalVariables',
|
10
|
+
description: 'Add global variables.',
|
11
|
+
config: {
|
12
|
+
values: {
|
13
|
+
description: 'Provide key/value pairs that will be set as global variables.',
|
14
|
+
label: 'Variables',
|
15
|
+
type: 'keyvalue',
|
16
|
+
value: {},
|
17
|
+
},
|
18
|
+
},
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
self.state = SymbolizedHash.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def adjust_data data
|
28
|
+
state.merge data
|
29
|
+
end
|
30
|
+
|
31
|
+
def process event, config
|
32
|
+
values = config[:values] || SymbolizedHash.new
|
33
|
+
state.merge! values
|
34
|
+
event
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/mushy/runner.rb
CHANGED
@@ -12,7 +12,7 @@ module Mushy
|
|
12
12
|
run = find_run flux, flow
|
13
13
|
starting_event = build_event event_data, flow.id, run.id, flux.id
|
14
14
|
|
15
|
-
events = run_event_with_flux starting_event, flux
|
15
|
+
events = run_event_with_flux starting_event, flux, flow
|
16
16
|
|
17
17
|
while events.any?
|
18
18
|
events = events.map { |e| runner.run_event_in_flow e, flow }.flatten
|
@@ -23,12 +23,14 @@ module Mushy
|
|
23
23
|
|
24
24
|
def run_event_in_flow event, flow
|
25
25
|
flow.fluxs_for(event)
|
26
|
-
.map { |s| runner.run_event_with_flux event, s }
|
26
|
+
.map { |s| runner.run_event_with_flux event, s, flow }
|
27
27
|
.flatten
|
28
28
|
end
|
29
29
|
|
30
|
-
def run_event_with_flux event, flux
|
31
|
-
|
30
|
+
def run_event_with_flux event, flux, flow
|
31
|
+
data = event.data
|
32
|
+
data = flow.adjust_data data
|
33
|
+
[flux.execute(data)]
|
32
34
|
.flatten
|
33
35
|
.reject { |x| x.nil? }
|
34
36
|
.map { |x| x.is_a?(Hash) ? build_event(x, event.flow_id, event.run_id, flux.id) : x }
|
data/mushy.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'mushy/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'mushy'
|
7
|
-
s.version = '0.
|
7
|
+
s.version = '0.9.0'
|
8
8
|
s.date = '2020-11-23'
|
9
9
|
s.summary = 'Process streams of work using common modules.'
|
10
10
|
s.description = 'This tool assists in the creation and processing of workflows.'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mushy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/mushy/fluxs/format.rb
|
195
195
|
- lib/mushy/fluxs/get.rb
|
196
196
|
- lib/mushy/fluxs/git_log.rb
|
197
|
+
- lib/mushy/fluxs/global_variables.rb
|
197
198
|
- lib/mushy/fluxs/interval.rb
|
198
199
|
- lib/mushy/fluxs/ls.rb
|
199
200
|
- lib/mushy/fluxs/parse_html.rb
|