mushy 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f18a4ff7bf18c88f36a66481bd9fd56e7511ca276f5312b2f4bf2862e8d5aa5
4
- data.tar.gz: 2d40205cd64f986cc7234c847173ed4dbf95f0ba2f3ccf5d81e71290fb23d6c4
3
+ metadata.gz: 2a999131659ac9039500b30ed19769e5eefbcd1e8d7d6d17944f60ef498e05ce
4
+ data.tar.gz: 490b583acb52f7100d62ff77acfb68d12aa49505c5f9a628ff47707e358d93c4
5
5
  SHA512:
6
- metadata.gz: 183e5fe0556b562c1747d1005dc238ca034ca1745e0505a763e394d008a4315de63c65f53cab0435cf45a219e54e68bf705095218ab85e572d04e658b0c6d25b
7
- data.tar.gz: d856b27867d3946ff2ca840ae1eff9c96b07b7a06757bde41d6475351be68a36b97d9395324c4e3ee0e198ec3b5cd4352bffb5637e2f76a78663c5da08565245
6
+ metadata.gz: 433b4bdb5716d5a035fb9b0b2a244d8d3a368a1338519aeca1e087545d9339baf44635a0562a8d3990115c2f6dc188a3465fb36c6b2f9de8d11126a872725eed
7
+ data.tar.gz: 77bc7c6ca893188da063935bc6c4178eee03c20d985041ea8b1c170a4452a497ea4df974b6c0747ef65d56d621cfb751763268c6e1b2185d5c67eb064f34781a
@@ -77,7 +77,6 @@ module Mushy
77
77
  end
78
78
 
79
79
  def self.get_flow file
80
- puts "trying to get: #{file}"
81
80
  file = "#{file}.mushy" unless file.downcase.end_with?('.mushy')
82
81
  data = JSON.parse File.open(file).read
83
82
 
@@ -135,7 +134,7 @@ module Mushy
135
134
  details[:config][:incoming_split] = { type: 'text', shrink: true, description: 'Split an incoming event into multiple events by this key, an each event will be processed independently.', default: '' }
136
135
  details[:config][:outgoing_split] = { type: 'text', shrink: true, description: 'Split an outgoing event into multiple events by this key.', default: '' }
137
136
  details[:config][:merge] = { type: 'text', shrink: true, description: 'A comma-delimited list of fields from the event to carry through. Use * to merge all fields.', default: '' }
138
- details[:config][:group] = { type: 'text', shrink: true, description: 'Group events by a field, which is stored in a key. The format is group_by|group_key.', default: '' }
137
+ details[:config][:group] = { type: 'text', shrink: true, description: 'Group events by this key, with the value as the key. If a group key is provided like group_by|group_key, then multiple events with the results under group_key will be returned.', default: '' }
139
138
  details[:config][:limit] = { type: 'integer', shrink: true, description: 'Limit the number of events to this number.', default: '' }
140
139
  details[:config][:join] = { type: 'text', shrink: true, description: 'Join all of the events from this flux into one event, under this name.', default: '' }
141
140
  details[:config][:sort] = { type: 'text', shrink: true, description: 'Sort by this key.', default: '' }
@@ -167,7 +167,7 @@ module Mushy
167
167
  },
168
168
  text: {
169
169
  props: ['label', 'placeholder', 'disabled', 'readonly', 'value', 'description', 'shrink'],
170
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><input type="text" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value);" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
170
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><input type="text" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value);" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
171
171
  },
172
172
  hide: {
173
173
  props: ['label', 'description'],
@@ -175,19 +175,19 @@ module Mushy
175
175
  },
176
176
  integer: {
177
177
  props: ['label', 'placeholder', 'disabled', 'readonly', 'value', 'description', 'shrink'],
178
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><input type="text" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value);" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
178
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><input type="text" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value);" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
179
179
  },
180
180
  email: {
181
181
  props: ['label', 'placeholder', 'disabled', 'readonly', 'value', 'description', 'shrink'],
182
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><input type="email" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
182
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><input type="email" :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="input"></div></div>'
183
183
  },
184
184
  textarea: {
185
185
  props: ['label', 'placeholder', 'disabled', 'readonly', 'value', 'description', 'shrink'],
186
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><textarea :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="textarea"></textarea></div></div>'
186
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><textarea :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="textarea"></textarea></div></div>'
187
187
  },
