mushy 0.20.0 → 0.21.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: dbf8fb6716e69283789cab01d8ac6cce819ecb4767f58f419cf789b4df9288d5
4
- data.tar.gz: fa02702e5af205ad6cf2ab0a233679532123f619684cfc301ff20fc28612039a
3
+ metadata.gz: cfd4d2f868fa9bd4c147f4cd9c7af24cea6ad38934d2e2bec53a6c8c9e396345
4
+ data.tar.gz: bf919c0d4f927dbc8ef6705b183fea9aa8d2fa73f61354603e83d2c8d01e3842
5
5
  SHA512:
6
- metadata.gz: ba22ee6901921c836b9ea8788b517ef149358530670899ab25b4d322d0676570a647eb30e5d18621d05241423bc32b0689ce8dd9cb60bf040ab59ad11cdc3db8
7
- data.tar.gz: 05ff96e01b3763fb528357b3fc413c5a847ab08601350841c024b55b4052b1de81a363077fb2f3728ce5fb607e70076002934587b2c1fcea9fd6ca63614e038c
6
+ metadata.gz: 9de7dae32eb11e0ae5448c0990e6a4be38483f3f38552e4bf519e6bdec047de6694c86734e57f2b3fe002a1ca263f9b0ed7232b1b42cc5290a2e99ee3d34745f
7
+ data.tar.gz: da103a79f76baa1cadc52d6a0f5100cfdb848212c9e6e1ac3b9dcb79fa14a527a8f1e7af8a4dc0d91e0e5d7ff77a142f8258308ecba819bfcf517a5772b03b68
@@ -17,6 +17,12 @@ 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" => {
@@ -47,15 +53,14 @@ module Mushy
47
53
  }
48
54
  end
49
55
 
50
- def loop &block
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,17 @@ 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
+ {
83
+ path: file,
84
+ name: file.split("\/").pop
85
+ }
86
+ end
87
+ end
88
+
73
89
  end
74
90
 
75
91
  end
@@ -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
- "ls #{arguments.join(' ')}"
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.20.0'
7
+ s.version = '0.21.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.20.0
4
+ version: 0.21.0
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
- }