mushy 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +17 -0
- data/Gemfile.lock +107 -0
- data/bin/console +15 -0
- data/exe/mushy +127 -0
- data/lib/mushy/builder/api.rb +14 -0
- data/lib/mushy/fluxs/delete.rb +30 -0
- data/lib/mushy/fluxs/get.rb +29 -27
- data/lib/mushy/fluxs/http_operation.rb +82 -0
- data/lib/mushy/fluxs/patch.rb +32 -0
- data/lib/mushy/fluxs/post.rb +32 -0
- data/lib/mushy/fluxs/put.rb +32 -0
- data/lib/mushy/fluxs/stdout.rb +1 -1
- data/lib/mushy/fluxs/stop.rb +20 -0
- data/lib/mushy/fluxs/web.rb +20 -0
- data/lib/mushy/run.rb +6 -7
- data/lib/mushy/runner.rb +17 -5
- data/lib/mushy.rb +1 -0
- data/mushy.gemspec +3 -2
- metadata +14 -4
- data/bin/mushy +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de49d985993c99da7e7958e7a888c9dda279f84cea27008247bd12a18a073a64
|
4
|
+
data.tar.gz: ac8ad19c8a74e0ed6b331f130cd033eabee8b7b9d0e48366d993e215a24f8df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f00bebd0036154717b203074dc267d0129352d904e35e9bc390d676ad5e69d6c49cf793d982dc78ba45aed3842e506277d39d2a0a43ae8f226d4798c54463dff
|
7
|
+
data.tar.gz: 8542950faae9ae53f241ead12ebb2a2601155b3159a3e7188d9dbb71a4368407059daffaa4132ebfc7148e0245104281f386779ac247b5d21de634d13f726059
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem 'daemons', '~> 1'
|
8
|
+
gem 'faraday', '~> 1'
|
9
|
+
gem 'ferrum', '~> 0.11'
|
10
|
+
gem 'liquid', '~> 5'
|
11
|
+
gem 'listen', '~> 3.5'
|
12
|
+
gem 'minitest', '~> 5'
|
13
|
+
gem 'nokogiri', '~> 1'
|
14
|
+
gem 'pony', '~> 1.13'
|
15
|
+
gem 'sinatra', '~> 2.1'
|
16
|
+
gem 'symbolized', '~> 0.0.1'
|
17
|
+
gem 'thor', '~> 1.1'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mushy (0.24.0)
|
5
|
+
daemons (~> 1)
|
6
|
+
faraday (~> 1)
|
7
|
+
ferrum (~> 0.11)
|
8
|
+
liquid (~> 5)
|
9
|
+
listen (~> 3.5)
|
10
|
+
nokogiri (~> 1)
|
11
|
+
pony (~> 1.13)
|
12
|
+
sinatra (~> 2.1)
|
13
|
+
symbolized (~> 0.0.1)
|
14
|
+
thor (~> 1.1)
|
15
|
+
|
16
|
+
GEM
|
17
|
+
remote: https://rubygems.org/
|
18
|
+
specs:
|
19
|
+
addressable (2.8.0)
|
20
|
+
public_suffix (>= 2.0.2, < 5.0)
|
21
|
+
cliver (0.3.2)
|
22
|
+
concurrent-ruby (1.1.10)
|
23
|
+
daemons (1.4.1)
|
24
|
+
faraday (1.10.0)
|
25
|
+
faraday-em_http (~> 1.0)
|
26
|
+
faraday-em_synchrony (~> 1.0)
|
27
|
+
faraday-excon (~> 1.1)
|
28
|
+
faraday-httpclient (~> 1.0)
|
29
|
+
faraday-multipart (~> 1.0)
|
30
|
+
faraday-net_http (~> 1.0)
|
31
|
+
faraday-net_http_persistent (~> 1.0)
|
32
|
+
faraday-patron (~> 1.0)
|
33
|
+
faraday-rack (~> 1.0)
|
34
|
+
faraday-retry (~> 1.0)
|
35
|
+
ruby2_keywords (>= 0.0.4)
|
36
|
+
faraday-em_http (1.0.0)
|
37
|
+
faraday-em_synchrony (1.0.0)
|
38
|
+
faraday-excon (1.1.0)
|
39
|
+
faraday-httpclient (1.0.1)
|
40
|
+
faraday-multipart (1.0.4)
|
41
|
+
multipart-post (~> 2)
|
42
|
+
faraday-net_http (1.0.1)
|
43
|
+
faraday-net_http_persistent (1.2.0)
|
44
|
+
faraday-patron (1.0.0)
|
45
|
+
faraday-rack (1.0.0)
|
46
|
+
faraday-retry (1.0.3)
|
47
|
+
ferrum (0.11)
|
48
|
+
addressable (~> 2.5)
|
49
|
+
cliver (~> 0.3)
|
50
|
+
concurrent-ruby (~> 1.1)
|
51
|
+
websocket-driver (>= 0.6, < 0.8)
|
52
|
+
ffi (1.15.5)
|
53
|
+
liquid (5.4.0)
|
54
|
+
listen (3.7.1)
|
55
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
56
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
57
|
+
mail (2.7.1)
|
58
|
+
mini_mime (>= 0.1.1)
|
59
|
+
mini_mime (1.1.2)
|
60
|
+
minitest (5.16.2)
|
61
|
+
multipart-post (2.2.3)
|
62
|
+
mustermann (2.0.2)
|
63
|
+
ruby2_keywords (~> 0.0.1)
|
64
|
+
nokogiri (1.13.8-arm64-darwin)
|
65
|
+
racc (~> 1.4)
|
66
|
+
pony (1.13.1)
|
67
|
+
mail (>= 2.0)
|
68
|
+
public_suffix (4.0.7)
|
69
|
+
racc (1.6.0)
|
70
|
+
rack (2.2.4)
|
71
|
+
rack-protection (2.2.2)
|
72
|
+
rack
|
73
|
+
rb-fsevent (0.11.1)
|
74
|
+
rb-inotify (0.10.1)
|
75
|
+
ffi (~> 1.0)
|
76
|
+
ruby2_keywords (0.0.5)
|
77
|
+
sinatra (2.2.2)
|
78
|
+
mustermann (~> 2.0)
|
79
|
+
rack (~> 2.2)
|
80
|
+
rack-protection (= 2.2.2)
|
81
|
+
tilt (~> 2.0)
|
82
|
+
symbolized (0.0.1)
|
83
|
+
thor (1.2.1)
|
84
|
+
tilt (2.0.11)
|
85
|
+
websocket-driver (0.7.5)
|
86
|
+
websocket-extensions (>= 0.1.0)
|
87
|
+
websocket-extensions (0.1.5)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
arm64-darwin-21
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
daemons (~> 1)
|
94
|
+
faraday (~> 1)
|
95
|
+
ferrum (~> 0.11)
|
96
|
+
liquid (~> 5)
|
97
|
+
listen (~> 3.5)
|
98
|
+
minitest (~> 5)
|
99
|
+
mushy!
|
100
|
+
nokogiri (~> 1)
|
101
|
+
pony (~> 1.13)
|
102
|
+
sinatra (~> 2.1)
|
103
|
+
symbolized (~> 0.0.1)
|
104
|
+
thor (~> 1.1)
|
105
|
+
|
106
|
+
BUNDLED WITH
|
107
|
+
2.3.19
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "mushy"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/exe/mushy
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
require 'mushy'
|
6
|
+
|
7
|
+
class MushyCLI < Thor
|
8
|
+
argument :file, optional: true, type: :string
|
9
|
+
argument :values, optional: true, type: :hash
|
10
|
+
|
11
|
+
desc "start FILE", "Run this workflow file."
|
12
|
+
def start
|
13
|
+
v = values || {}
|
14
|
+
Mushy::Builder::Api.start(file, v).tap do |run|
|
15
|
+
MushyCLI.set_special_values({ method: 'web', file: file, run: run }) if run.is_a?(Mushy::FireUpAWebServer)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "build FILE", 'Build a flow.'
|
20
|
+
def build
|
21
|
+
MushyCLI.set_special_values( { method: 'build', file: file } )
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.set_special_values data
|
25
|
+
@special = data
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_special_values
|
29
|
+
@special
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
MushyCLI.start(ARGV)
|
34
|
+
|
35
|
+
exit unless MushyCLI.get_special_values
|
36
|
+
|
37
|
+
require 'sinatra'
|
38
|
+
enable :run
|
39
|
+
|
40
|
+
if MushyCLI.get_special_values[:method] == 'web'
|
41
|
+
hey = lambda do |file, request, params|
|
42
|
+
end
|
43
|
+
|
44
|
+
[:get, :post, :patch, :delete].each do |method|
|
45
|
+
(1..10).map { |x| (1...x).map { |_| '*' }.join('/') }.each do |url|
|
46
|
+
self.send(method, url) do
|
47
|
+
raw = {
|
48
|
+
accept: request.accept.map(&:to_s),
|
49
|
+
body: request.body.read,
|
50
|
+
scheme: nil,
|
51
|
+
script_name: nil,
|
52
|
+
path_info: nil,
|
53
|
+
port: nil,
|
54
|
+
request_method: nil,
|
55
|
+
query_string: nil,
|
56
|
+
content_length: nil,
|
57
|
+
media_type: nil,
|
58
|
+
host: nil,
|
59
|
+
form_data?: nil,
|
60
|
+
referrer: nil,
|
61
|
+
user_agent: nil,
|
62
|
+
xhr?: nil,
|
63
|
+
url: nil,
|
64
|
+
path: nil,
|
65
|
+
ip: nil,
|
66
|
+
secure?: nil,
|
67
|
+
forwarded?: nil,
|
68
|
+
}.reduce({}) { |t, i| t[i[0]] = i[1] || request.send(i[0]).to_s; t }
|
69
|
+
|
70
|
+
values = { method: request.request_method, params: params, request: raw }
|
71
|
+
Mushy::Builder::Api.start(MushyCLI.get_special_values[:file], values)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
elsif MushyCLI.get_special_values[:method] == 'build'
|
76
|
+
the_file = MushyCLI.get_special_values[:file]
|
77
|
+
|
78
|
+
get '/' do
|
79
|
+
Mushy::Builder::Index.file
|
80
|
+
end
|
81
|
+
|
82
|
+
get '/bulma.css' do
|
83
|
+
content_type :css
|
84
|
+
Mushy::Builder::Bulma.file
|
85
|
+
end
|
86
|
+
|
87
|
+
get '/dark.css' do
|
88
|
+
content_type :css
|
89
|
+
Mushy::Builder::Dark.file
|
90
|
+
end
|
91
|
+
|
92
|
+
get '/axios.js' do
|
93
|
+
content_type :js
|
94
|
+
Mushy::Builder::Axios.file
|
95
|
+
end
|
96
|
+
|
97
|
+
get '/vue.js' do
|
98
|
+
content_type :js
|
99
|
+
Mushy::Builder::Vue.file
|
100
|
+
end
|
101
|
+
|
102
|
+
get '/flow' do
|
103
|
+
content_type :json
|
104
|
+
Mushy::Builder::Api.get_flow(the_file).to_json
|
105
|
+
end
|
106
|
+
|
107
|
+
get '/fluxs' do
|
108
|
+
content_type :json
|
109
|
+
Mushy::Builder::Api.get_fluxs.to_json
|
110
|
+
end
|
111
|
+
|
112
|
+
post '/run' do
|
113
|
+
content_type :json
|
114
|
+
|
115
|
+
result = Mushy::Builder::Api.run request.body.read
|
116
|
+
|
117
|
+
{ result: result }.to_json
|
118
|
+
end
|
119
|
+
|
120
|
+
post '/save' do
|
121
|
+
content_type :json
|
122
|
+
|
123
|
+
result = Mushy::Builder::Api.save the_file, request.body.read
|
124
|
+
|
125
|
+
{ result: result }.to_json
|
126
|
+
end
|
127
|
+
end
|
data/lib/mushy/builder/api.rb
CHANGED
@@ -71,6 +71,20 @@ module Mushy::Builder::Api
|
|
71
71
|
exit
|
72
72
|
end
|
73
73
|
|
74
|
+
web_flux = flow.fluxs.select { |x| x.is_a?(Mushy::Web) }.first
|
75
|
+
if web_flux
|
76
|
+
if event[:method]
|
77
|
+
return Mushy::Runner.new.start event, web_flux, flow
|
78
|
+
else
|
79
|
+
return Mushy::FireUpAWebServer.new.tap do |x|
|
80
|
+
x.id = SecureRandom.uuid
|
81
|
+
x.flow_id = flow.id
|
82
|
+
x.flow = flow
|
83
|
+
x.flux = web_flux
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
74
88
|
cli_flux = flow.fluxs.select { |x| x.is_a?(Mushy::Cli) }.first
|
75
89
|
|
76
90
|
Mushy::Runner.new.start event, cli_flux, flow
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
#
|
6
|
+
# A DELETE request.
|
7
|
+
#
|
8
|
+
class Mushy::Delete < Mushy::HttpOperation
|
9
|
+
def self.details
|
10
|
+
super.merge({
|
11
|
+
examples: {
|
12
|
+
'Successful Call' => {
|
13
|
+
description: 'This will send a DELETE to an API endpoint.',
|
14
|
+
config: { url: 'http://localhost:3000/api/v1/db/data/v1/people/1' },
|
15
|
+
result: {
|
16
|
+
status: 200,
|
17
|
+
url: 'http://localhost:3000/api/v1/db/data/v1/people/1',
|
18
|
+
time: 0.11498799989931285,
|
19
|
+
reason_phrase: 'OK',
|
20
|
+
headers: {
|
21
|
+
'content-type' => 'application/json; charset=utf-8',
|
22
|
+
'content-length' => '1'
|
23
|
+
},
|
24
|
+
body: '1'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
})
|
29
|
+
end
|
30
|
+
end
|
data/lib/mushy/fluxs/get.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Mushy
|
4
|
-
|
5
|
-
class Get < Flux
|
6
|
-
|
7
|
-
def process event, config
|
8
|
-
|
9
|
-
faraday = Faraday.new do |connection|
|
10
|
-
connection.adapter Faraday.default_adapter
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
12
2
|
|
13
|
-
|
14
|
-
data = {}
|
15
|
-
url = config[:url]
|
16
|
-
|
17
|
-
response = faraday.get config[:url], data, headers
|
18
|
-
|
19
|
-
{
|
20
|
-
status: response.status,
|
21
|
-
url: url,
|
22
|
-
reason_phrase: response.reason_phrase,
|
23
|
-
headers: response.headers,
|
24
|
-
body: response.body,
|
25
|
-
}
|
26
|
-
end
|
3
|
+
require 'faraday'
|
27
4
|
|
5
|
+
#
|
6
|
+
# A GET request.
|
7
|
+
#
|
8
|
+
class Mushy::Get < Mushy::HttpOperation
|
9
|
+
def self.details
|
10
|
+
super.merge({
|
11
|
+
examples: {
|
12
|
+
'Successful Call' => {
|
13
|
+
description: "This will send a #{operation.upcase} to https://www.google.com.",
|
14
|
+
config: { url: 'https://www.google.com' },
|
15
|
+
result: {
|
16
|
+
status: 400,
|
17
|
+
url: 'https://www.google.com',
|
18
|
+
time: 0.12829399993643165,
|
19
|
+
reason_phrase: 'OK',
|
20
|
+
headers: {
|
21
|
+
'access-control-allow-origin': '*',
|
22
|
+
'content-type': 'application/json; charset=utf-8',
|
23
|
+
'content-length': '193',
|
24
|
+
'keep-alive': 'timeout=5'
|
25
|
+
},
|
26
|
+
body: '{}'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
})
|
28
31
|
end
|
29
|
-
|
30
|
-
end
|
32
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
#
|
6
|
+
# A HTTP Operation request.
|
7
|
+
#
|
8
|
+
class Mushy::HttpOperation < Mushy::Flux
|
9
|
+
def self.operation
|
10
|
+
name.split('::').last.downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
def operation
|
14
|
+
self.class.operation
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.details
|
18
|
+
{
|
19
|
+
name: operation.capitalize,
|
20
|
+
title: "Make a #{operation.upcase} call",
|
21
|
+
fluxGroup: { name: 'Web' },
|
22
|
+
description: "Makes a #{operation} call to a URL",
|
23
|
+
config: {
|
24
|
+
url: {
|
25
|
+
description: 'The URL to visit.',
|
26
|
+
type: 'text',
|
27
|
+
value: 'https://www.google.com'
|
28
|
+
},
|
29
|
+
headers: {
|
30
|
+
description: 'Headers for the web request.',
|
31
|
+
type: 'keyvalue',
|
32
|
+
shrink: true,
|
33
|
+
value: {}
|
34
|
+
},
|
35
|
+
params: {
|
36
|
+
description: 'Parameters for the URL.',
|
37
|
+
type: 'keyvalue',
|
38
|
+
shrink: true,
|
39
|
+
value: {}
|
40
|
+
},
|
41
|
+
body: {
|
42
|
+
description: 'The body of the request.',
|
43
|
+
type: 'text',
|
44
|
+
shrink: true,
|
45
|
+
value: ''
|
46
|
+
},
|
47
|
+
},
|
48
|
+
examples: {
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def process(_event, config) # rubocop:disable Metrics/MethodLength
|
54
|
+
args = {
|
55
|
+
params: config[:params],
|
56
|
+
headers: config[:headers]
|
57
|
+
}
|
58
|
+
|
59
|
+
faraday = Faraday.new(**args) do |connection|
|
60
|
+
connection.adapter Faraday.default_adapter
|
61
|
+
end
|
62
|
+
|
63
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
64
|
+
|
65
|
+
response = faraday.send(operation.to_sym, config[:url]) do |request|
|
66
|
+
request.body = config[:body] if config[:body].to_s != ''
|
67
|
+
end
|
68
|
+
|
69
|
+
time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
70
|
+
|
71
|
+
url = response.instance_variable_get(:@env).url.to_s
|
72
|
+
|
73
|
+
{
|
74
|
+
status: response.status,
|
75
|
+
url: url,
|
76
|
+
time: time,
|
77
|
+
reason_phrase: response.reason_phrase,
|
78
|
+
headers: response.headers,
|
79
|
+
body: response.body
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
#
|
6
|
+
# A PATCH request.
|
7
|
+
#
|
8
|
+
class Mushy::Patch < Mushy::HttpOperation
|
9
|
+
def self.details
|
10
|
+
super.merge({
|
11
|
+
examples: {
|
12
|
+
'Successful Call' => {
|
13
|
+
description: "This will send a #{operation.upcase} to https://www.google.com.",
|
14
|
+
config: { url: 'https://www.google.com' },
|
15
|
+
result: {
|
16
|
+
status: 400,
|
17
|
+
url: 'https://www.google.com',
|
18
|
+
time: 0.12829399993643165,
|
19
|
+
reason_phrase: 'OK',
|
20
|
+
headers: {
|
21
|
+
'access-control-allow-origin': '*',
|
22
|
+
'content-type': 'application/json; charset=utf-8',
|
23
|
+
'content-length': '193',
|
24
|
+
'keep-alive': 'timeout=5'
|
25
|
+
},
|
26
|
+
body: '{}'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
#
|
6
|
+
# A POST request.
|
7
|
+
#
|
8
|
+
class Mushy::Post < Mushy::HttpOperation
|
9
|
+
def self.details
|
10
|
+
super.merge({
|
11
|
+
examples: {
|
12
|
+
'Successful Call' => {
|
13
|
+
description: "This will send a #{operation.upcase} to https://www.google.com.",
|
14
|
+
config: { url: 'https://www.google.com' },
|
15
|
+
result: {
|
16
|
+
status: 400,
|
17
|
+
url: 'https://www.google.com',
|
18
|
+
time: 0.12829399993643165,
|
19
|
+
reason_phrase: 'OK',
|
20
|
+
headers: {
|
21
|
+
'access-control-allow-origin': '*',
|
22
|
+
'content-type': 'application/json; charset=utf-8',
|
23
|
+
'content-length': '193',
|
24
|
+
'keep-alive': 'timeout=5'
|
25
|
+
},
|
26
|
+
body: '{}'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
#
|
6
|
+
# A PUT request.
|
7
|
+
#
|
8
|
+
class Mushy::Put < Mushy::HttpOperation
|
9
|
+
def self.details
|
10
|
+
super.merge({
|
11
|
+
examples: {
|
12
|
+
'Successful Call' => {
|
13
|
+
description: "This will send a #{operation.upcase} to https://www.google.com.",
|
14
|
+
config: { url: 'https://www.google.com' },
|
15
|
+
result: {
|
16
|
+
status: 400,
|
17
|
+
url: 'https://www.google.com',
|
18
|
+
time: 0.12829399993643165,
|
19
|
+
reason_phrase: 'OK',
|
20
|
+
headers: {
|
21
|
+
'access-control-allow-origin': '*',
|
22
|
+
'content-type': 'application/json; charset=utf-8',
|
23
|
+
'content-length': '193',
|
24
|
+
'keep-alive': 'timeout=5'
|
25
|
+
},
|
26
|
+
body: '{}'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
})
|
31
|
+
end
|
32
|
+
end
|
data/lib/mushy/fluxs/stdout.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Mushy::Stop < Mushy::Flux
|
2
|
+
def self.details
|
3
|
+
{
|
4
|
+
name: 'Stop',
|
5
|
+
title: 'Stopper',
|
6
|
+
fluxGroup: { name: 'Stoppers', position: 1 },
|
7
|
+
description: 'Stop the flow',
|
8
|
+
config: {
|
9
|
+
}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def process(event, _)
|
14
|
+
event
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop(event)
|
18
|
+
event
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Mushy::Web < Mushy::Flux
|
2
|
+
def self.details
|
3
|
+
{
|
4
|
+
name: 'Web',
|
5
|
+
title: 'Set up a web endpoint',
|
6
|
+
description: '',
|
7
|
+
fluxGroup: { name: '' },
|
8
|
+
config: {
|
9
|
+
},
|
10
|
+
examples: {
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def process(event, _)
|
16
|
+
puts event.inspect
|
17
|
+
puts 'method!!!' if event[:method]
|
18
|
+
event
|
19
|
+
end
|
20
|
+
end
|
data/lib/mushy/run.rb
CHANGED
data/lib/mushy/runner.rb
CHANGED
@@ -15,16 +15,28 @@ module Mushy
|
|
15
15
|
events = run_event_with_flux starting_event, flux, flow
|
16
16
|
|
17
17
|
while events.any?
|
18
|
-
events = events.map
|
18
|
+
events = events.map do |event|
|
19
|
+
result = runner.run_event_in_flow(event, flow)
|
20
|
+
|
21
|
+
return result[0].flatten unless result[1]
|
22
|
+
|
23
|
+
result[0]
|
24
|
+
end.flatten
|
19
25
|
end
|
20
26
|
|
21
27
|
run
|
22
28
|
end
|
23
29
|
|
24
|
-
def run_event_in_flow
|
25
|
-
flow.fluxs_for(event)
|
26
|
-
|
27
|
-
|
30
|
+
def run_event_in_flow(event, flow)
|
31
|
+
fluxes = flow.fluxs_for(event)
|
32
|
+
|
33
|
+
[fluxes.map do |flux|
|
34
|
+
events = runner.run_event_with_flux event, flux, flow
|
35
|
+
|
36
|
+
return [flux.stop(events[0]), false] if flux.respond_to?(:stop)
|
37
|
+
|
38
|
+
events
|
39
|
+
end.flatten, true]
|
28
40
|
end
|
29
41
|
|
30
42
|
def run_event_with_flux event, flux, flow
|
data/lib/mushy.rb
CHANGED
data/mushy.gemspec
CHANGED
@@ -4,17 +4,18 @@ 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.25.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.'
|
11
11
|
s.authors = ['Darren Cauthon']
|
12
12
|
s.email = 'darren@cauthon.com'
|
13
13
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
-
s.executables = s.files.grep(%r{^
|
14
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.homepage = 'https://cauthon.com'
|
17
17
|
s.license = 'MIT'
|
18
|
+
s.bindir = 'exe'
|
18
19
|
|
19
20
|
s.add_development_dependency 'minitest', '~> 5'
|
20
21
|
s.add_runtime_dependency 'sinatra', '~> 2.1'
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mushy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -171,7 +171,10 @@ executables:
|
|
171
171
|
extensions: []
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
|
-
-
|
174
|
+
- Gemfile
|
175
|
+
- Gemfile.lock
|
176
|
+
- bin/console
|
177
|
+
- exe/mushy
|
175
178
|
- lib/mushy.rb
|
176
179
|
- lib/mushy/builder/api.rb
|
177
180
|
- lib/mushy/builder/axios.rb
|
@@ -189,6 +192,7 @@ files:
|
|
189
192
|
- lib/mushy/fluxs/build_csv.rb
|
190
193
|
- lib/mushy/fluxs/cli.rb
|
191
194
|
- lib/mushy/fluxs/collection.rb
|
195
|
+
- lib/mushy/fluxs/delete.rb
|
192
196
|
- lib/mushy/fluxs/document.rb
|
193
197
|
- lib/mushy/fluxs/environment.rb
|
194
198
|
- lib/mushy/fluxs/file_watch.rb
|
@@ -197,10 +201,14 @@ files:
|
|
197
201
|
- lib/mushy/fluxs/get.rb
|
198
202
|
- lib/mushy/fluxs/git_log.rb
|
199
203
|
- lib/mushy/fluxs/global_variables.rb
|
204
|
+
- lib/mushy/fluxs/http_operation.rb
|
200
205
|
- lib/mushy/fluxs/interval.rb
|
201
206
|
- lib/mushy/fluxs/ls.rb
|
202
207
|
- lib/mushy/fluxs/parse_html.rb
|
208
|
+
- lib/mushy/fluxs/patch.rb
|
203
209
|
- lib/mushy/fluxs/pdf.rb
|
210
|
+
- lib/mushy/fluxs/post.rb
|
211
|
+
- lib/mushy/fluxs/put.rb
|
204
212
|
- lib/mushy/fluxs/pwd.rb
|
205
213
|
- lib/mushy/fluxs/read_csv.rb
|
206
214
|
- lib/mushy/fluxs/read_file.rb
|
@@ -212,8 +220,10 @@ files:
|
|
212
220
|
- lib/mushy/fluxs/simple_python_program.rb
|
213
221
|
- lib/mushy/fluxs/smtp.rb
|
214
222
|
- lib/mushy/fluxs/stdout.rb
|
223
|
+
- lib/mushy/fluxs/stop.rb
|
215
224
|
- lib/mushy/fluxs/times.rb
|
216
225
|
- lib/mushy/fluxs/twilio_message.rb
|
226
|
+
- lib/mushy/fluxs/web.rb
|
217
227
|
- lib/mushy/fluxs/write_file.rb
|
218
228
|
- lib/mushy/fluxs/write_json.rb
|
219
229
|
- lib/mushy/masher.rb
|
@@ -242,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
252
|
- !ruby/object:Gem::Version
|
243
253
|
version: '0'
|
244
254
|
requirements: []
|
245
|
-
rubygems_version: 3.2.
|
255
|
+
rubygems_version: 3.2.32
|
246
256
|
signing_key:
|
247
257
|
specification_version: 4
|
248
258
|
summary: Process streams of work using common modules.
|
data/bin/mushy
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
require 'mushy'
|
5
|
-
|
6
|
-
class MushyCLI < Thor
|
7
|
-
argument :file, optional: true, type: :string
|
8
|
-
argument :values, optional: true, type: :hash
|
9
|
-
|
10
|
-
desc "start FILE", "Run this workflow file."
|
11
|
-
def start
|
12
|
-
v = values || {}
|
13
|
-
Mushy::Builder::Api.start file, v
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "build FILE", 'Build a flow.'
|
17
|
-
def build
|
18
|
-
MushyCLI.set_special_values( { method: 'build', file: file } )
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.set_special_values data
|
22
|
-
@special = data
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.get_special_values
|
26
|
-
@special
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
MushyCLI.start(ARGV)
|
31
|
-
|
32
|
-
exit unless MushyCLI.get_special_values
|
33
|
-
|
34
|
-
require 'sinatra'
|
35
|
-
enable :run
|
36
|
-
|
37
|
-
the_file = MushyCLI.get_special_values[:file]
|
38
|
-
|
39
|
-
get '/' do
|
40
|
-
Mushy::Builder::Index.file
|
41
|
-
end
|
42
|
-
|
43
|
-
get '/bulma.css' do
|
44
|
-
content_type :css
|
45
|
-
Mushy::Builder::Bulma.file
|
46
|
-
end
|
47
|
-
|
48
|
-
get '/dark.css' do
|
49
|
-
content_type :css
|
50
|
-
Mushy::Builder::Dark.file
|
51
|
-
end
|
52
|
-
|
53
|
-
get '/axios.js' do
|
54
|
-
content_type :js
|
55
|
-
Mushy::Builder::Axios.file
|
56
|
-
end
|
57
|
-
|
58
|
-
get '/vue.js' do
|
59
|
-
content_type :js
|
60
|
-
Mushy::Builder::Vue.file
|
61
|
-
end
|
62
|
-
|
63
|
-
get '/flow' do
|
64
|
-
content_type :json
|
65
|
-
Mushy::Builder::Api.get_flow(the_file).to_json
|
66
|
-
end
|
67
|
-
|
68
|
-
get '/fluxs' do
|
69
|
-
content_type :json
|
70
|
-
Mushy::Builder::Api.get_fluxs.to_json
|
71
|
-
end
|
72
|
-
|
73
|
-
post '/run' do
|
74
|
-
content_type :json
|
75
|
-
|
76
|
-
result = Mushy::Builder::Api.run request.body.read
|
77
|
-
|
78
|
-
{ result: result }.to_json
|
79
|
-
end
|
80
|
-
|
81
|
-
post '/save' do
|
82
|
-
content_type :json
|
83
|
-
|
84
|
-
result = Mushy::Builder::Api.save the_file, request.body.read
|
85
|
-
|
86
|
-
{ result: result }.to_json
|
87
|
-
end
|