mushy 0.5.3 → 0.6.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: 06d11ce2fc1a5da26f1272caf5b4b8a5bc7e8ff110b0169932778b9bdb7bb2bc
4
- data.tar.gz: 96b68f95bff616ff46084d97630d0eab8d1496a99e902efae7fad965a16485dd
3
+ metadata.gz: dcfab01a12d0d1a59c024265891b2851943755a0cdb9468768dd71c3fbcc1c63
4
+ data.tar.gz: ed387d7e22cc0368e1d309326dd646cb284256b030ced1da44106a6dad3f1979
5
5
  SHA512:
6
- metadata.gz: efc7c6b028efa5c75033b92ff9db8b422c6d81aae240a48178371b4208c1231ac63d8a2e437acfaccddb9e8a233c263b0284c85b16678036f99125f6ed757f6c
7
- data.tar.gz: 5d19241ba64eddd10937f09aeb19d5c3d809d68e8ca100b7d94e64362e8a1a32fc0da56fabf7aeebd6f6303be5cce00db382333400f8e000c408535f63ad64f1
6
+ metadata.gz: d633be32aec24e036a0c8b6ffc185b743f95d78a9b986304dabaff72a642fdfe09a48ca86d3753b1e1dfb722347cccf33392fb651befbae28177e9dcc9889808
7
+ data.tar.gz: 0d54c907f8ec088f928fc0cd4ca88c72203e6080e0ccb5bc96b23b31dca329fa673b84168017effdc19a33dd8f5598100039675b34db20adfb7ee5c282cc7cd7
@@ -40,16 +40,25 @@ module Mushy
40
40
  pwd = Dir.pwd
41
41
 
42
42
  if service_fluxes.any?
43
- calls = service_fluxes
43
+
44
+ things = service_fluxes
44
45
  .map { |s| { flux: s, proc: ->(e) do
45
46
  Dir.chdir pwd
46
47
  Mushy::Runner.new.start e, s, flow
47
- end } }
48
+ end,
49
+ run_method: (s.config[:run_strategy] == 'daemon' ? :run_this_as_a_daemon : :run_this_inline),
50
+ }
51
+ }.group_by { |x| x[:run_method] }
52
+
53
+ calls = (things[:run_this_as_a_daemon] || [])
48
54
  .map { |p| ->() { p[:flux].loop &p[:proc] } }
49
55
  .map { |x| ->() { loop &x } }
50
- .map { |x| run_as_a_daemon &x }
56
+ .map { |x| run_this_as_a_daemon &x }
51
57
 
52
- puts calls.inspect
58
+ (things[:run_this_inline] || [])
59
+ .map { |p| ->() { p[:flux].loop &p[:proc] } }
60
+ .map { |x| ->() { loop &x } }
61
+ .map { |x| run_this_inline &x }
53
62
 
54
63
  exit
55
64
  end
@@ -59,8 +68,11 @@ module Mushy
59
68
  Mushy::Runner.new.start event, cli_flux, flow
60
69
  end
61
70
 
62
- def self.run_as_a_daemon &block
63
- #block.call
71
+ def self.run_this_inline &block
72
+ block.call
73
+ end
74
+
75
+ def self.run_this_as_a_daemon &block
64
76
  Daemons.call(&block).pid.pid
65
77
  end
66
78
 
@@ -104,6 +116,16 @@ module Mushy
104
116
  shrink: true,
105
117
  }
106
118
 
119
+ if flux.new.respond_to? :loop
120
+ details[:config][:run_strategy] = {
121
+ description: 'Run this using this strategy. (select "daemon" if this should be run in the background)',
122
+ type: 'select',
123
+ options: ['', 'inline', 'daemon'],
124
+ value: '',
125
+ shrink: true,
126
+ }
127
+ end
128
+
107
129
  details[:config]
108
130
  .select { |_, v| v[:type] == 'keyvalue' }
109
131
  .select { |_, v| v[:editors].nil? }
@@ -115,7 +137,7 @@ module Mushy
115
137
  end
116
138
 
117
139
  details
118
- end
140
+ end.sort_by { |x| x[:name] }
119
141
  }
120
142
  end
121
143
 
@@ -22,6 +22,8 @@ module Mushy
22
22
  method = i[1] || i[0]
23
23
  t[i[0]] = now.send method
24
24
  t
25
+ end.tap do |hash|
26
+ hash[:seconds_ago] = Time.now - now
25
27
  end
26
28
  end
27
29
 
@@ -0,0 +1,46 @@
1
+ require 'listen'
2
+
3
+ module Mushy
4
+
5
+ class FileWatch < Flux
6
+
7
+ def self.details
8
+ {
9
+ name: 'FileWatch',
10
+ description: 'Watch for file changes.',
11
+ config: {
12
+ directory: {
13
+ description: 'The directory to watch.',
14
+ type: 'text',
15
+ value: '',
16
+ },
17
+ },
18
+ }
19
+ end
20
+
21
+ def loop &block
22
+
23
+ directory = config[:directory].to_s != '' ? config[:directory] : Dir.pwd
24
+
25
+ listener = Listen.to(directory) do |modified, added, removed|
26
+ the_event = {
27
+ modified: modified,
28
+ added: added,
29
+ removed: removed,
30
+ }
31
+ block.call the_event
32
+ end
33
+
34
+ listener.start
35
+
36
+ sleep
37
+
38
+ end
39
+
40
+ def process event, config
41
+ event
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,29 @@
1
+ module Mushy
2
+
3
+ class Times < Flux
4
+
5
+ def self.details
6
+ {
7
+ name: 'Times',
8
+ description: 'Return the event passed to it, X times.',
9
+ config: {
10
+ times: {
11
+ description: 'The number of times this event should be returned.',
12
+ type: 'integer',
13
+ value: '1',
14
+ },
15
+ }
16
+ }
17
+ end
18
+
19
+ def process event, config
20
+ config[:times]
21
+ .to_i
22
+ .times
23
+ .each_with_index
24
+ .map { |x, i| event.dup.tap { |e| e[:index] = i } }
25
+ end
26
+
27
+ end
28
+
29
+ end
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.5.3'
7
+ s.version = '0.6.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.'
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency 'faraday'
27
27
  s.add_runtime_dependency 'pony'
28
28
  s.add_runtime_dependency 'daemons'
29
+ s.add_runtime_dependency 'listen'
29
30
  end
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.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: listen
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description: This tool assists in the creation and processing of workflows.
154
168
  email: darren@cauthon.com
155
169
  executables:
@@ -175,6 +189,7 @@ files:
175
189
  - lib/mushy/fluxs/collection.rb
176
190
  - lib/mushy/fluxs/document.rb
177
191
  - lib/mushy/fluxs/environment.rb
192
+ - lib/mushy/fluxs/file_watch.rb
178
193
  - lib/mushy/fluxs/filter.rb
179
194
  - lib/mushy/fluxs/format.rb
180
195
  - lib/mushy/fluxs/get.rb
@@ -189,6 +204,7 @@ files:
189
204
  - lib/mushy/fluxs/read_file.rb
190
205
  - lib/mushy/fluxs/screenshot.rb
191
206
  - lib/mushy/fluxs/smtp.rb
207
+ - lib/mushy/fluxs/times.rb
192
208
  - lib/mushy/fluxs/write_file.rb
193
209
  - lib/mushy/masher.rb
194
210
  - lib/mushy/run.rb