mushy 0.2.1 → 0.2.6
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 +2 -2
- data/lib/mushy/fluxs/browser.rb +11 -9
- data/lib/mushy/fluxs/environment.rb +28 -0
- data/lib/mushy/fluxs/pdf.rb +46 -0
- data/lib/mushy/fluxs/read_csv.rb +22 -2
- data/lib/mushy/fluxs/read_file.rb +44 -0
- data/lib/mushy/fluxs/screenshot.rb +9 -5
- data/lib/mushy/fluxs/smtp.rb +115 -0
- data/lib/mushy/fluxs/write_file.rb +5 -2
- data/mushy.gemspec +2 -1
- metadata +19 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1f4610ff32999add5edef562475fff259d62961c020d10abec4e2bfbe64344f
|
4
|
+
data.tar.gz: c0d2c08fdf345a28e7abfb9377309c1c1c3d09c0c38a28ca106e911da0bdb12f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7995542973e879c9dc1485182f74b2f648d37eb711b21017de11370a5839a0c92663d48fbcf1192781f121db1dddf0a367f68865a4761881306712fed37bbaa
|
7
|
+
data.tar.gz: a89ff7d26708e89c7d64fc8486146a4b51bcbba9abe8ad824796c90f6bae217f1f6578f41ca5772a8f105ec13e8e60c9981673dffdc7e88477ce2a11afa23fc9
|
data/lib/mushy/flow.rb
CHANGED
@@ -30,14 +30,14 @@ module Mushy
|
|
30
30
|
data = JSON.parse data
|
31
31
|
|
32
32
|
data_fluxs = data['fluxs'] || []
|
33
|
-
data_fluxs.select { |x| x['parent'] }.map { |r| r["
|
33
|
+
data_fluxs.select { |x| x['parent'] }.map { |r| r["parents"] = [r["parent"]] }
|
34
34
|
|
35
35
|
flow = new
|
36
36
|
|
37
37
|
flow.fluxs = data_fluxs.map { |s| build_flux s }
|
38
38
|
|
39
39
|
fluxs_with_parent_ids = flow.fluxs.reduce({}) { |t, i| t[i.id] = []; t }
|
40
|
-
data_fluxs.map { |r| fluxs_with_parent_ids[r['id']] = r['
|
40
|
+
data_fluxs.map { |r| fluxs_with_parent_ids[r['id']] = r['parents'] || [] }
|
41
41
|
|
42
42
|
flow.fluxs.each do |flux|
|
43
43
|
flux.parent_fluxs = flow.fluxs.select { |x| fluxs_with_parent_ids[flux.id].include?(x.id) }
|
data/lib/mushy/fluxs/browser.rb
CHANGED
@@ -51,10 +51,10 @@ module Mushy
|
|
51
51
|
],
|
52
52
|
},
|
53
53
|
carry_cookies_from: {
|
54
|
-
description: 'Carry the cookies from this path in the event.',
|
54
|
+
description: 'Carry the cookies from this path in the event. Defaults to "cookies".',
|
55
55
|
type: 'text',
|
56
56
|
shrink: true,
|
57
|
-
value: '
|
57
|
+
value: '',
|
58
58
|
},
|
59
59
|
headers: {
|
60
60
|
description: 'Headers for the web request. These can be received from a previous browser event with {{headers}}, or can be typed manually.',
|
@@ -63,10 +63,10 @@ module Mushy
|
|
63
63
|
value: {},
|
64
64
|
},
|
65
65
|
carry_headers_from: {
|
66
|
-
description: 'Carry the headers from this path in the event.',
|
66
|
+
description: 'Carry the headers from this path in the event. Defaults to "headers".',
|
67
67
|
type: 'text',
|
68
68
|
shrink: true,
|
69
|
-
value: '
|
69
|
+
value: '',
|
70
70
|
},
|
71
71
|
wait_before_closing: {
|
72
72
|
description: 'Wait this many seconds before closing the browser.',
|
@@ -105,19 +105,20 @@ module Mushy
|
|
105
105
|
body: browser.body
|
106
106
|
}
|
107
107
|
|
108
|
-
result =
|
108
|
+
result = adjust( { browser: browser, result: result, config: config } )
|
109
109
|
|
110
110
|
browser.quit
|
111
111
|
|
112
112
|
result
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
116
|
-
result
|
115
|
+
def adjust input
|
116
|
+
input[:result]
|
117
117
|
end
|
118
118
|
|
119
119
|
def get_the_cookies_from event, config
|
120
|
-
|
120
|
+
carry_cookies_from = config[:carry_cookies_from].to_s == '' ? 'cookies' : config[:carry_cookies_from]
|
121
|
+
cookies = event[carry_cookies_from.to_sym]
|
121
122
|
cookies = [] unless cookies.is_a?(Array)
|
122
123
|
config[:cookies] = [] unless config[:cookies].is_a?(Array)
|
123
124
|
config[:cookies].each { |x| cookies << x }
|
@@ -125,7 +126,8 @@ module Mushy
|
|
125
126
|
end
|
126
127
|
|
127
128
|
def get_the_headers_from event, config
|
128
|
-
|
129
|
+
carry_headers_from = config[:carry_headers_from].to_s == '' ? 'headers' : config[:carry_headers_from]
|
130
|
+
headers = event[carry_headers_from.to_sym]
|
129
131
|
headers = {} unless headers.is_a?(Hash)
|
130
132
|
config[:headers] = {} unless config[:headers].is_a?(Hash)
|
131
133
|
config[:headers].each { |k, v| headers[k] = v }
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class Environment < Flux
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
{
|
7
|
+
name: 'Environment',
|
8
|
+
description: 'Pull environment variables.',
|
9
|
+
config: {
|
10
|
+
variables: {
|
11
|
+
description: 'Map the environment variables to a new event.',
|
12
|
+
type: 'keyvalue',
|
13
|
+
value: {},
|
14
|
+
},
|
15
|
+
},
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def process event, config
|
20
|
+
config[:variables].reduce({}) do |t, i|
|
21
|
+
t[i[0]] = ENV[i[1]]
|
22
|
+
t
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class Pdf < Browser
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
details = Browser.details
|
7
|
+
details['name'] = 'Pdf'
|
8
|
+
details['description'] = 'Turn a URL into a PDF.'
|
9
|
+
|
10
|
+
details[:config][:path] = {
|
11
|
+
description: 'The path of the PDF file to save.',
|
12
|
+
type: 'text',
|
13
|
+
value: 'picture.pdf',
|
14
|
+
}
|
15
|
+
|
16
|
+
details[:config][:landscape] = {
|
17
|
+
description: 'Build the PDF in landscape. Defaults to false.',
|
18
|
+
type: 'boolean',
|
19
|
+
shrink: true,
|
20
|
+
value: '',
|
21
|
+
}
|
22
|
+
|
23
|
+
details
|
24
|
+
end
|
25
|
+
|
26
|
+
def adjust input
|
27
|
+
|
28
|
+
the_browser = input[:browser]
|
29
|
+
the_result = input[:result]
|
30
|
+
the_config = input[:config]
|
31
|
+
|
32
|
+
options = {
|
33
|
+
path: the_config[:path],
|
34
|
+
}
|
35
|
+
|
36
|
+
options[:landscape] = true if the_config[:landscape].to_s == 'true'
|
37
|
+
|
38
|
+
the_browser.pdf options
|
39
|
+
|
40
|
+
options
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/mushy/fluxs/read_csv.rb
CHANGED
@@ -4,10 +4,30 @@ module Mushy
|
|
4
4
|
|
5
5
|
class ReadCsv < Flux
|
6
6
|
|
7
|
+
def self.details
|
8
|
+
{
|
9
|
+
name: 'ReadCsv',
|
10
|
+
description: 'Read CSV content into events.',
|
11
|
+
config: {
|
12
|
+
data: {
|
13
|
+
description: 'The data to convert to a CSV.',
|
14
|
+
type: 'text',
|
15
|
+
value: '{{data}}',
|
16
|
+
},
|
17
|
+
headers: {
|
18
|
+
description: 'The CSV contains headers. Defaults to false.',
|
19
|
+
type: 'boolean',
|
20
|
+
shrink: true,
|
21
|
+
value: '',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
7
27
|
def process event, config
|
8
|
-
data =
|
28
|
+
data = config[:data]
|
9
29
|
|
10
|
-
headers = config[:headers].to_s.strip.downcase == 'true'
|
30
|
+
headers = config[:headers].to_s.strip.downcase == 'true'
|
11
31
|
|
12
32
|
rows = CSV.new data, headers: headers
|
13
33
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class ReadFile < Flux
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
{
|
7
|
+
name: 'ReadFile',
|
8
|
+
description: 'Read a file.',
|
9
|
+
config: {
|
10
|
+
name: {
|
11
|
+
description: 'The name of the file to read.',
|
12
|
+
type: 'text',
|
13
|
+
value: 'file.csv',
|
14
|
+
},
|
15
|
+
directory: {
|
16
|
+
description: 'The directory in which to read the file. Leave blank for the current directory.',
|
17
|
+
type: 'text',
|
18
|
+
shrink: true,
|
19
|
+
value: '',
|
20
|
+
},
|
21
|
+
path: {
|
22
|
+
description: 'The path in the event to return the contents of the file.',
|
23
|
+
type: 'text',
|
24
|
+
value: 'content',
|
25
|
+
},
|
26
|
+
},
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def process event, config
|
31
|
+
file = config[:name]
|
32
|
+
|
33
|
+
file = File.join(config[:directory], file) if config[:directory].to_s != ''
|
34
|
+
|
35
|
+
content = File.open(file).read
|
36
|
+
|
37
|
+
{
|
38
|
+
config[:path] => content
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -27,15 +27,19 @@ module Mushy
|
|
27
27
|
details
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def adjust input
|
31
|
+
|
32
|
+
the_browser = input[:browser]
|
33
|
+
the_result = input[:result]
|
34
|
+
the_config = input[:config]
|
31
35
|
|
32
36
|
options = {
|
33
|
-
path:
|
34
|
-
full: ['true', ''].include?(
|
35
|
-
quality: (
|
37
|
+
path: the_config[:path],
|
38
|
+
full: ['true', ''].include?(the_config[:full].to_s),
|
39
|
+
quality: (the_config[:quality].to_s == '' ? '100' : the_config[:quality]).to_i
|
36
40
|
}
|
37
41
|
|
38
|
-
|
42
|
+
the_browser.screenshot options
|
39
43
|
|
40
44
|
options
|
41
45
|
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'pony'
|
2
|
+
|
3
|
+
module Mushy
|
4
|
+
|
5
|
+
class Smtp < Flux
|
6
|
+
|
7
|
+
def self.details
|
8
|
+
{
|
9
|
+
name: 'Smtp',
|
10
|
+
description: 'Send email through SMTP.',
|
11
|
+
config: {
|
12
|
+
from: {
|
13
|
+
description: 'From whom the email will be sent.',
|
14
|
+
type: 'text',
|
15
|
+
shrink: true,
|
16
|
+
value: '',
|
17
|
+
},
|
18
|
+
to: {
|
19
|
+
description: 'To whom the email should be sent.',
|
20
|
+
type: 'text',
|
21
|
+
value: '',
|
22
|
+
},
|
23
|
+
subject: {
|
24
|
+
description: 'The subject of the email.',
|
25
|
+
type: 'text',
|
26
|
+
value: '',
|
27
|
+
},
|
28
|
+
body: {
|
29
|
+
description: 'The text body of the email.',
|
30
|
+
type: 'textarea',
|
31
|
+
value: '',
|
32
|
+
},
|
33
|
+
html_body: {
|
34
|
+
description: 'The HTML body of the email.',
|
35
|
+
type: 'textarea',
|
36
|
+
value: '',
|
37
|
+
},
|
38
|
+
attachment_file: {
|
39
|
+
description: 'The full path of a file to attach.',
|
40
|
+
type: 'text',
|
41
|
+
shrink: true,
|
42
|
+
value: '',
|
43
|
+
},
|
44
|
+
address: {
|
45
|
+
description: 'The address of the SMTP server.',
|
46
|
+
type: 'text',
|
47
|
+
value: 'smtp.gmail.com',
|
48
|
+
},
|
49
|
+
port: {
|
50
|
+
description: 'The SMTP server port.',
|
51
|
+
type: 'integer',
|
52
|
+
value: '587',
|
53
|
+
},
|
54
|
+
domain: {
|
55
|
+
description: 'The email domain.',
|
56
|
+
type: 'text',
|
57
|
+
value: 'gmail.com',
|
58
|
+
},
|
59
|
+
username: {
|
60
|
+
description: 'The username.',
|
61
|
+
type: 'text',
|
62
|
+
value: '',
|
63
|
+
},
|
64
|
+
password: {
|
65
|
+
description: 'The password.',
|
66
|
+
type: 'text',
|
67
|
+
value: '',
|
68
|
+
},
|
69
|
+
},
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def process event, config
|
74
|
+
options = adjust(cleanup({
|
75
|
+
from: config[:from],
|
76
|
+
to: config[:to],
|
77
|
+
subject: config[:subject],
|
78
|
+
body: config[:body],
|
79
|
+
html_body: config[:html_body],
|
80
|
+
via_options: get_via_options_from(config)
|
81
|
+
}))
|
82
|
+
|
83
|
+
if (config[:attachment_file].to_s != '')
|
84
|
+
options[:attachments] = { config[:attachment_file].split("\/")[-1] => File.read(config[:attachment_file]) }
|
85
|
+
end
|
86
|
+
|
87
|
+
result = Pony.mail options
|
88
|
+
options.tap { |x| x.delete(:via_options) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def adjust options
|
92
|
+
options.tap { |x| x[:via] = 'smtp' }
|
93
|
+
end
|
94
|
+
|
95
|
+
def cleanup options
|
96
|
+
options.tap do |hash|
|
97
|
+
hash.delete_if { |_, v| v.to_s == '' }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_via_options_from config
|
102
|
+
{
|
103
|
+
address: config[:address],
|
104
|
+
port: config[:port].to_s,
|
105
|
+
user_name: config[:username],
|
106
|
+
password: config[:password],
|
107
|
+
domain: config[:domain],
|
108
|
+
authentication: :plain,
|
109
|
+
enable_starttls_auto: true,
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -27,12 +27,15 @@ module Mushy
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def process event, config
|
30
|
+
file = config[:name]
|
30
31
|
|
31
|
-
File.
|
32
|
+
file = File.join(config[:directory], file) if config[:directory].to_s != ''
|
33
|
+
|
34
|
+
File.open(file, 'w') { |f| f.write config[:data] }
|
32
35
|
|
33
36
|
{}
|
34
37
|
end
|
35
38
|
|
36
39
|
end
|
37
40
|
|
38
|
-
end
|
41
|
+
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.2.
|
7
|
+
s.version = '0.2.6'
|
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.'
|
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency 'ferrum'
|
25
25
|
s.add_runtime_dependency 'nokogiri'
|
26
26
|
s.add_runtime_dependency 'faraday'
|
27
|
+
s.add_runtime_dependency 'pony'
|
27
28
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pony
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: This tool assists in the creation and processing of workflows.
|
126
140
|
email: darren@cauthon.com
|
127
141
|
executables:
|
@@ -144,13 +158,17 @@ files:
|
|
144
158
|
- lib/mushy/fluxs/build_csv.rb
|
145
159
|
- lib/mushy/fluxs/cli.rb
|
146
160
|
- lib/mushy/fluxs/collection.rb
|
161
|
+
- lib/mushy/fluxs/environment.rb
|
147
162
|
- lib/mushy/fluxs/filter.rb
|
148
163
|
- lib/mushy/fluxs/format.rb
|
149
164
|
- lib/mushy/fluxs/get.rb
|
150
165
|
- lib/mushy/fluxs/ls.rb
|
151
166
|
- lib/mushy/fluxs/parse_html.rb
|
167
|
+
- lib/mushy/fluxs/pdf.rb
|
152
168
|
- lib/mushy/fluxs/read_csv.rb
|
169
|
+
- lib/mushy/fluxs/read_file.rb
|
153
170
|
- lib/mushy/fluxs/screenshot.rb
|
171
|
+
- lib/mushy/fluxs/smtp.rb
|
154
172
|
- lib/mushy/fluxs/write_file.rb
|
155
173
|
- lib/mushy/masher.rb
|
156
174
|
- lib/mushy/run.rb
|