mushy 0.2.3 → 0.3.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/builder/api.rb +29 -2
- data/lib/mushy/fluxs/browser.rb +3 -3
- data/lib/mushy/fluxs/environment.rb +28 -0
- data/lib/mushy/fluxs/git_log.rb +86 -0
- data/lib/mushy/fluxs/interval.rb +75 -0
- data/lib/mushy/fluxs/pdf.rb +46 -0
- data/lib/mushy/fluxs/screenshot.rb +9 -5
- data/lib/mushy/fluxs/smtp.rb +115 -0
- data/mushy.gemspec +3 -1
- metadata +34 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a41b5499e19c46d620ec9794fb8265224ce142516be73f977cfacc5597a844f
|
4
|
+
data.tar.gz: c74dfd1f76f24da513947edba159a97f4cf613308775346fcf22d8d8eb69a71e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ca21536b4b8d740c619ce7632d86d33b7b3db3b36d8279839bf1ceeb6fbd67edec6cd9f38bca7ce15d870223034c20b5bc46c7c55d3d15adda794b23e867de
|
7
|
+
data.tar.gz: 0d0254cabb3bd1943872f3db3afede763b9edf4773cc08b4c1dbe54f86f2c3ce9fa55cd24d42b2a30b53044e58925446a0deb504372b57d3c2905ad0fd18098b
|
data/lib/mushy/builder/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'daemons'
|
2
|
+
|
1
3
|
module Mushy
|
2
4
|
|
3
5
|
module Builder
|
@@ -32,9 +34,34 @@ module Mushy
|
|
32
34
|
file = "#{file}.json" unless file.downcase.end_with?('.json')
|
33
35
|
flow = File.open(file).read
|
34
36
|
flow = Mushy::Flow.parse flow
|
35
|
-
flux = flow.fluxs.select { |x| x.type == 'Cli' }.first
|
36
37
|
|
37
|
-
|
38
|
+
service_fluxes = flow.fluxs.select { |x| x.respond_to? :loop }
|
39
|
+
|
40
|
+
pwd = Dir.pwd
|
41
|
+
|
42
|
+
if service_fluxes.any?
|
43
|
+
calls = service_fluxes
|
44
|
+
.map { |s| { flux: s, proc: ->(e) do
|
45
|
+
Dir.chdir pwd
|
46
|
+
Mushy::Runner.new.start e, s, flow
|
47
|
+
end } }
|
48
|
+
.map { |p| ->() { p[:flux].loop &p[:proc] } }
|
49
|
+
.map { |x| ->() { loop &x } }
|
50
|
+
.map { |x| run_as_a_daemon &x }
|
51
|
+
|
52
|
+
puts calls.inspect
|
53
|
+
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
|
57
|
+
cli_flux = flow.fluxs.select { |x| x.kind_of?(Mushy::Cli) }.first
|
58
|
+
|
59
|
+
Mushy::Runner.new.start event, cli_flux, flow
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.run_as_a_daemon &block
|
63
|
+
#block.call
|
64
|
+
Daemons.call(&block).pid.pid
|
38
65
|
end
|
39
66
|
|
40
67
|
def self.get_flow file
|
data/lib/mushy/fluxs/browser.rb
CHANGED
@@ -105,15 +105,15 @@ 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
|
@@ -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,86 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class GitLog < Bash
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
{
|
7
|
+
name: 'GitLog',
|
8
|
+
description: 'Return git logs.',
|
9
|
+
config: {
|
10
|
+
directory: {
|
11
|
+
description: 'The working directory in which the command will be run.',
|
12
|
+
type: 'text',
|
13
|
+
shrink: true,
|
14
|
+
value: '',
|
15
|
+
},
|
16
|
+
after: {
|
17
|
+
description: 'Filter for commits after this',
|
18
|
+
type: 'text',
|
19
|
+
shrink: true,
|
20
|
+
value: '',
|
21
|
+
},
|
22
|
+
before: {
|
23
|
+
description: 'Filter for commits before this',
|
24
|
+
type: 'text',
|
25
|
+
shrink: true,
|
26
|
+
value: '',
|
27
|
+
},
|
28
|
+
author: {
|
29
|
+
description: 'Filter for commits by this author',
|
30
|
+
type: 'text',
|
31
|
+
shrink: true,
|
32
|
+
value: '',
|
33
|
+
},
|
34
|
+
committer: {
|
35
|
+
description: 'Filter for commits by this committer',
|
36
|
+
type: 'text',
|
37
|
+
shrink: true,
|
38
|
+
value: '',
|
39
|
+
},
|
40
|
+
},
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def process event, config
|
45
|
+
|
46
|
+
config[:command] = 'git log'
|
47
|
+
|
48
|
+
if config[:directory].to_s != ''
|
49
|
+
config[:command] = "cd \"#{config[:directory]}\";#{config[:command]}"
|
50
|
+
end
|
51
|
+
|
52
|
+
[:after, :before, :author, :committer]
|
53
|
+
.select { |x| config[x].to_s != ''}
|
54
|
+
.each { |k| config[:command] = "#{config[:command]} --#{k}=\"#{config[k]}\"" }
|
55
|
+
|
56
|
+
result = super event, config
|
57
|
+
|
58
|
+
return result unless result[:success]
|
59
|
+
|
60
|
+
result[:text].split("\n\n").reduce([]) do |results, line|
|
61
|
+
if line.start_with? 'commit'
|
62
|
+
results << { message: line.sub('commit', 'commit:') }
|
63
|
+
else
|
64
|
+
results[-1][:message] = results[-1][:message] + "\nMessage: " + line.strip
|
65
|
+
end
|
66
|
+
results
|
67
|
+
end.map { |x| x[:message] }.map do |line|
|
68
|
+
line.split("\n").reduce({}) do |t, i|
|
69
|
+
segments = i.split ':'
|
70
|
+
key = segments.shift.strip.downcase.to_sym
|
71
|
+
t[key] = segments.map { |y| y.strip }.join ':'
|
72
|
+
t
|
73
|
+
end
|
74
|
+
end.map do |commit|
|
75
|
+
commit.tap do |x|
|
76
|
+
segments = x[:author].split '<'
|
77
|
+
x[:author_name] = segments.shift.strip
|
78
|
+
x[:author_email] = segments.join('').strip.gsub('>', '')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Mushy
|
4
|
+
|
5
|
+
class Interval < Flux
|
6
|
+
|
7
|
+
def self.setup
|
8
|
+
{
|
9
|
+
seconds: ->(x) { x },
|
10
|
+
minutes: ->(x) { x * 60 },
|
11
|
+
hours: ->(x) { x * 60 * 60 },
|
12
|
+
days: ->(x) { x * 60 * 60 * 24 },
|
13
|
+
weeks: ->(x) { x * 60 * 60 * 24 * 7 },
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.details
|
18
|
+
{
|
19
|
+
name: 'Interval',
|
20
|
+
description: 'Fire an event every X minutes.',
|
21
|
+
config: {},
|
22
|
+
}.tap do |c|
|
23
|
+
setup.keys.each do |key|
|
24
|
+
c[:config][key] = {
|
25
|
+
description: "#{key.to_s.capitalize} until the job is fired again.",
|
26
|
+
type: 'integer',
|
27
|
+
shrink: true,
|
28
|
+
value: '',
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def loop &block
|
35
|
+
event = { time: time }
|
36
|
+
block.call event
|
37
|
+
sleep time
|
38
|
+
end
|
39
|
+
|
40
|
+
def time
|
41
|
+
the_time = self.class.setup.keys
|
42
|
+
.select { |x| config[x].to_s != '' }
|
43
|
+
.map { |x| self.class.setup[x].call(config[x].to_i) }
|
44
|
+
.sum
|
45
|
+
|
46
|
+
the_time > 0 ? the_time : 60
|
47
|
+
end
|
48
|
+
|
49
|
+
def process event, config
|
50
|
+
now = Time.now
|
51
|
+
{
|
52
|
+
year: nil,
|
53
|
+
month: nil,
|
54
|
+
day: nil,
|
55
|
+
hour: nil,
|
56
|
+
minute: :min,
|
57
|
+
second: :sec,
|
58
|
+
nanosecond: :nsec,
|
59
|
+
utc_offset: nil,
|
60
|
+
weekday: :wday,
|
61
|
+
day_of_month: :mday,
|
62
|
+
day_of_year: :yday,
|
63
|
+
string: :to_s,
|
64
|
+
epoch_integer: :to_i,
|
65
|
+
epoch_float: :to_f,
|
66
|
+
}.reduce({}) do |t, i|
|
67
|
+
method = i[1] || i[0]
|
68
|
+
t[i[0]] = now.send method
|
69
|
+
t
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
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
|
@@ -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
|
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.3.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.'
|
@@ -24,4 +24,6 @@ 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'
|
28
|
+
s.add_runtime_dependency 'daemons'
|
27
29
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -122,6 +122,34 @@ 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'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: daemons
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
description: This tool assists in the creation and processing of workflows.
|
126
154
|
email: darren@cauthon.com
|
127
155
|
executables:
|
@@ -144,14 +172,19 @@ files:
|
|
144
172
|
- lib/mushy/fluxs/build_csv.rb
|
145
173
|
- lib/mushy/fluxs/cli.rb
|
146
174
|
- lib/mushy/fluxs/collection.rb
|
175
|
+
- lib/mushy/fluxs/environment.rb
|
147
176
|
- lib/mushy/fluxs/filter.rb
|
148
177
|
- lib/mushy/fluxs/format.rb
|
149
178
|
- lib/mushy/fluxs/get.rb
|
179
|
+
- lib/mushy/fluxs/git_log.rb
|
180
|
+
- lib/mushy/fluxs/interval.rb
|
150
181
|
- lib/mushy/fluxs/ls.rb
|
151
182
|
- lib/mushy/fluxs/parse_html.rb
|
183
|
+
- lib/mushy/fluxs/pdf.rb
|
152
184
|
- lib/mushy/fluxs/read_csv.rb
|
153
185
|
- lib/mushy/fluxs/read_file.rb
|
154
186
|
- lib/mushy/fluxs/screenshot.rb
|
187
|
+
- lib/mushy/fluxs/smtp.rb
|
155
188
|
- lib/mushy/fluxs/write_file.rb
|
156
189
|
- lib/mushy/masher.rb
|
157
190
|
- lib/mushy/run.rb
|