mushy 0.19.0 → 0.20.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: d783dd461abacb6686c2e131fc228d2640f1dda9836d1c49c1073f7e37054739
4
- data.tar.gz: 950f0fd45cb88001fe62d3f1541374c2df5a1f3ff931b19d3a40f4a6fd187fb3
3
+ metadata.gz: dbf8fb6716e69283789cab01d8ac6cce819ecb4767f58f419cf789b4df9288d5
4
+ data.tar.gz: fa02702e5af205ad6cf2ab0a233679532123f619684cfc301ff20fc28612039a
5
5
  SHA512:
6
- metadata.gz: 15b49ebac4c571ab8f2c34450516f0325b70a3e85e7bd909bdd800c29a74ee7377297fa5128f8d7b5458ec278768e92cafbd8af552321f372d26a9a743d8ebb1
7
- data.tar.gz: 8041bbd1b4f89af13edc858be699bc3903e4bea680ac68b0b2f26a744adc0b7230572034ade0367851b7f5201e3c51ca9a48095d7afd9300f5185ce2f2c0bd3f
6
+ metadata.gz: ba22ee6901921c836b9ea8788b517ef149358530670899ab25b4d322d0676570a647eb30e5d18621d05241423bc32b0689ce8dd9cb60bf040ab59ad11cdc3db8
7
+ data.tar.gz: 05ff96e01b3763fb528357b3fc413c5a847ab08601350841c024b55b4052b1de81a363077fb2f3728ce5fb607e70076002934587b2c1fcea9fd6ca63614e038c
@@ -0,0 +1,64 @@
1
+ module Mushy
2
+ class RegexMatches < Flux
3
+ def self.details
4
+ {
5
+ name: 'RegexMatches',
6
+ title: 'Find regex matches',
7
+ description: 'Use a regex to search content.',
8
+ fluxGroup: { name: 'Regex' },
9
+ config: {
10
+ regex: { description: 'The regular expression to use.',
11
+ type: 'text',
12
+ value: '(\w+)' },
13
+ value: { description: 'The value against which to use the regular expression.',
14
+ type: 'text',
15
+ value: '{{value}}' }
16
+ },
17
+ examples: {
18
+ 'Simple Example' => {
19
+ description: 'The simplest regex.',
20
+ input: { text: 'apple orange' },
21
+ config: {
22
+ regex: '(\w+)',
23
+ value: 'apple orange'
24
+ },
25
+ result: [ { match1: 'apple' }, { match2: 'orange' } ]
26
+ },
27
+ 'Named Parameters' => {
28
+ description: 'Named Parameters.',
29
+ input: {
30
+ text: 'apple 1 orange 2'
31
+ },
32
+ config: {
33
+ regex: '(?&lt;name&gt;\w+) (?&lt;count&gt;\d+)',
34
+ value: '{{text}}'
35
+ },
36
+ result: [ { name: 'apple', count: '1' }, { name: 'orange', count: '2' } ]
37
+ },
38
+ }
39
+ }
40
+ end
41
+
42
+ def process(_, config)
43
+ return [] unless config[:value]
44
+ return [] if (config[:regex] || '').strip == ''
45
+
46
+ keys = config[:regex].scan(/\?<(\w+)>/).flatten
47
+
48
+ regex = Regexp.new config[:regex]
49
+
50
+ config[:value].scan(regex).map do |match|
51
+ convert_the_match_to_a_hash match, keys
52
+ end
53
+ end
54
+
55
+ def convert_the_match_to_a_hash(match, keys)
56
+ {}.tap do |hash|
57
+ match.each_with_index do |item, index|
58
+ key = (keys[index] || "match#{index + 1}").to_sym
59
+ hash[key] = item
60
+ end
61
+ end
62
+ end
63
+ end
64
+ 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.19.0'
7
+ s.version = '0.20.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.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
@@ -206,6 +206,7 @@ files:
206
206
  - lib/mushy/fluxs/read_csv.rb
207
207
  - lib/mushy/fluxs/read_file.rb
208
208
  - lib/mushy/fluxs/read_json.rb
209
+ - lib/mushy/fluxs/regex_matches.rb
209
210
  - lib/mushy/fluxs/screenshot.rb
210
211
  - lib/mushy/fluxs/sense_hat_environmental_sensors.rb
211
212
  - lib/mushy/fluxs/sense_hat_led_matrix.rb