mushy 0.15.3 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/hey.mushy +29 -0
  3. data/lib/mushy/builder/api.rb +15 -3
  4. data/lib/mushy/builder/documentation.rb +37 -0
  5. data/lib/mushy/builder/index.rb +88 -15
  6. data/lib/mushy/flux.rb +5 -1
  7. data/lib/mushy/fluxs/bash.rb +24 -0
  8. data/lib/mushy/fluxs/browser.rb +120 -0
  9. data/lib/mushy/fluxs/build_csv.rb +23 -0
  10. data/lib/mushy/fluxs/cli.rb +12 -0
  11. data/lib/mushy/fluxs/collection.rb +3 -1
  12. data/lib/mushy/fluxs/document.rb +16 -0
  13. data/lib/mushy/fluxs/environment.rb +13 -0
  14. data/lib/mushy/fluxs/file_watch.rb +30 -1
  15. data/lib/mushy/fluxs/filter.rb +28 -0
  16. data/lib/mushy/fluxs/format.rb +42 -1
  17. data/lib/mushy/fluxs/git_log.rb +2 -0
  18. data/lib/mushy/fluxs/global_variables.rb +17 -1
  19. data/lib/mushy/fluxs/interval.rb +2 -0
  20. data/lib/mushy/fluxs/ls.rb +112 -0
  21. data/lib/mushy/fluxs/parse_html.rb +37 -1
  22. data/lib/mushy/fluxs/pdf.rb +72 -1
  23. data/lib/mushy/fluxs/pwd.rb +42 -1
  24. data/lib/mushy/fluxs/read_csv.rb +27 -0
  25. data/lib/mushy/fluxs/read_file.rb +24 -9
  26. data/lib/mushy/fluxs/read_json.rb +21 -7
  27. data/lib/mushy/fluxs/screenshot.rb +72 -2
  28. data/lib/mushy/fluxs/sense_hat_environmental_sensors.rb +2 -0
  29. data/lib/mushy/fluxs/sense_hat_led_matrix.rb +2 -0
  30. data/lib/mushy/fluxs/simple_python_program.rb +1 -0
  31. data/lib/mushy/fluxs/smtp.rb +2 -1
  32. data/lib/mushy/fluxs/stdout.rb +2 -0
  33. data/lib/mushy/fluxs/times.rb +9 -0
  34. data/lib/mushy/fluxs/twilio_message.rb +113 -0
  35. data/lib/mushy/fluxs/write_file.rb +48 -0
  36. data/lib/mushy/fluxs/write_json.rb +16 -0
  37. data/mushy.gemspec +1 -1
  38. metadata +8 -7
  39. data/lib/mushy/fluxs/print.rb +0 -26
@@ -5,10 +5,12 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'ReadFile',
8
+ title: 'Read File',
9
+ fluxGroup: { name: 'Files' },
8
10
  description: 'Read a file.',
9
11
  config: {
10
- name: {
11
- description: 'The name of the file to read.',
12
+ file: {
13
+ description: 'The file to read.',
12
14
  type: 'text',
13
15
  value: 'file.csv',
14
16
  },
@@ -18,24 +20,37 @@ module Mushy
18
20
  shrink: true,
19
21
  value: '',
20
22
  },
21
- path: {
22
- description: 'The path in the event to return the contents of the file.',
23
- type: 'text',
24
- value: 'content',
25
- },
23
+ key: {
24
+ description: 'The key in the resulting event to return the contents of the file.',
25
+ type: 'text',
26
+ value: 'content',
27
+ },
26
28
  },
29
+ examples: {
30
+ "Example" => {
31
+ description: 'Using this Flux to read the contents of a text file.',
32
+ input: {
33
+ file: "data.csv"
34
+ },
35
+ config: {
36
+ file: '{{file}}',
37
+ key: 'csvdata'
38
+ },
39
+ result: { csvdata: 'a,b,c\nd\n\e\f'}
40
+ },
41
+ }
27
42
  }
28
43
  end
29
44
 
30
45
  def process event, config
31
- file = config[:name]
46
+ file = config[:file]
32
47
 
33
48
  file = File.join(config[:directory], file) if config[:directory].to_s != ''
34
49
 
