mushy 0.3.0 → 0.4.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: 3a41b5499e19c46d620ec9794fb8265224ce142516be73f977cfacc5597a844f
4
- data.tar.gz: c74dfd1f76f24da513947edba159a97f4cf613308775346fcf22d8d8eb69a71e
3
+ metadata.gz: 7fdb340186745a43f2930f3b0e60a6538076593f3cb8cf3464fba209ac90d409
4
+ data.tar.gz: cbe1b085e5844c4facabd43d5451f6f34b0fc21cba4909460028dd5bab007c5f
5
5
  SHA512:
6
- metadata.gz: b4ca21536b4b8d740c619ce7632d86d33b7b3db3b36d8279839bf1ceeb6fbd67edec6cd9f38bca7ce15d870223034c20b5bc46c7c55d3d15adda794b23e867de
7
- data.tar.gz: 0d0254cabb3bd1943872f3db3afede763b9edf4773cc08b4c1dbe54f86f2c3ce9fa55cd24d42b2a30b53044e58925446a0deb504372b57d3c2905ad0fd18098b
6
+ metadata.gz: 85af2b856ca023cef5a65fba574b615683b9898c20aea0a87f3aa24c2061382ebfb14eb9a7aee40e6267c7cb34666c12f8c1c939f3a4207a8a7fc90c6114817b
7
+ data.tar.gz: 7f21edc8cd3e5f256dc038e16569a402f4d104a81060e08601b65afd325e7c71f2d22e5bdf39b895121034a8551025cbf7db9da62a6d4af1d2724d1ee706247f
@@ -0,0 +1,30 @@
1
+ module Mushy
2
+
3
+ module DateParts
4
+
5
+ def self.parse now
6
+ {
7
+ year: nil,
8
+ month: nil,
9
+ day: nil,
10
+ hour: nil,
11
+ minute: :min,
12
+ second: :sec,
13
+ nanosecond: :nsec,
14
+ utc_offset: nil,
15
+ weekday: :wday,
16
+ day_of_month: :mday,
17
+ day_of_year: :yday,
18
+ string: :to_s,
19
+ epoch_integer: :to_i,
20
+ epoch_float: :to_f,
21
+ }.reduce({}) do |t, i|
22
+ method = i[1] || i[0]
23
+ t[i[0]] = now.send method
24
+ t
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -48,26 +48,7 @@ module Mushy
48
48
 
49
49
  def process event, config
50
50
  now = Time.now
51
- {
52
- year: nil,
53
- month: nil,
54
- day: nil,
55
- hour: nil,
56
- minute: :min,
57
- second: :sec,
58
- nanosecond: :nsec,
59
- utc_offset: nil,
60
- weekday: :wday,
61
- day_of_month: :mday,
62
- day_of_year: :yday,
63
- string: :to_s,
64
- epoch_integer: :to_i,
65
- epoch_float: :to_f,
66
- }.reduce({}) do |t, i|
67
- method = i[1] || i[0]
68
- t[i[0]] = now.send method
69
- t
70
- end
51
+ Mushy::DateParts.parse now
71
52
  end
72
53
 
73
54
  end
@@ -6,30 +6,82 @@ module Mushy
6
6
  {
7
7
  name: 'Ls',
8
8
  description: 'Run the "ls" command.',
9
- config: {
10
- directory: {
11
- description: 'The working directory in which the command will be run.',
12
- type: 'text',
13
- value: '',
14
- },
15
- },
16
- }
9
+ config: Mushy::Bash.details[:config].tap { |c| c.delete :command },
10
+ }.tap do |c|
11
+ c[:config][:recursive] = {
12
+ description: 'Pull files recursively.',
13
+ type: 'boolean',
14
+ shrink: true,
15
+ value: '',
16
+ }
17
+ end
17
18
  end
18
19
 
19
20
  def process event, config
20
21
 
21
- config[:command] = 'ls'
22
+ arguments = ['-A', '-l', '--full-time', '-i']
23
+ arguments << '-R' if config[:recursive].to_s == 'true'
24
+ config[:command] = "ls #{arguments.join(' ')}"
22
25
 