188
188
  json: {
189
189
  props: ['label', 'placeholder', 'disabled', 'readonly', 'value', 'description', 'shrink'],
190
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><textarea :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="textarea"></textarea></div>'
190
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <textarea :name="id" v-if="value || !shrink" :placeholder="placeholder" v-bind:value="value" v-on:input="$emit(\\'update:value\\', $event.target.value)" :disabled="disabled == \\'true\\'" :readonly="readonly == \\'true\\'" class="textarea"></textarea></div>'
191
191
  },
192
192
  jsonview: {
193
193
  data: function() {
@@ -202,15 +202,15 @@ module Mushy
202
202
  },
203
203
  radio: {
204
204
  props: ['label', 'value', 'options', 'description', 'shrink'],
205
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div v-for="option in options"><input type="radio" :name="id" v-bind:value="option" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" :checked="value == option"> <label for="option">{{option}}</label></div></div>'
205
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div v-for="option in options"><input type="radio" :name="id" v-bind:value="option" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" :checked="value == option"> <label for="option">{{option}}</label></div></div>'
206
206
  },
207
207
  select: {
208
208
  props: ['label', 'value', 'options', 'description', 'shrink'],
209
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><select :name="id" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in options" v-bind:value="option" :selected="value == option">{{option}}</option></select></div></div>'
209
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><select :name="id" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in options" v-bind:value="option" :selected="value == option">{{option}}</option></select></div></div>'
210
210
  },
211
211
  selectrecord: {
212
212
  props: ['label', 'value', 'options', 'description', 'shrink'],
213
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><select :name="id" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in options" v-bind:value="option.id" :selected="value == option.id">{{option.name}}</option></select></div></div>'
213
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><select :name="id" v-if="value || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in options" v-bind:value="option.id" :selected="value == option.id">{{option.name}}</option></select></div></div>'
214
214
  },
215
215
  selectmanyrecords: {
216
216
  data: function() {
@@ -236,11 +236,11 @@ module Mushy
236
236
  };
237
237
  },
238
238
  props: ['label', 'value', 'options', 'description', 'shrink'],
239
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a> <span v-for="option in options" v-if="value && value.includes(option.id)">{{option.name}} <a href="#" v-on:click.prevent.stop="remove(option.id, value);$emit(\\'update:value\\', value)">[X]</a> </span> <a href="#" v-on:click.prevent.stop="doit(selectedValue, value);$emit(\\'update:value\\', value)">ADD</a> <div class="control"><select :name="id" v-if="value || !shrink" v-on:input="selectedValue=$event.target.value;" class="select"><option v-for="option in options" v-bind:value="option.id">{{option.name}}</option></select></div></div>'
239
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <span v-for="option in options" v-if="value && value.includes(option.id)">{{option.name}} <a href="#" v-on:click.prevent.stop="remove(option.id, value);$emit(\\'update:value\\', value)">[X]</a> </span> <a href="#" v-on:click.prevent.stop="doit(selectedValue, value);$emit(\\'update:value\\', value)">ADD</a> <div class="control"><select :name="id" v-if="value || !shrink" v-on:input="selectedValue=$event.target.value;" class="select"><option v-for="option in options" v-bind:value="option.id">{{option.name}}</option></select></div></div>'
240
240
  },
241
241
  boolean: {
242
242
  props: ['label', 'value', 'options', 'description', 'shrink'],
243
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a><div class="control"><select :name="id" v-if="(value != undefined && value != null && value != \\'\\') || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in [true, false]" v-bind:value="option" :selected="value == option">{{option}}</option></select></div></div>'
243
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && !value">[^]</a></div></div></div> <div class="control"><select :name="id" v-if="(value != undefined && value != null && value != \\'\\') || !shrink" v-on:input="$emit(\\'update:value\\', $event.target.value)" class="select"><option v-for="option in [true, false]" v-bind:value="option" :selected="value == option">{{option}}</option></select></div></div>'
244
244
  },
245
245
  table: {
246
246
  props: ['value', 'description'],
@@ -262,7 +262,7 @@ module Mushy
262
262
  };
263
263
  },
264
264
  props: ['value', 'editors', 'label', 'description', 'shrink'],
