mushy 0.17.0 → 0.18.0

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: 2a999131659ac9039500b30ed19769e5eefbcd1e8d7d6d17944f60ef498e05ce
4
- data.tar.gz: 490b583acb52f7100d62ff77acfb68d12aa49505c5f9a628ff47707e358d93c4
3
+ metadata.gz: 88a3578100f93b47791d83299597e4b6a1d1ccabfaa8628eb5172617facf9b95
4
+ data.tar.gz: fa722d8dd776c1e311bea24ad94303785fd93ccc16eeebcd93783f9d25c3e0f5
5
5
  SHA512:
6
- metadata.gz: 433b4bdb5716d5a035fb9b0b2a244d8d3a368a1338519aeca1e087545d9339baf44635a0562a8d3990115c2f6dc188a3465fb36c6b2f9de8d11126a872725eed
7
- data.tar.gz: 77bc7c6ca893188da063935bc6c4178eee03c20d985041ea8b1c170a4452a497ea4df974b6c0747ef65d56d621cfb751763268c6e1b2185d5c67eb064f34781a
6
+ metadata.gz: 4eafe788eccb281c1e15bdc0cfae4dca68f1146894a7d28569347673f28ef265b5b8aa90f7fb6c21245e1ba15fceac2f2677420cc643dd535c8cd54062c7642d
7
+ data.tar.gz: 2568f50f7cdf5569605d89fe7e088036d48f106d10f2b45c2b29a25038f145d29bb2566f9d7271f642b11307cb5e9259e72ac4fb1f1b3826178e977532e7c8b3
@@ -31,7 +31,17 @@ module Mushy
31
31
  end
32
32
 
33
33
  def self.start file, event
34
- file = "#{file}.mushy" unless file.downcase.end_with?('.mushy')
34
+ original_file = file
35
+ file = [file, "#{Dir.home}/.mushy/#{file}"]
36
+ .map { |x| (x.downcase.end_with?('.mushy') ? x : "#{x}.mushy") }
37
+ .select { |x| File.exist?(x) }
38
+ .first
39
+
40
+ unless file
41
+ puts "#{original_file} does not exist."
42
+ return
43
+ end
44
+
35
45
  flow = File.open(file).read
36
46
  flow = Mushy::Flow.parse flow
37
47
 
@@ -0,0 +1,112 @@
1
+ module Mushy
2
+
3
+ class TwilioMessage < Bash
4
+
5
+ def self.details
6
+ {
7
+ name: 'TwilioMessage',
8
+ title: 'Twilio Message',
9
+ description: 'Send a Twilio Message.',
10
+ config: {
11
+ account_sid: {
12
+ description: 'Your Twilio Account SID.',
13
+ type: 'text',
14
+ value: '{{twilio_account_sid}}',
15
+ },
16
+ auth_token: {
17
+ description: 'Your Twilio Auth Token.',
18
+ type: 'text',
19
+ value: '{{twilio_auth_token}}',
20
+ },
21
+ from: {
22
+ description: 'The phone number from which the message will be sent.',
23
+ type: 'text',
24
+ value: '+1{{from}}',
25
+ },
26
+ to: {
27
+ description: 'The phone number to which the message will be sent.',
28
+ type: 'text',
29
+ value: '+1{{to}}',
30
+ },
31
+ body: {
32
+ description: 'The content of the message.',
33
+ type: 'text',
34
+ value: '{{body}}',
35
+ },
36
+ media_url: {
37
+ description: 'A URL to a file that can be included with the text message, like https://.../your_file.png.',
38
+ type: 'text',
39
+ value: '',
40
+ shrink: true,
41
+ },
42
+ },
43
+ examples: {
44
+ "Basic Example" => {
45
+ description: "This is what a basic text message.",
46
+ input: { message: "Hello World!" },
47
+ config: {
48
+ account_sid: 'Your Twilio Account SID',
49
+ auth_token: 'Your Twilio Auth Token',
50
+ from: '+15555555555',
51
+ to: '+14444444444',
52
+ body: '{{message}}',
53
+ },
54
+ result: {
55
+ sid: "the sid",
56
+ date_created: "Sun, 10 Oct 2021 20:16:48 +0000",
57
+ date_updated: "Sun, 10 Oct 2021 20:16:48 +0000",
58
+ date_sent: nil,
59
+ account_sid: "account sid",
60
+ to: "+15555555555",
61
+ from: "+14444444444",
62
+ messaging_service_sid: nil,
63
+ body: "Hello World!",
64
+ status: "queued",
65
+ num_segments: "1",
66
+ num_media: "0",
67
+ direction: "outbound-api",
68
+ api_version: "2010-04-01",
69
+ price: nil,
70
+ price_unit: "USD",
71
+ error_code: nil,
72
+ error_message: nil,
73
+ uri: "/2010-04-01/Accounts/ABC/Messages/DEF.json",
74
+ subresource_uris: {
75
+ media: "/2010-04-01/Accounts/ABC/Messages/DEF/Media.json"
76
+ }
77
+ }
78
+ },
79
+ "A Failed Call" => {
80
+ description: "This is what a failed call may look like.",
81
+ result: {
82
+ code: 20003,
83
+ detail: "Your AccountSid or AuthToken was incorrect.",
84
+ message: "Authentication Error - invalid username",
85
+ more_info: "https://www.twilio.com/docs/errors/20003",
86
+ status: 401
87
+ }
88
+ },
89
+ },
90
+ }
91
+ end
92
+
93
+ def process event, config
94
+ arguments = {
95
+ from: "From",
96
+ to: "To",
97
+ body: "Body",
98
+ media_url: "MediaUrl",
99
+ }.select { |x| config[x].to_s != "" }
100
+ .map { |x| [x[1], config[x[0]].to_s.gsub('"', '\\"')] }
101
+ .reduce("") { |t, i| "#{t} --data-urlencode \"#{i[0]}=#{i[1]}\"" }
102
+
103
+ 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}"
104
+
105
+ result = super event, config
106
+
107
+ JSON.parse result[:text]
108
+ end
109
+
110
+ end
111
+
112
+ 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.17.0'
7
+ s.version = '0.18.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.17.0
4
+ version: 0.18.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
@@ -212,6 +212,7 @@ files:
212
212
  - lib/mushy/fluxs/smtp.rb
213
213
  - lib/mushy/fluxs/stdout.rb
214
214
  - lib/mushy/fluxs/times.rb
215
+ - lib/mushy/fluxs/twilio_message.rb
215
216
  - lib/mushy/fluxs/write_file.rb
216
217
  - lib/mushy/fluxs/write_json.rb
217
218
  - lib/mushy/masher.rb
@@ -225,7 +226,7 @@ homepage: https://cauthon.com
225
226
  licenses:
226
227
  - MIT
227
228
  metadata: {}
228
- post_install_message:
229
+ post_install_message:
229
230
  rdoc_options: []
230
231
  require_paths:
231
232
  - lib
@@ -240,9 +241,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
241
  - !ruby/object:Gem::Version
241
242
  version: '0'
242
243
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.7.6.2
245
- signing_key:
244
+ rubygems_version: 3.2.15
245
+ signing_key:
246
246
  specification_version: 4
247
247
  summary: Process streams of work using common modules.
248
248
  test_files: []