23
26
  result = super event, config
24
27
 
25
28
  return result unless result[:success]
26
29
 
27
- result[:text].split("\n").map do |x|
28
- {
29
- name: x,
30
- }
30
+ lines = result[:text].split("\n")
31
+ lines.shift
32
+
33
+ origin = config[:directory] || Dir.pwd
34
+ directory = origin
35
+ lines.map do |x|
36
+ segments = x.split ' '
37
+ result = if segments.count > 5
38
+ pull_file segments, directory
39
+ elsif segments.count == 1
40
+ dir_segments = segments[0].split("\/")
41
+ dir_segments[0] = origin if dir_segments[0] == '.'
42
+ dir_segments[-1] = dir_segments[-1].sub ':', ''
43
+ directory = dir_segments.join("\/")
44
+ nil
45
+ else
46
+ nil
47
+ end
48
+ end.select { |x| x }
49
+
50
+ end
51
+
52
+ def pull_file segments, directory
53
+ result = {}
54
+
55
+ [:inode, :help, :hard_links, :owner, :group, :size].each do |key|
56
+ result[key] = segments.shift; x = segments.join ' '
57
+ end
58
+
59
+ result.tap do |r|
60
+ r[:date] = []
61
+ 3.times { r[:date] << segments.shift }
62
+ r[:date] = r[:date].join ' '
63
+ r[:date] = Time.parse r[:date]
64
+ end
65
+
66
+ result[:name] = segments.shift
67
+
68
+ result.tap do |r|
69
+ help_segments = r[:help].split ''
70
+ r[:type] = help_segments[0]
71
+ r[:owner_permission] = [1, 2, 3].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
72
+ r[:group_permission] = [4, 5, 6].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
73
+ r[:other_permission] = [7, 8, 9].map { |i| help_segments[i] }.reduce('') { |t, i| t + i }
74
+ r.delete :help
31
75
  end
32
76
 
77
+ [:hard_links, :size].each { |x| result[x] = result[x].to_i }
78
+
79
+ result[:date_parts] = Mushy::DateParts.parse result[:date]
80
+
81
+ result[:directory] = directory
82
+ result[:path] = File.join result[:directory], result[:name]
83
+
84
+ result
33
85
  end
34
86
 
35
87
  end
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,29 @@
1
+ module Mushy
2
+
3
+ class Pwd < Bash
4
+
5
+ def self.details
6
+ {
7
+ name: 'Pwd',
8
+ description: 'Run the "pwd" command.',
9
+ config: Mushy::Bash.details[:config].tap { |c| c.delete :command },
10
+ }
11
+ end
12
+
13
+ def process event, config
14
+
15
+ config[:command] = 'pwd'
16
+
17
+ result = super event, config
18
+
19
+ return result unless result[:success]
20
+
21
+ {
22
+ pwd: result[:text].to_s.strip
23
+ }
24
+
25
+ end
26
+
27
+ end
28
+
29
+ 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.3.0'
7
+ s.version = '0.4.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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
@@ -164,6 +164,7 @@ files:
164
164
  - lib/mushy/builder/dark.rb
165
165
  - lib/mushy/builder/index.rb
166
166
  - lib/mushy/builder/vue.rb
167
+ - lib/mushy/date_parts.rb
167
168
  - lib/mushy/event.rb
168
169
  - lib/mushy/flow.rb
169
170
  - lib/mushy/flux.rb
@@ -181,6 +182,8 @@ files:
181
182
  - lib/mushy/fluxs/ls.rb
182
183
  - lib/mushy/fluxs/parse_html.rb
183
184
  - lib/mushy/fluxs/pdf.rb
185
+ - lib/mushy/fluxs/print.rb
186
+ - lib/mushy/fluxs/pwd.rb
184
187
  - lib/mushy/fluxs/read_csv.rb
185
188
  - lib/mushy/fluxs/read_file.rb
186
189
  - lib/mushy/fluxs/screenshot.rb