265
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && value.length == 0">[^]</a><table v-if="value.length > 0 || !shrink" class="table"><tr><th v-for="(d, i) in value[0]">{{' + fancyName('i') + '}}</th></tr><tr v-for="(v, z) in value"><td v-for="(d, i) in v">{{d}}</td><td><a href="#" v-on:click.prevent.stop="removeRecord(v, value, z)">[x]</a></td></tr><tr><td v-for="editor in editors"><mip-thing :data="editor.field" :id="editor.id"></mip-thing></td><td><a href="#" v-on:click.prevent.stop="addRecord(editors, value)">[Add]</a></td></tr></table></div>'
265
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink && value.length == 0">[^]</a></div></div></div> <table v-if="value.length > 0 || !shrink" class="table"><tr><th v-for="(d, i) in value[0]">{{' + fancyName('i') + '}}</th></tr><tr v-for="(v, z) in value"><td v-for="(d, i) in v">{{d}}</td><td><a href="#" v-on:click.prevent.stop="removeRecord(v, value, z)">[x]</a></td></tr><tr><td v-for="editor in editors"><mip-thing :data="editor.field" :id="editor.id"></mip-thing></td><td><a href="#" v-on:click.prevent.stop="addRecord(editors, value)">[Add]</a></td></tr></table></div>'
266
266
  },
267
267
  keyvalue: {
268
268
  data: function() {
@@ -277,7 +277,7 @@ module Mushy
277
277
  };
278
278
  },
279
279
  props: ['value', 'label', 'editors', 'description', 'shrink'],
280
- template: '<div><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink">[^]</a><table v-if="JSON.stringify(value) != \\'{}\\' || !shrink" class="table"><tr v-for="(v, k) in value"><td>{{k}}</td><td>{{v}}</td><td><button v-on:click.prevent.stop="removeRecord(value, k)" class="button">Remove {{k}}</button></td></tr><tr><td v-for="editor in editors"><mip-thing :data="editor.field" :id="editor.id"></mip-thing></td><td><button v-on:click.prevent.stop="addRecord(editors, value)" v-show="editors[0].field.value" class="button">{{actionText(editors[0].field.value, value)}} {{editors[0].field.value}}</button></td></tr></table></div>'
280
+ template: '<div><div class="level"><div class="level-left"><div class="level-item"><mip-label :id="id" :label="label" :description="description" :hide_description="shrink && !value"></mip-label></div><div class="level-item"> <a href="#" v-on:click.prevent.stop="shrink=false" v-show="shrink">[^]</a></div></div></div> <table v-if="JSON.stringify(value) != \\'{}\\' || !shrink" class="table"><tr v-for="(v, k) in value"><td>{{k}}</td><td>{{v}}</td><td><button v-on:click.prevent.stop="removeRecord(value, k)" class="button">Remove {{k}}</button></td></tr><tr><td v-for="editor in editors"><mip-thing :data="editor.field" :id="editor.id"></mip-thing></td><td><button v-on:click.prevent.stop="addRecord(editors, value)" v-show="editors[0].field.value" class="button">{{actionText(editors[0].field.value, value)}} {{editors[0].field.value}}</button></td></tr></table></div>'
281
281
  },
282
282
  button: {
283
283
  data: function() {
data/lib/mushy/flux.rb CHANGED
@@ -119,7 +119,11 @@ module Mushy
119
119
  def group_these_results results, event, by
120
120
  group_by = by.split('|')[0]
121
121
  result_key = by.split('|')[1]
122
- results.group_by { |x| x[group_by] }.map { |k, v| SymbolizedHash.new( { result_key => v } ) }
122
+ grouped_results = results.group_by { |x| x[group_by] }
123
+
124
+ return grouped_results unless result_key
125
+
126
+ grouped_results.map { |k, v| SymbolizedHash.new( { result_key => v } ) }
123
127
  end
124
128
 
125
129
  def outgoing_split_these_results results, event, by
@@ -5,6 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'Environment',
8
+ title: 'Environment Variables',
8
9
  description: 'Pull environment variables.',
9
10
  config: {
10
11
  variables: {
@@ -13,6 +14,17 @@ module Mushy
13
14
  value: {},
14
15
  },
15
16
  },
17
+ examples: {
18
+ "Example" => {
19
+ description: 'Get environmental variables.',
20
+ config: {
21
+ variables: { text_domain: 'TEXTDOMAIN' }
22
+ },
23
+ result: {
24
+ text_domain: 'Linux-PAM',
25
+ }
26
+ },
27
+ }
16
28
  }
17
29
  end
18
30
 
@@ -7,14 +7,42 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'FileWatch',
10
+ title: 'File Watcher',
10
11
  description: 'Watch for file changes.',
11
12
  config: {
12
13
  directory: {
13
- description: 'The directory to watch.',
14
+ description: 'The directory to watch, defaults to the current directory.',
14
15
  type: 'text',
16
+ shrink: true,
15
17
  value: '',
16
18
  },
17
19
  },
20
+ examples: {
21
+ "Files Added" => {
22
+ description: 'When a file is added, this type of result will be returned.',
23
+ result: {
24
+ modified: [],
25
+ added: ["/home/pi/Desktop/mushy/bin/hey.txt"],
26
+ removed:[]
27
+ }
28
+ },
29
+ "Files Removed" => {
30
+ description: 'When a file is deleted, this type of result will be returned.',
31
+ result: {
32
+ modified: [],
33
+ added: [],
34
+ removed:["/home/pi/Desktop/mushy/mushy-0.15.3.gem"]
35
+ }
36
+ },
37
+ "Files Modified" => {
38
+ description: 'When a file is modified, this type of result will be returned.',
39
+ result: {
40
+ modified: ["/home/pi/Desktop/mushy/lib/mushy/fluxs/environment.rb"],
41
+ added: [],
42
+ removed:[]
43
+ }
44
+ },
45
+ }
18
46
  }