35
50
  content = File.open(file).read
36
51
 
37
52
  {
38
- config[:path] => content
53
+ config[:key] => content
39
54
  }
40
55
  end
41
56
 
@@ -7,20 +7,34 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'ReadJson',
10
+ title: 'Deserialize JSON',
11
+ fluxGroup: { name: 'JSON' },
10
12
  description: 'Read JSON and output it as an event.',
11
13
  config: {
12
- json: {
13
- description: 'The JSON contents that will be returned as an event.',
14
- type: 'text',
15
- value: 'json',
16
- },
14
+ key: {
15
+ description: 'The JSON contents that will be returned as an event.',
16
+ type: 'text',
17
+ value: 'json',
18
+ },
17
19
  },
20
+ examples: {
21
+ "Example" => {
22
+ description: 'Using this Flux to deserialize a JSON string.',
23
+ input: {
24
+ orange: "{\"people\":[{\"name\":\"John\"},{\"name\":\"Jane\"}]}"
25
+ },
26
+ config: {
27
+ key: 'orange'
28
+ },
29
+ result: { people: [ { name: "John" }, { name: "Jane" } ] }
30
+ },
31
+ }
18
32
  }
19
33
  end
20
34
 
21
35
  def process event, config
22
- return nil unless config[:json].to_s != ''
23
- JSON.parse config[:json]
36
+ return nil unless event[config[:key]].to_s != ''
37
+ JSON.parse event[config[:key]]
24
38
  end
25
39
 
26
40
  end
@@ -5,7 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  details = Browser.details
7
7
  details[:name] = 'Screenshot'
8
- details[:description] = 'Take a screenshot of the browser.'
8
+ details[:description] = 'Take a screenshot of the browser. This works the same as the Browser, but with a screenshot at the end.'
9
9
 
10
10
  details[:config].merge!(Mushy::WriteFile.file_saving_config.tap do |x|
11
11
  x[x.keys.first][:value] = 'file.jpg'
@@ -23,7 +23,77 @@ module Mushy
23
23
  shrink: true,
24
24
  value: '',
25
25
  }
26
- details
26
+ details.tap do |config|
27
+ config[:examples] = {
28
+ "Screenshot of google.com" => {
29
+ description: 'This will open https://www.google.com and take a screenshot.',
30
+ config: {
31
+ url: "https://www.google.com",
32
+ file: 'file.jpg'
33
+ },
34
+ result: {
35
+ url: "https://www.google.com/",
36
+ status: 200,
37
+ title: "Google",
38
+ cookies: [
39
+ {
40
+ name: "1P_JAR",
41
+ value: "2021-10-07-21",
42
+ domain: ".google.com",
43
+ path: "/",
44
+ expires: 1636232420.005369,
45
+ size: 19,
46
+ httpOnly: false,
47
+ secure: true,
48
+ session: false,
49
+ sameSite: "None",
50
+ priority: "Medium"
51
+ }
52
+ ],
53
+ headers: {},
54
+ time: 1.520785498,
55
+ body: "...",
56
+ options: {
57
+ path: "file.jpg",
58
+ full: true,
59
+ quality: 100
60
+ },
61
+ file: {
62
+ inode: "439545",
63
+ hard_links: 1,
64
+ owner: "pi",
65
+ group: "pi",
66
+ size: 54269,
67
+ date: {
68
+ year: 2021,
69
+ month: 10,
70
+ day: 7,
71
+ hour: 16,
72
+ minute: 0,
73
+ second: 20,
74
+ nanosecond: 444437482,
75
+ utc_offset: -18000,
76
+ weekday: 4,
77
+ day_of_month: 7,
78
+ day_of_year: 280,
79
+ string: "2021-10-07 16:00:20 -0500",
80
+ epoch_integer: 1633640420,
81
+ epoch_float: 1633640420.4444375,
82
+ seconds_ago: 0.016297478
83
+ },
84
+ name: "file.jpg",
85
+ type: "-",
86
+ owner_permission: "rw-",
87
+ group_permission: "r--",
88
+ other_permission: "r--",
89
+ directory: "/home/pi/Desktop/mushy",
90
+ path: "/home/pi/Desktop/mushy/file.jpg"
91
+ }
92
+ }
93
+ },
94
+ }
95
+ config[:fluxGroup] = { name: 'Export' }
96
+ end
27
97
  end
