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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78f078fac4fc19b1ee58323ce2ceaed770613dd8c71901a8a9a7f4ba03c5b413
4
- data.tar.gz: f19bde198e025b8478400fd33bbd8471b688b33b6caac27ae1f78441441bd895
3
+ metadata.gz: 49ce2c989b79318911d3941f9733d582a5911e9b7c31e73fb50bae29d63ee5e0
4
+ data.tar.gz: c9cff38e82362e8ec8299ae84884b1c1cfdc511f367c832697f6cb538143b505
5
5
  SHA512:
6
- metadata.gz: 6aff2c9d3d21517c385a5d1f5d0464ae37c77f281c32ef3a5f520cd667ad6354399f3be8e589dcd5883e4a8c0c60d321709373dd174dcd27813c77cb99c1958f
7
- data.tar.gz: cc0c2218bc455af76721edf9f9358828a21a45635c31e4f5b6a049b03c98ba7f83ea2212567426fad6114042d29ccc0a02251ee502be69c16eeeca0763c9cb16
6
+ metadata.gz: ef122c23b39ef1ef6dbe3675b66f55840c243341403d5b22f31356c2d31b1dd9fdc66f6572ff6861cfb2ea2c43257c064ab8411e15f01da29a472d4612c8fa89
7
+ data.tar.gz: 79a7708ce3fda3f0081d00a767ccc588967a2cbc44f37e27363a769234eb43a1fc53a0e50e1fa74e245497304ee6185b3160a14cac2216c71e09d09ed632f31e
data/bin/mushy CHANGED
@@ -10,7 +10,8 @@ class MushyCLI < Thor
10
10
 
11
11
  desc "start FILE", "Run this workflow file."
12
12
  def start
13
- Mushy::Builder::Api.start file, values
13
+ v = values || {}
14
+ Mushy::Builder::Api.start file, v
14
15
  end
15
16
 
16
17
  desc "build FILE", 'Build a flow.'
@@ -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
@@ -15,6 +15,7 @@ module Mushy
15
15
  directory: {
16
16
  description: 'The working directory in which the command will be run.',
17
17
  type: 'text',
18
+ shrink: true,
18
19
  value: '',
19
20
  },
20
21
  },
@@ -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
@@ -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[:command] = "ls #{arguments.join(' ')}"
25
-
26
- result = super event, config
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
- return result unless result[:success]
48
+ def turn_the_ls_output_to_events result, config, event
29
49
 
30
50
  lines = result[:text].split("\n")
31
- lines.shift
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
- lines.map do |x|
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
- dir_segments[0] = origin if dir_segments[0] == '.'
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[:date_parts] = Mushy::DateParts.parse result[:date]
122
+ result[:date] = Mushy::DateParts.parse result[:date]
80
123
 
81
124
  result[:directory] = directory
82
- result[:path] = File.join result[:directory], result[:name]
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
@@ -18,8 +18,10 @@ module Mushy
18
18
 
19
19
  return result unless result[:success]
20
20
 
21
+ pwd = result[:text].to_s.strip
22
+
21
23
  {
22
- pwd: result[:text].to_s.strip
24
+ pwd: Mushy::Ls.new.process({}, { path: pwd, directory_only: true })[0]
23
25
  }
24
26
 
25
27
  end
@@ -41,7 +41,10 @@ module Mushy
41
41
 
42
42
  the_browser.screenshot options
43
43
 
44
- options.merge the_result
44
+ the_result[:options] = options
45
+ the_result[:file] = Mushy::Ls.new.process({}, { path: file })[0]
46
+
47
+ the_result
45
48
 
46
49
  end
47
50
 
@@ -43,7 +43,9 @@ module Mushy
43
43
 
44
44
  File.open(file, 'w') { |f| f.write config[:data] }
45
45
 
46
- {}
46
+ {
47
+ file: Mushy::Ls.new.process({}, { path: file })[0]
48
+ }
47
49
  end
48
50
 
49
51
  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.4.1'
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.1
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