19
47
  end
20
48
 
@@ -36,6 +36,32 @@ module Mushy
36
36
  value: {},
37
37
  },
38
38
  },
39
+ examples: {
40
+ "Match On A Value" => {
41
+ description: 'The input is returned if it matches on a value.',
42
+ input: {
43
+ name: "John",
44
+ },
45
+ config: {
46
+ matches: { name: "John" }
47
+ },
48
+ result: {
49
+ name: "John",
50
+ }
51
+ },
52
+ "Contains A Value" => {
53
+ description: 'The input is returned if it contains a value.',
54
+ input: {
55
+ name: "John",
56
+ },
57
+ config: {
58
+ contains: { name: "H" }
59
+ },
60
+ result: {
61
+ name: "John",
62
+ }
63
+ },
64
+ }
39
65
  }
40
66
  end
41
67
 
@@ -5,8 +5,47 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'Format',
8
- description: 'Return the event passed to it. This opens the opportunity to further alter results.',
8
+ description: 'Return the event passed to it. This opens the opportunity to use the common fluxing to alter the event.',
9
9
  config: {},
10
+ examples: {
11
+ "Simplest Example" => {
12
+ description: 'It only returns what is passed to it.',
13
+ input: {
14
+ hello: 'world',
15
+ },
16
+ config: {
17
+ },
18
+ result: {
19
+ hello: 'world',
20
+ }
21
+ },
22
+ "Changing The Event" => {
23
+ description: 'The common fluxing can still be used to alter the event.',
24
+ input: {
25
+ things: [
26
+ { name: "Elephant", type: "Mammal" },
27
+ { name: "Alligator", type: "Reptile" },
28
+ { name: "Giraffe", type: "Mammal" }
29
+ ]
30
+ },
31
+ config: { outgoing_split:"things",group:"type|animal_type" },
32
+ result: [
33
+ {
34
+ animal_type: [
35
+ {
36
+ name: "Elephant",
37
+ type: "Mammal"
38
+ },
39
+ {
40
+ name: "Giraffe",
41
+ type: "Mammal"
42
+ }
43
+ ]
44
+ },
45
+ { animal_type:[ { name:"Alligator",type:"Reptile" } ] }
46
+ ]
47
+ },
48
+ }
10
49
  }
11
50
  end
12
51
 
@@ -7,7 +7,8 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'GlobalVariables',
10
- description: 'Add global variables.',
10
+ title: 'Global Variables',
11
+ description: 'Add global variables to use in any future flux. Returns what was passed to it.',
11
12
  config: {
12
13
  values: {
13
14
  description: 'Provide key/value pairs that will be set as global variables.',
@@ -16,6 +17,20 @@ module Mushy
16
17
  value: {},
17
18
  },
18
19
  },
20
+ examples: {
21
+ "Setting Config Variables" => {
22
+ description: 'Set a variable to use in any flux. Here, I can use {{api_key}} anywhere.',
23
+ input: {
24
+ hey: 'you'
25
+ },
26
+ config: {
27
+ values: { api_key: 'my api key' }
28
+ },
29
+ result: {
30
+ hey: 'you',
31
+ }
32
+ },
33
+ }
19
34
  }