28
98
 
29
99
  def adjust input
@@ -5,7 +5,9 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'SenseHatEnvironmentalSensors',
8
+ title: 'Read Environmental Sensors',
8
9
  description: 'Pull values from the Sense HAT environmental sensors.',
10
+ fluxGroup: { name: 'SenseHAT' },
9
11
  config: Mushy::SimplePythonProgram.default_config,
10
12
  }.tap do |c|
11
13
  measurements
@@ -5,7 +5,9 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'SenseHatLedMatrix',
8
+ title: 'Use LED Matrix',
8
9
  description: 'Interface with the LED Matrix.',
10
+ fluxGroup: { name: 'SenseHAT' },
9
11
  config: Mushy::SimplePythonProgram.default_config.tap do |config|
10
12
  config[:get_pixels] = {
11
13
  description: 'Specify the pixels you want returned as events. Use "all" to return all 64, 3,3 to return x:3 y:3, or "none" to return none.',
@@ -6,6 +6,7 @@ module Mushy
6
6
  Mushy::Bash.details[:config].tap do |config|
7
7
  config.delete :command
8
8
  config.delete :directory
9
+ config[:fluxGroup] = { name: 'Execute' }
9
10
  end
10
11
  end
11
12
 
@@ -48,8 +48,9 @@ module Mushy
48
48
 
49
49
  def self.details
50
50
  {
51
- name: 'Smtp',
51
+ name: 'Send Email Using SMTP',
52
52
  description: 'Send email through SMTP.',
53
+ fluxGroup: { name: 'Email' },
53
54
  config: {
54
55
  from: {
55
56
  description: 'From whom the email will be sent.',
@@ -5,6 +5,8 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'Stdout',
8
+ title: 'Export text to stdout',
9
+ fluxGroup: { name: 'Environment' },
8
10
  description: 'Standard Out',
9
11
  config: {
10
12
  message: {
@@ -5,13 +5,22 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'Times',
8
+ title: 'Repeat an event X times',
8
9
  description: 'Return the event passed to it, X times.',
10
+ fluxGroup: { name: 'Flows' },
9
11
  config: {
10
12
  times: {
11
13
  description: 'The number of times this event should be returned.',
12
14
  type: 'integer',
13
15
  value: '1',
14
16
  },
17
+ },
18
+ examples: {
19
+ "Basic Example" => {
20
+ input: {name: "Elephant"},
21
+ config: {times: 2},
22
+ result: [ { name: "Elephant", index: 0 }, { name: "Elephant", index: 1 } ],
23
+ }
15
24
  }
16
25
  }
17
26
  end
@@ -0,0 +1,113 @@
1
+ module Mushy
2
+
3
+ class TwilioMessage < Bash
4
+
5
+ def self.details
6
+ {
7
+ name: 'TwilioMessage',
8
+ title: 'Send SMS',
9
+ fluxGroup: { name: 'Twilio' },
10
+ description: 'Send a Twilio Message.',
11
+ config: {
12
+ account_sid: {
13
+ description: 'Your Twilio Account SID.',
14
+ type: 'text',
15
+ value: '{{twilio_account_sid}}',
16
+ },
17
+ auth_token: {
18
+ description: 'Your Twilio Auth Token.',
19
+ type: 'text',
20
+ value: '{{twilio_auth_token}}',
21
+ },
22
+ from: {
23
+ description: 'The phone number from which the message will be sent.',
24
+ type: 'text',
25
+ value: '+1{{from}}',
26
+ },
27
+ to: {
28
+ description: 'The phone number to which the message will be sent.',
29
+ type: 'text',
30
+ value: '+1{{to}}',
31
+ },
32
+ body: {
33
+ description: 'The content of the message.',
34
+ type: 'text',
35
+ value: '{{body}}',
36
+ },
37
+ media_url: {
38
+ description: 'A URL to a file that can be included with the text message, like https://.../your_file.png.',
39
+ type: 'text',
40
+ value: '',
41
+ shrink: true,
42
+ },
43
+ },
44
+ examples: {
45
+ "Basic Example" => {
46
+ description: "This is what a basic text message.",
47
+ input: { message: "Hello World!" },
48
+ config: {
49
+ account_sid: 'Your Twilio Account SID',
50
+ auth_token: 'Your Twilio Auth Token',
51
+ from: '+15555555555',
52
+ to: '+14444444444',
53
+ body: '{{message}}',
54
+ },
55
+ result: {
56
+ sid: "the sid",
57
+ date_created: "Sun, 10 Oct 2021 20:16:48 +0000",
58
+ date_updated: "Sun, 10 Oct 2021 20:16:48 +0000",
59
+ date_sent: nil,
60
+ account_sid: "account sid",
61
+ to: "+15555555555",
62
+ from: "+14444444444",
63
+ messaging_service_sid: nil,
64
+ body: "Hello World!",
65
+ status: "queued",
66
+ num_segments: "1",
67
+ num_media: "0",
68
+ direction: "outbound-api",
69
+ api_version: "2010-04-01",
70
+ price: nil,
71
+ price_unit: "USD",
72
+ error_code: nil,
73
+ error_message: nil,
74
+ uri: "/2010-04-01/Accounts/ABC/Messages/DEF.json",
75
+ subresource_uris: {
76
+ media: "/2010-04-01/Accounts/ABC/Messages/DEF/Media.json"
77
+ }
78
+ }
79
+ },
80
+ "A Failed Call" => {
81
+ description: "This is what a failed call may look like.",
82
+ result: {
83
+ code: 20003,
84
+ detail: "Your AccountSid or AuthToken was incorrect.",
85
+ message: "Authentication Error - invalid username",
86
+ more_info: "https://www.twilio.com/docs/errors/20003",
87
+ status: 401
88
+ }
89
+ },
90
+ },
91
+ }
92
+ end
93
+
94
+ def process event, config
95
+ arguments = {
96
+ from: "From",
97
+ to: "To",
98
+ body: "Body",
99
+ media_url: "MediaUrl",
100
+ }.select { |x| config[x].to_s != "" }
101
+ .map { |x| [x[1], config[x[0]].to_s.gsub('"', '\\"')] }
102
+ .reduce("") { |t, i| "#{t} --data-urlencode \"#{i[0]}=#{i[1]}\"" }
103
+
104
+ config[:command] = "curl -X POST https://api.twilio.com/2010-04-01/Accounts/#{config[:account_sid]}/Messages.json -u #{config[:account_sid]}:#{config[:auth_token]} #{arguments}"
105
+
106
+ result = super event, config
107
+
108
+ JSON.parse result[:text]
109
+ end
110
+
111
+ end
112
+
113
+ end
@@ -5,7 +5,9 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'WriteFile',
8
+ title: 'Write File',
8
9
  description: 'Write a file.',
10
+ fluxGroup: { name: 'Files' },
9
11
  config: file_saving_config.merge({
10
12
  data: {
11
13
  description: 'The text to write. You can use Liquid templating here to pull data from the event, or write hardcoded data.',
@@ -13,6 +15,52 @@ module Mushy
13
15
  value: '{{data}}',
14
16
  },
15
17
  }),
18
+ examples: {
19
+ "Example" => {
20
+ description: 'Using this Flux to write the contents of a text file. Details about the file are returned.',
21
+ input: {
22
+ file: "data.csv",
23
+ content: "a,b,c\nd,e,f",
24
+ },
25
+ config: {
26
+ file: '{{file}}',
27
+ data: '{{content}}'
28
+ },
29
+ result: {
30
+ file: {
31
+ inode: "439540",
32
+ hard_links: 1,
33
+ owner: "pi",
34
+ group: "pi",
35
+ size: 3,
36
+ date: {
37
+ year: 2021,
38
+ month: 10,
39
+ day: 7,
40
+ hour: 15,
41
+ minute: 41,
42
+ second: 14,
43
+ nanosecond: 163590058,
44
+ utc_offset: -18000,
45
+ weekday: 4,
46
+ day_of_month: 7,
47
+ day_of_year: 280,
48
+ string: "2021-10-07 15:41:14 -0500",
49
+ epoch_integer: 1633639274,
50
+ epoch_float: 1633639274.1635902,
51
+ seconds_ago: 0.018665617
52
+ },
53
+ name: "file.csv",
54
+ type: "-",
55
+ owner_permission: "rw-",
56
+ group_permission: "r--",
57
+ other_permission: "r--",
58
+ directory: "/home/pi/Desktop/mushy",
59
+ path: "/home/pi/Desktop/mushy/file.csv"
60
+ }
61
+ }
62
+ },
63
+ }
16
64
  }
17
65
  end
18
66
 
@@ -7,7 +7,9 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'WriteJson',
10
+ title: 'Serialize as JSON',
10
11
  description: 'Write the incoming event as JSON.',
12
+ fluxGroup: { name: 'JSON' },
11
13
  config: {
12
14
  key: {
13
15
  description: 'The key of the outgoing field that will contain the JSON.',
@@ -15,6 +17,20 @@ module Mushy
15
17
  value: 'json',
16
18
  },
17
19
  },
20
+ examples: {
21
+ "Example" => {
22
+ description: 'Using this Flux to convert input to a JSON string.',
23
+ input: {
24
+ people: [ { name: "John" }, { name: "Jane" } ]
25
+ },
26
+ config: {
27
+ key: 'apple'
28
+ },
29
+ result: {
30
+ apple: "{\"people\":[{\"name\":\"John\"},{\"name\":\"Jane\"}]}"
31
+ }
32
+ },
33
+ }
18
34
  }
19
35
  end
20
36
 
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.15.3'
7
+ s.version = '0.19.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,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-11-23 00:00:00.000000000 Z
@@ -172,11 +172,13 @@ extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
174
  - bin/mushy
175
+ - hey.mushy
175
176
  - lib/mushy.rb
176
177
  - lib/mushy/builder/api.rb
177
178
  - lib/mushy/builder/axios.rb
178
179
  - lib/mushy/builder/bulma.rb
179
180
  - lib/mushy/builder/dark.rb
181
+ - lib/mushy/builder/documentation.rb
180
182
  - lib/mushy/builder/index.rb
181
183
  - lib/mushy/builder/vue.rb
182
184
  - lib/mushy/date_parts.rb
@@ -200,7 +202,6 @@ files:
200
202
  - lib/mushy/fluxs/ls.rb
201
203
  - lib/mushy/fluxs/parse_html.rb
202
204
  - lib/mushy/fluxs/pdf.rb
203
- - lib/mushy/fluxs/print.rb
204
205
  - lib/mushy/fluxs/pwd.rb
205
206
  - lib/mushy/fluxs/read_csv.rb
206
207
  - lib/mushy/fluxs/read_file.rb
@@ -212,6 +213,7 @@ files:
212
213
  - lib/mushy/fluxs/smtp.rb
213
214
  - lib/mushy/fluxs/stdout.rb
214
215
  - lib/mushy/fluxs/times.rb
216
+ - lib/mushy/fluxs/twilio_message.rb
215
217
  - lib/mushy/fluxs/write_file.rb
216
218
  - lib/mushy/fluxs/write_json.rb
217
219
  - lib/mushy/masher.rb
@@ -225,7 +227,7 @@ homepage: https://cauthon.com
225
227
  licenses:
226
228
  - MIT
227
229
  metadata: {}
228
- post_install_message:
230
+ post_install_message:
229
231
  rdoc_options: []
230
232
  require_paths:
231
233
  - lib
@@ -240,9 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
242
  - !ruby/object:Gem::Version
241
243
  version: '0'
242
244
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.7.6.2
245
- signing_key:
245
+ rubygems_version: 3.2.15
246
+ signing_key:
246
247
  specification_version: 4
247
248
  summary: Process streams of work using common modules.
248
249
  test_files: []
@@ -1,26 +0,0 @@
1
- module Mushy
2
-
3
- class Print < Flux
4
-
5
- def self.details
6
- {
7
- name: 'Print',
8
- description: 'Print output to the screen.',
9
- config: {
10
- message: {
11
- description: 'The message to display',
12
- type: 'text',
13
- value: '',
14
- },
15
- }
16
- }
17
- end
18
-
19
- def process event, config
20
- puts config[:message]
21
- {}
22
- end
23
-
24
- end
25
-
26
- end