mushy 0.2.2 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e6ffdfb09e494e5ddbbf2a6dde4c33c2b29a0ac19af467bd00cb77b6f899067
4
- data.tar.gz: 4835fd407a77f62612d629994f323d37d4ea1b8f2053fa10c2b47141898659fe
3
+ metadata.gz: 92ba64469be678fe9889628ae7b6897f78935605605c83652d257f2c4a948d3d
4
+ data.tar.gz: 1fa13be3acb6a38f8062536d416630f92867ed93b8f28ac3c140f91a6dfd1385
5
5
  SHA512:
6
- metadata.gz: 236092d1c7ee52ec2f19815cd3e48f90d1178943b02ddfd8c966034599770ad4cadd43dace1ae2a66b960fadd75a5f382911eeb1d7667219d3bc65964d191a75
7
- data.tar.gz: 4e5a52fed081e20c0096ad4e6df08c5c46236776ccb0d4d01a3c69ac1e9244e628525ba8328df2bd201ed711a5afec05d3e41aa2156c279e8b00f2c01ee7ac8b
6
+ metadata.gz: d9aaebd4c3a70c7e64417eb515d719ad6e0bd0c6ccacdde4a2b8ae21845e77b63ee2ca0639d1207aa2d064c8aa3bda48f282a3f640e07b26c171cd1819191416
7
+ data.tar.gz: ba95b540eb1746ae7b525221c746aee163861c62956e3ac08e5405738bdf329eea32c0d8378283b6c625a1d1919d6f1fd11b936548822ce2a15c438651112a6f
@@ -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: 'cookies',
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: 'headers',
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 = special_browser_action browser, 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 special_browser_action browser, result
116
- result
115
+ def adjust input
116
+ input[:result]
117
117
  end
118
118
 
119
119
  def get_the_cookies_from event, config
120
- cookies = (event[config[:carry_cookies_from].to_sym])
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
- headers = (event[config[:carry_headers_from].to_sym])
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,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,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
@@ -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 = event[config[:key]]
28
+ data = config[:data]
9
29
 
10
- headers = config[:headers].to_s.strip.downcase == 'true' ? true : false
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 special_browser_action browser, result
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: config[:path],
34
- full: ['true', ''].include?(config[:full].to_s),
35
- quality: (config[:quality].to_s == '' ? '100' : config[:quality]).to_i
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
- browser.screenshot options
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.open(config[:name], 'w') { |f| f.write config[:data] }
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.2'
7
+ s.version = '0.2.7'
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.2
4
+ version: 0.2.7
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,18 @@ 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
165
+ - lib/mushy/fluxs/git_log.rb
150
166
  - lib/mushy/fluxs/ls.rb
151
167
  - lib/mushy/fluxs/parse_html.rb
168
+ - lib/mushy/fluxs/pdf.rb
152
169
  - lib/mushy/fluxs/read_csv.rb
170
+ - lib/mushy/fluxs/read_file.rb
153
171
  - lib/mushy/fluxs/screenshot.rb
172
+ - lib/mushy/fluxs/smtp.rb
154
173
  - lib/mushy/fluxs/write_file.rb
155
174
  - lib/mushy/masher.rb
156
175
  - lib/mushy/run.rb