20
35
  end
21
36
 
@@ -7,7 +7,8 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'ParseHtml',
10
- description: 'Parses HTML.',
10
+ title: 'Parse HTML',
11
+ description: 'Extract data from HTML.',
11
12
  config: {
12
13
  path: {
13
14
  description: 'The path to the HTML in the incoming event.',
@@ -20,6 +21,40 @@ module Mushy
20
21
  value: { url: 'a|@href' },
21
22
  }
22
23
  },
24
+ examples: {
25
+ "Example 1" => {
26
+ description: 'Pulling all links out of HTML.',
27
+ input: {
28
+ html: '<a href="one">First</a><a href="two">Second</a>'
29
+ },
30
+ config: {
31
+ path: 'html',
32
+ extract: {
33
+ url: "a|@href",
34
+ name: "a"
35
+ },
36
+ },
37
+ result: [
38
+ { url: 'one', name: 'First' },
39
+ { url: 'two', name: 'Second' }
40
+ ]
41
+ },
42
+ "Example 2" => {
43
+ description: 'Pulling the contents of a single div.',
44
+ input: {
45
+ html: "<div class=\"main\" data-this=\"you\">HEY</a>"
46
+ },
47
+ config: {
48
+ path: 'html',
49
+ extract: {
50
+ content: "div.main",
51
+ class: "div|@class",
52
+ "data-this" => "div|@data-this",
53
+ },
54
+ },
55
+ result: { content: 'HEY', class: 'main', "data-this" => "you" },
56
+ },
57
+ }
23
58
  }
24
59
  end
25
60
 
@@ -5,6 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  details = Browser.details
7
7
  details[:name] = 'Pdf'
8
+ details[:title] = 'PDF'
8
9
  details[:description] = 'Turn a URL into a PDF.'
9
10
 
10
11
  details[:config][:path] = {
@@ -20,7 +21,76 @@ module Mushy
20
21
  value: '',
21
22
  }
22
23
 
23
- details
24
+ details.tap do |config|
25
+ config[:examples] = {
26
+ "PDF of google.com" => {
27
+ description: 'This will open https://www.google.com and take a screenshot.',
28
+ config: {
29
+ url: "https://www.google.com",
30
+ file: 'file.pdf'
31
+ },
32
+ result: {
33
+ url: "https://www.google.com/",
34
+ status: 200,
35
+ title: "Google",
36
+ cookies: [
37
+ {
38
+ name: "1P_JAR",
39
+ value: "2021-10-07-21",
40
+ domain: ".google.com",
41
+ path: "/",
42
+ expires: 1636232420.005369,
43
+ size: 19,
44
+ httpOnly: false,
45
+ secure: true,
46
+ session: false,
47
+ sameSite: "None",
48
+ priority: "Medium"
49
+ }
50
+ ],
51
+ headers: {},
52
+ time: 1.520785498,
53
+ body: "...",
54
+ options: {
55
+ path: "file.pdf",
56
+ full: true,
57
+ quality: 100
58
+ },
59
+ file: {
60
+ inode: "439545",
61
+ hard_links: 1,
62
+ owner: "pi",
63
+ group: "pi",
64
+ size: 54269,
65
+ date: {
66
+ year: 2021,
67
+ month: 10,
68
+ day: 7,
69
+ hour: 16,
70
+ minute: 0,
71
+ second: 20,
72
+ nanosecond: 444437482,
73
+ utc_offset: -18000,
74
+ weekday: 4,
75
+ day_of_month: 7,
76
+ day_of_year: 280,
77
+ string: "2021-10-07 16:00:20 -0500",
78
+ epoch_integer: 1633640420,
79
+ epoch_float: 1633640420.4444375,
80
+ seconds_ago: 0.016297478
81
+ },
82
+ name: "file.pdf",
83
+ type: "-",
84
+ owner_permission: "rw-",
85
+ group_permission: "r--",
86
+ other_permission: "r--",
87
+ directory: "/home/pi/Desktop/mushy",
88
+ path: "/home/pi/Desktop/mushy/file.pdf"
89
+ }
90
+ }
91
+ },
92
+ }
93
+ end
24
94
  end
25
95
 
26
96
  def adjust input
@@ -7,6 +7,7 @@ module Mushy
7
7
  def self.details
