mushy 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mushy +2 -1
- data/lib/mushy/builder/api.rb +8 -0
- data/lib/mushy/flux.rb +4 -0
- data/lib/mushy/fluxs/bash.rb +1 -0
- data/lib/mushy/fluxs/browser.rb +3 -0
- data/lib/mushy/fluxs/document.rb +27 -0
- data/lib/mushy/fluxs/ls.rb +61 -10
- data/lib/mushy/fluxs/pwd.rb +3 -1
- data/lib/mushy/fluxs/screenshot.rb +4 -1
- data/lib/mushy/fluxs/write_file.rb +3 -1
- data/mushy.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49ce2c989b79318911d3941f9733d582a5911e9b7c31e73fb50bae29d63ee5e0
|
4
|
+
data.tar.gz: c9cff38e82362e8ec8299ae84884b1c1cfdc511f367c832697f6cb538143b505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef122c23b39ef1ef6dbe3675b66f55840c243341403d5b22f31356c2d31b1dd9fdc66f6572ff6861cfb2ea2c43257c064ab8411e15f01da29a472d4612c8fa89
|
7
|
+
data.tar.gz: 79a7708ce3fda3f0081d00a767ccc588967a2cbc44f37e27363a769234eb43a1fc53a0e50e1fa74e245497304ee6185b3160a14cac2216c71e09d09ed632f31e
|
data/bin/mushy
CHANGED
data/lib/mushy/builder/api.rb
CHANGED
@@ -95,6 +95,14 @@ module Mushy
|
|
95
95
|
details[:config][:sort] = { type: 'text', shrink: true, description: 'Sort by this key.', default: '' }
|
96
96
|
details[:config][:model] = { type: 'keyvalue', shrink: true, description: 'Reshape the outgoing events.', value: {}, default: {} }
|
97
97
|
|
98
|
+
details[:config][:error_strategy] = {
|
99
|
+
description: 'Error strategy. (return to return an event with "exception" returning the error, or ignore to ignore the exception)',
|
100
|
+
type: 'select',
|
101
|
+
options: ['', 'return', 'ignore'],
|
102
|
+
value: '',
|
103
|
+
shrink: true,
|
104
|
+
}
|
105
|
+
|
98
106
|
details[:config]
|
99
107
|
.select { |_, v| v[:type] == 'keyvalue' }
|
100
108
|
.select { |_, v| v[:editors].nil? }
|
data/lib/mushy/flux.rb
CHANGED
@@ -77,6 +77,10 @@ module Mushy
|
|
77
77
|
|
78
78
|
returned_one_result ? results.first : results
|
79
79
|
|
80
|
+
rescue Exception => e
|
81
|
+
raise e if config[:error_strategy].to_s == ''
|
82
|
+
return [] if config[:error_strategy] == 'ignore'
|
83
|
+
{ exception: e.message }
|
80
84
|
end
|
81
85
|
|
82
86
|
def standardize_these results
|
data/lib/mushy/fluxs/bash.rb
CHANGED
data/lib/mushy/fluxs/browser.rb
CHANGED
@@ -90,7 +90,9 @@ module Mushy
|
|
90
90
|
|
91
91
|
browser.headers.add get_the_headers_from(event, config)
|
92
92
|
|
93
|
+
the_start = Time.now
|
93
94
|
browser.goto config[:url]
|
95
|
+
time = Time.now - the_start
|
94
96
|
|
95
97
|
browser.execute(config[:execute]) if config[:execute]
|
96
98
|
|
@@ -102,6 +104,7 @@ module Mushy
|
|
102
104
|
title: browser.frames[0].title,
|
103
105
|
cookies: browser.cookies.all.map { |k, v| v.instance_variable_get('@attributes') },
|
104
106
|
headers: browser.headers.get,
|
107
|
+
time: time,
|
105
108
|
body: browser.body
|
106
109
|
}
|
107
110
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class Document < Flux
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
{
|
7
|
+
name: 'Document',
|
8
|
+
description: 'Create a multi-line document.',
|
9
|
+
config: {
|
10
|
+
document: {
|
11
|
+
description: 'The multi-line document you wish to create.',
|
12
|
+
type: 'textarea',
|
13
|
+
value: '',
|
14
|
+
},
|
15
|
+
},
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def process event, config
|
20
|
+
{
|
21
|
+
document: config[:document],
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/mushy/fluxs/ls.rb
CHANGED
@@ -14,31 +14,61 @@ module Mushy
|
|
14
14
|
shrink: true,
|
15
15
|
value: '',
|
16
16
|
}
|
17
|
+
c[:config][:path] = {
|
18
|
+
description: 'Path, used to search for specific files.',
|
19
|
+
type: 'text',
|
20
|
+
shrink: true,
|
21
|
+
value: '',
|
22
|
+
}
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
26
|
def process event, config
|
27
|
+
arguments = build_the_arguments_from config
|
21
28
|
|
29
|
+
config[:command] = build_the_command_from arguments
|
30
|
+
result = super event, config
|
31
|
+
|
32
|
+
things = turn_the_ls_output_to_events result, config, event
|
33
|
+
things
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_the_command_from arguments
|
37
|
+
"ls #{arguments.join(' ')}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_the_arguments_from config
|
22
41
|
arguments = ['-A', '-l', '--full-time', '-i']
|
23
42
|
arguments << '-R' if config[:recursive].to_s == 'true'
|
24
|
-
config[:
|
25
|
-
|
26
|
-
|
43
|
+
arguments << '-d' if config[:directory_only].to_s == 'true'
|
44
|
+
arguments << config[:path] if config[:path].to_s != ''
|
45
|
+
arguments
|
46
|
+
end
|
27
47
|
|
28
|
-
|
48
|
+
def turn_the_ls_output_to_events result, config, event
|
29
49
|
|
30
50
|
lines = result[:text].split("\n")
|
31
|
-
|
51
|
+
|
52
|
+
needs_special_work_for_path = config[:directory_only].to_s != 'true' &&
|
53
|
+
config[:path].to_s != '' &&
|
54
|
+
lines[0].start_with?('total ')
|
32
55
|
|
33
56
|
origin = config[:directory] || Dir.pwd
|
34
|
-
directory = origin
|
35
|
-
|
57
|
+
directory = needs_special_work_for_path ? '||DIRECTORY||' : origin
|
58
|
+
|
59
|
+
things = lines.map do |x|
|
36
60
|
segments = x.split ' '
|
37
61
|
result = if segments.count > 5
|
38
62
|
pull_file segments, directory
|
39
63
|
elsif segments.count == 1
|
40
64
|
dir_segments = segments[0].split("\/")
|
41
|
-
|
65
|
+
|
66
|
+
if dir_segments[0] == '.'
|
67
|
+
dir_segments[0] = origin
|
68
|
+
else
|
69
|
+
dir_segments.unshift origin
|
70
|
+
end
|
71
|
+
|
42
72
|
dir_segments[-1] = dir_segments[-1].sub ':', ''
|
43
73
|
directory = dir_segments.join("\/")
|
44
74
|
nil
|
@@ -47,6 +77,19 @@ module Mushy
|
|
47
77
|
end
|
48
78
|
end.select { |x| x }
|
49
79
|
|
80
|
+
if needs_special_work_for_path
|
81
|
+
config[:directory_only] = true
|
82
|
+
special_name = process(event, config)[0][:name]
|
83
|
+
things.each do |x|
|
84
|
+
[:directory, :path].each do |key|
|
85
|
+
if x[key].include?('||DIRECTORY||')
|
86
|
+
x[key].sub!('||DIRECTORY||', File.join(Dir.pwd, special_name))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
things
|
50
93
|
end
|
51
94
|
|
52
95
|
def pull_file segments, directory
|
@@ -76,10 +119,18 @@ module Mushy
|
|
76
119
|
|
77
120
|
[:hard_links, :size].each { |x| result[x] = result[x].to_i }
|
78
121
|
|
79
|
-
result[:
|
122
|
+
result[:date] = Mushy::DateParts.parse result[:date]
|
80
123
|
|
81
124
|
result[:directory] = directory
|
82
|
-
|
125
|
+
|
126
|
+
if result[:type] == 'd' && result[:directory] == result[:name]
|
127
|
+
result[:path] = result[:directory]
|
128
|
+
name_segments = result[:name].split "\/"
|
129
|
+
result[:name] = name_segments.pop
|
130
|
+
result[:directory] = name_segments.join "\/"
|
131
|
+
else
|
132
|
+
result[:path] = File.join result[:directory], result[:name]
|
133
|
+
end
|
83
134
|
|
84
135
|
result
|
85
136
|
end
|
data/lib/mushy/fluxs/pwd.rb
CHANGED
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.5.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,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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/mushy/fluxs/build_csv.rb
|
174
174
|
- lib/mushy/fluxs/cli.rb
|
175
175
|
- lib/mushy/fluxs/collection.rb
|
176
|
+
- lib/mushy/fluxs/document.rb
|
176
177
|
- lib/mushy/fluxs/environment.rb
|
177
178
|
- lib/mushy/fluxs/filter.rb
|
178
179
|
- lib/mushy/fluxs/format.rb
|