mushy 0.20.0 → 0.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mushy/fluxs/file_watch.rb +26 -8
- data/lib/mushy/fluxs/ls.rb +26 -1
- data/mushy.gemspec +1 -1
- metadata +1 -2
- data/hey.mushy +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b74a763b3548295aa4227af27f34e3472f057e9091896ecf0afa45a2e0452dfd
|
4
|
+
data.tar.gz: f5a7f830dea50073856eb0ff645f0904e27f04b546fb6ace2b5f6219d94e31c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a60bf45d09d7d768dab814966301d09ff7156b9c77261af1ec6f27d5e4fb11840f091034be5cd8df2e89e7ef3024503c29640269183e522e75bc8bc1261e5a
|
7
|
+
data.tar.gz: 4fdf85336bcf80cfaf147f2f4e92f1e4a6956ffb9a014b89b04f57faa523c00ec9c7803909b47c10324490d70472b87bcbc063fb0877d6e8d80b333828967d24
|
@@ -17,13 +17,19 @@ module Mushy
|
|
17
17
|
shrink: true,
|
18
18
|
value: '',
|
19
19
|
},
|
20
|
+
include_all_file_details: {
|
21
|
+
description: 'If true, returns all details for the file. If false, just path & name are returned',
|
22
|
+
type: 'boolean',
|
23
|
+
shrink: true,
|
24
|
+
value: '',
|
25
|
+
}
|
20
26
|
},
|
21
27
|
examples: {
|
22
28
|
"Files Added" => {
|
23
29
|
description: 'When a file is added, this type of result will be returned.',
|
24
30
|
result: {
|
25
31
|
modified: [],
|
26
|
-
added: [
|
32
|
+
added: [ { path: '/home/pi/Desktop/mushy/bin/hey.txt', directory: '/home/pi/Desktop/mushy/bin', name: 'hey.txt' } ],
|
27
33
|
removed:[]
|
28
34
|
}
|
29
35
|
},
|
@@ -32,13 +38,13 @@ module Mushy
|
|
32
38
|
result: {
|
33
39
|
modified: [],
|
34
40
|
added: [],
|
35
|
-
removed:[
|
41
|
+
removed:[{ path: '/home/pi/Desktop/mushy/mushy-0.15.3.gem', directory: '/home/pi/Desktop/mushy', name: 'mushy-0.15.3.gem'} ]
|
36
42
|
}
|
37
43
|
},
|
38
44
|
"Files Modified" => {
|
39
45
|
description: 'When a file is modified, this type of result will be returned.',
|
40
46
|
result: {
|
41
|
-
modified: [
|
47
|
+
modified: [ { path: '/home/pi/Desktop/mushy/lib/mushy/fluxs/environment.rb', directory: '/home/pi/Desktop/mushy/lib/mushy/fluxs/environment.rb', name: 'environment.rb' } ],
|
42
48
|
added: [],
|
43
49
|
removed:[]
|
44
50
|
}
|
@@ -47,15 +53,14 @@ module Mushy
|
|
47
53
|
}
|
48
54
|
end
|
49
55
|
|
50
|
-
def loop
|
51
|
-
|
56
|
+
def loop(&block)
|
52
57
|
directory = config[:directory].to_s != '' ? config[:directory] : Dir.pwd
|
53
58
|
|
54
59
|
listener = Listen.to(directory) do |modified, added, removed|
|
55
60
|
the_event = {
|
56
|
-
modified: modified,
|
57
|
-
added: added,
|
58
|
-
removed: removed
|
61
|
+
modified: modified.map { |f| get_the_details_for(f) },
|
62
|
+
added: added.map { |f| get_the_details_for(f) },
|
63
|
+
removed: removed.map { |f| get_the_details_for(f) }
|
59
64
|
}
|
60
65
|
block.call the_event
|
61
66
|
end
|
@@ -70,6 +75,19 @@ module Mushy
|
|
70
75
|
event
|
71
76
|
end
|
72
77
|
|
78
|
+
def get_the_details_for(file)
|
79
|
+
if config[:include_all_file_details].to_s == 'true'
|
80
|
+
Mushy::Ls.new.process({}, { path: file })[0]
|
81
|
+
else
|
82
|
+
segments = file.split("\/")
|
83
|
+
{
|
84
|
+
path: file,
|
85
|
+
name: segments.pop,
|
86
|
+
directory: segments.join("\/")
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
73
91
|
end
|
74
92
|
|
75
93
|
end
|
data/lib/mushy/fluxs/ls.rb
CHANGED
@@ -2,6 +2,24 @@ module Mushy
|
|
2
2
|
|
3
3
|
class Ls < Bash
|
4
4
|
|
5
|
+
def self.the_ls_command
|
6
|
+
@the_ls_command ||= find_the_right_ls_command_to_use
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find_the_right_ls_command_to_use
|
10
|
+
commands = [
|
11
|
+
'ls', # the normal method used to pull file information
|
12
|
+
'gls' # BSD users don't get the version of ls this needs,
|
13
|
+
# so we might need to use gls after the user runs (brew install coreutils)
|
14
|
+
]
|
15
|
+
|
16
|
+
the_command_to_use = nil
|
17
|
+
while the_command_to_use.nil? && (command = commands.shift) # keep trying till we find one that works
|
18
|
+
the_command_to_use = command if Mushy::Bash.new.process({}, { command: "#{command} --full-time" })[:success]
|
19
|
+
end
|
20
|
+
the_command_to_use || -1
|
21
|
+
end
|
22
|
+
|
5
23
|
def self.details
|
6
24
|
{
|
7
25
|
name: 'Ls',
|
@@ -134,6 +152,8 @@ module Mushy
|
|
134
152
|
end
|
135
153
|
|
136
154
|
def process event, config
|
155
|
+
raise 'ls is not available' if self.class.the_ls_command == -1
|
156
|
+
|
137
157
|
arguments = build_the_arguments_from config
|
138
158
|
|
139
159
|
config[:command] = build_the_command_from arguments
|
@@ -144,7 +164,8 @@ module Mushy
|
|
144
164
|
end
|
145
165
|
|
146
166
|
def build_the_command_from arguments
|
147
|
-
|
167
|
+
command = self.class.the_ls_command
|
168
|
+
"#{command} #{arguments.join(' ')}"
|
148
169
|
end
|
149
170
|
|
150
171
|
def build_the_arguments_from config
|
@@ -232,6 +253,10 @@ module Mushy
|
|
232
253
|
|
233
254
|
result[:date] = Mushy::DateParts.parse result[:date]
|
234
255
|
|
256
|
+
if File.exist?(result[:name]) && result[:name].start_with?(directory)
|
257
|
+
result[:name] = result[:name].split("\/")[-1]
|
258
|
+
end
|
259
|
+
|
235
260
|
result[:directory] = directory
|
236
261
|
|
237
262
|
if result[:type] == 'd' && result[:directory] == result[:name]
|
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.21.2'
|
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.21.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -172,7 +172,6 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- bin/mushy
|
175
|
-
- hey.mushy
|
176
175
|
- lib/mushy.rb
|
177
176
|
- lib/mushy/builder/api.rb
|
178
177
|
- lib/mushy/builder/axios.rb
|
data/hey.mushy
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"fluxs": [
|
3
|
-
{
|
4
|
-
"id": "0294b0c4-296f-44cd-9891-95fe75ebe4d2",
|
5
|
-
"name": "Start it up",
|
6
|
-
"flux": "Cli",
|
7
|
-
"parents": [
|
8
|
-
|
9
|
-
],
|
10
|
-
"config": {
|
11
|
-
"model": {
|
12
|
-
}
|
13
|
-
}
|
14
|
-
},
|
15
|
-
{
|
16
|
-
"id": "7779dce1-1ce8-4241-8e94-ddcd5cb4f8df",
|
17
|
-
"name": "Output something",
|
18
|
-
"flux": "Stdout",
|
19
|
-
"parents": [
|
20
|
-
"0294b0c4-296f-44cd-9891-95fe75ebe4d2"
|
21
|
-
],
|
22
|
-
"config": {
|
23
|
-
"message": "Hello.",
|
24
|
-
"model": {
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}
|