8
8
  {
9
9
  name: 'ReadCsv',
10
+ title: 'Read CSV',
10
11
  description: 'Read CSV content into events.',
11
12
  config: {
12
13
  data: {
@@ -21,6 +22,31 @@ module Mushy
21
22
  value: '',
22
23
  },
23
24
  },
25
+ examples: {
26
+ "With Headers" => {
27
+ description: 'Using this Flux to read a CSV into many events.',
28
+ input: {
29
+ csv: "first,last,height\njane,doe,short"
30
+ },
31
+ config: {
32
+ data: '{{csv}}'
33
+ },
34
+ result: { "first": "jane", "last": "doe", "height": "short" }
35
+ },
36
+ "No Headers" => {
37
+ description: 'Using this Flux to read a CSV into many events.',
38
+ input: {
39
+ csv: "john,doe,tall\njane,doe,short"
40
+ },
41
+ config: {
42
+ data: '{{csv}}'
43
+ },
44
+ result: [
45
+ { "a": "john", "b": "doe", "c": "tall" },
46
+ { "a": "jane", "b": "doe", "c": "short" }
47
+ ]
48
+ },
49
+ }
24
50
  }
25
51
  end
26
52
 
@@ -5,10 +5,11 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'ReadFile',
8
+ title: 'Read File',
8
9
  description: 'Read a file.',
9
10
  config: {
10
- name: {
11
- description: 'The name of the file to read.',
11
+ file: {
12
+ description: 'The file to read.',
12
13
  type: 'text',
13
14
  value: 'file.csv',
14
15
  },
@@ -18,24 +19,37 @@ module Mushy
18
19
  shrink: true,
19
20
  value: '',
20
21
  },
21
- path: {
22
- description: 'The path in the event to return the contents of the file.',
23
- type: 'text',
24
- value: 'content',
25
- },
22
+ key: {
23
+ description: 'The key in the resulting event to return the contents of the file.',
24
+ type: 'text',
25
+ value: 'content',
26
+ },
26
27
  },
28
+ examples: {
29
+ "Example" => {
30
+ description: 'Using this Flux to read the contents of a text file.',
31
+ input: {
32
+ file: "data.csv"
33
+ },
34
+ config: {
35
+ file: '{{file}}',
36
+ key: 'csvdata'
37
+ },
38
+ result: { csvdata: 'a,b,c\nd\n\e\f'}
39
+ },
40
+ }
27
41
  }
28
42
  end
29
43
 
30
44
  def process event, config
31
- file = config[:name]
45
+ file = config[:file]
32
46
 
33
47
  file = File.join(config[:directory], file) if config[:directory].to_s != ''
34
48
 
35
49
  content = File.open(file).read
36
50
 
37
51
  {
38
- config[:path] => content
52
+ config[:key] => content
39
53
  }
40
54
  end
41
55
 
@@ -5,7 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  details = Browser.details
7
7
  details[:name] = 'Screenshot'
8
- details[:description] = 'Take a screenshot of the browser.'
8
+ details[:description] = 'Take a screenshot of the browser. This works the same as the Browser, but with a screenshot at the end.'
9
9
 
10
10
  details[:config].merge!(Mushy::WriteFile.file_saving_config.tap do |x|
11
11
  x[x.keys.first][:value] = 'file.jpg'
@@ -23,7 +23,76 @@ module Mushy
23
23
  shrink: true,
24
24
  value: '',
25
25
  }
