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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 479ccc8116bd6b1cc29396f6218108d110ef0cb166d8e19800de282e3c9960eb
4
- data.tar.gz: b83c88258d9cfde5f08eea41d6b16a6fc935f39b4ef3f757bf3db303fc460676
3
+ metadata.gz: 3310d89eada814ea6146a796ad78267d592b81b2cf7bdc002e765dfb9eb35e20
4
+ data.tar.gz: 7e2aa3b6a63d8e0f4d9c7291e1c1eecb7103374fa87302c5c4ad4ff1498f05a0
5
5
  SHA512:
6
- metadata.gz: e09c68d4be5c311b7bb5ea0fb14f4539b0932a2a67c18239c4df7b786aa1221ae63b2a5b5418aed4d20b02a1c650380c0d9bf41abdf7562d596b5fe04ad632dc
7
- data.tar.gz: f0d90a45776a0f07ba6a07fdb8348fd55d8f03fa3b941d310f2b547b089f70d402554a050981578b165a340eea86ba01f89202245c8424d0e32634eb7e37b286
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
- event = incoming_event
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] : [event]
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, event, config[:join]) if config[:join]
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
- [flux.execute(event.data)]
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.8.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.8.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