26
- details
26
+ details.tap do |config|
27
+ config[:examples] = {
28
+ "Screenshot of google.com" => {
29
+ description: 'This will open https://www.google.com and take a screenshot.',
30
+ config: {
31
+ url: "https://www.google.com",
32
+ file: 'file.jpg'
33
+ },
34
+ result: {
35
+ url: "https://www.google.com/",
36
+ status: 200,
37
+ title: "Google",
38
+ cookies: [
39
+ {
40
+ name: "1P_JAR",
41
+ value: "2021-10-07-21",
42
+ domain: ".google.com",
43
+ path: "/",
44
+ expires: 1636232420.005369,
45
+ size: 19,
46
+ httpOnly: false,
47
+ secure: true,
48
+ session: false,
49
+ sameSite: "None",
50
+ priority: "Medium"
51
+ }
52
+ ],
53
+ headers: {},
54
+ time: 1.520785498,
55
+ body: "...",
56
+ options: {
57
+ path: "file.jpg",
58
+ full: true,
59
+ quality: 100
60
+ },
61
+ file: {
62
+ inode: "439545",
63
+ hard_links: 1,
64
+ owner: "pi",
65
+ group: "pi",
66
+ size: 54269,
67
+ date: {
68
+ year: 2021,
69
+ month: 10,
70
+ day: 7,
71
+ hour: 16,
72
+ minute: 0,
73
+ second: 20,
74
+ nanosecond: 444437482,
75
+ utc_offset: -18000,
76
+ weekday: 4,
77
+ day_of_month: 7,
78
+ day_of_year: 280,
79
+ string: "2021-10-07 16:00:20 -0500",
80
+ epoch_integer: 1633640420,
81
+ epoch_float: 1633640420.4444375,
82
+ seconds_ago: 0.016297478
83
+ },
84
+ name: "file.jpg",
85
+ type: "-",
86
+ owner_permission: "rw-",
87
+ group_permission: "r--",
88
+ other_permission: "r--",
89
+ directory: "/home/pi/Desktop/mushy",
90
+ path: "/home/pi/Desktop/mushy/file.jpg"
91
+ }
92
+ }
93
+ },
94
+ }
95
+ end
27
96
  end
28
97
 
29
98
  def adjust input
@@ -5,6 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'Stdout',
8
+ title: 'Stdout / Print',
8
9
  description: 'Standard Out',
9
10
  config: {
10
11
  message: {
@@ -12,6 +12,13 @@ module Mushy
12
12
  type: 'integer',
13
13
  value: '1',
14
14
  },
15
+ },
16
+ examples: {
17
+ "Basic Example" => {
18
+ input: {name: "Elephant"},
19
+ config: {times: 2},
20
+ result: [ { name: "Elephant", index: 0 }, { name: "Elephant", index: 1 } ],
21
+ }
15
22
  }
16
23
  }
17
24
  end
@@ -5,6 +5,7 @@ module Mushy
5
5
  def self.details
6
6
  {
7
7
  name: 'WriteFile',
8
+ title: 'Write File',
8
9
  description: 'Write a file.',
9
10
  config: file_saving_config.merge({
10
11
  data: {
@@ -13,6 +14,52 @@ module Mushy
13
14
  value: '{{data}}',
14
15
  },
15
16
  }),
17
+ examples: {
18
+ "Example" => {
19
+ description: 'Using this Flux to write the contents of a text file. Details about the file are returned.',
20
+ input: {
21
+ file: "data.csv",
22
+ content: "a,b,c\nd,e,f",
23
+ },
24
+ config: {
25
+ file: '{{file}}',
26
+ data: '{{content}}'
27
+ },
28
+ result: {
29
+ file: {
30
+ inode: "439540",
31
+ hard_links: 1,
32
+ owner: "pi",
33
+ group: "pi",
34
+ size: 3,
35
+ date: {
36
+ year: 2021,
37
+ month: 10,
38
+ day: 7,
39
+ hour: 15,
40
+ minute: 41,
41
+ second: 14,
42
+ nanosecond: 163590058,
43
+ utc_offset: -18000,
44
+ weekday: 4,
45
+ day_of_month: 7,
46
+ day_of_year: 280,
47
+ string: "2021-10-07 15:41:14 -0500",
48
+ epoch_integer: 1633639274,
49
+ epoch_float: 1633639274.1635902,
50
+ seconds_ago: 0.018665617
51
+ },
52
+ name: "file.csv",
53
+ type: "-",
54
+ owner_permission: "rw-",
55
+ group_permission: "r--",
56
+ other_permission: "r--",
57
+ directory: "/home/pi/Desktop/mushy",
58
+ path: "/home/pi/Desktop/mushy/file.csv"
59
+ }
60
+ }
61
+ },
62
+ }
16
63
  }
17
64
  end
18
65
 
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.16.0'
7
+ s.version = '0.17.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.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
@@ -201,7 +201,6 @@ files:
201
201
  - lib/mushy/fluxs/ls.rb
202
202
  - lib/mushy/fluxs/parse_html.rb
203
203
  - lib/mushy/fluxs/pdf.rb
204
- - lib/mushy/fluxs/print.rb
205
204
  - lib/mushy/fluxs/pwd.rb
206
205
  - lib/mushy/fluxs/read_csv.rb
207
206
  - lib/mushy/fluxs/read_file.rb
@@ -1,26 +0,0 @@
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