mushy 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mushy.rb +10 -3
- data/lib/mushy/fluxs/sense_hat_environmental_sensors.rb +56 -0
- data/lib/mushy/fluxs/simple_python_program.rb +32 -0
- data/mushy.gemspec +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e8090ce2ca66c9aff11ada4b9beee80bb7866dcd27d51b618c1cfa699b2d4f
|
4
|
+
data.tar.gz: b9849eca063fa80c99e465c498994c04796245e01c79762338616563e484c312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b632030b6ce53a9364e6861b466e6574cd9f2e5836964db87a4124109bb4e0c23d801c448b40b1270e367cc2ab7eecb04b4ef94fa86ae844e1626f2a97471f52
|
7
|
+
data.tar.gz: 421e022ab044af27b72b2380be9343c22fa94c435388512712045f717af46c3ee10a2524e2784aff5bfb5c0e1bbe3a255b73a47ab38d514e17bb9307b626dad2
|
data/lib/mushy.rb
CHANGED
@@ -3,9 +3,16 @@ require 'symbolized'
|
|
3
3
|
|
4
4
|
Dir[File.dirname(__FILE__) + '/mushy/*.rb'].each { |f| require f }
|
5
5
|
|
6
|
-
important_flux_files = [
|
6
|
+
important_flux_files = [
|
7
|
+
'bash',
|
8
|
+
'browser',
|
9
|
+
'simple_python_program',
|
10
|
+
].map { |x| "#{x}.rb" }
|
11
|
+
|
7
12
|
Dir[File.dirname(__FILE__) + '/mushy/fluxs/*.rb']
|
8
|
-
.
|
9
|
-
.
|
13
|
+
.map { |x| [x, important_flux_files.find_index(x.split("\/")[-1]) || 9999999] }
|
14
|
+
.sort_by { |x| x[1] }
|
15
|
+
.map { |x| x[0] }
|
16
|
+
.each { |f| require f }
|
10
17
|
|
11
18
|
Dir[File.dirname(__FILE__) + '/mushy/builder/*.rb'].each { |f| require f }
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class SenseHatEnvironmentalSensors < SimplePythonProgram
|
4
|
+
|
5
|
+
def self.details
|
6
|
+
{
|
7
|
+
name: 'SenseHatEnvironmentalSensors',
|
8
|
+
description: 'Pull values from the Sense HAT environmental sensors.',
|
9
|
+
config: Mushy::SimplePythonProgram.default_config,
|
10
|
+
}.tap do |c|
|
11
|
+
measurements
|
12
|
+
.sort_by { |x| default_measurements.include?(x) ? 0 : 1 }
|
13
|
+
.each do |measurement|
|
14
|
+
c[:config][measurement] = {
|
15
|
+
description: "Pull #{measurement}.",
|
16
|
+
type: 'boolean',
|
17
|
+
shrink: true,
|
18
|
+
value: default_measurements.include?(measurement) ? 'true' : '',
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.measurements
|
25
|
+
[
|
26
|
+
:humidity,
|
27
|
+
:temperature,
|
28
|
+
:temperature_from_humidity,
|
29
|
+
:temperature_from_pressure,
|
30
|
+
:pressure,
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.default_measurements
|
35
|
+
[:humidity, :temperature, :pressure]
|
36
|
+
end
|
37
|
+
|
38
|
+
def python_program event, config
|
39
|
+
values = self.class.measurements
|
40
|
+
.select { |x| config[x] == 'true' }
|
41
|
+
.reduce({}) { |t, i| t[i] = "get_#{i}"; t}
|
42
|
+
.map { |m| "\"#{m[0]}\": sense.#{m[1]}()" }
|
43
|
+
.join(',')
|
44
|
+
|
45
|
+
<<PYTHON
|
46
|
+
from sense_hat import SenseHat
|
47
|
+
import json
|
48
|
+
sense = SenseHat()
|
49
|
+
value = json.dumps({#{values}})
|
50
|
+
print(value)
|
51
|
+
PYTHON
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Mushy
|
2
|
+
|
3
|
+
class SimplePythonProgram < Bash
|
4
|
+
|
5
|
+
def self.default_config
|
6
|
+
Mushy::Bash.details[:config].tap do |config|
|
7
|
+
config.delete :command
|
8
|
+
config.delete :directory
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def process event, config
|
13
|
+
|
14
|
+
lines = python_program(event, config)
|
15
|
+
.split('\n')
|
16
|
+
.map { |x| x.rstrip }
|
17
|
+
.select { |x| x && x != '' }
|
18
|
+
.map { |x| x.gsub('"', '\"') }
|
19
|
+
|
20
|
+
config[:command] = "python -c \"#{lines.join(';')}\""
|
21
|
+
|
22
|
+
result = super event, config
|
23
|
+
|
24
|
+
return nil unless result[:success]
|
25
|
+
|
26
|
+
JSON.parse result[:text]
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
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.
|
7
|
+
s.version = '0.11.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.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
@@ -204,6 +204,8 @@ files:
|
|
204
204
|
- lib/mushy/fluxs/read_csv.rb
|
205
205
|
- lib/mushy/fluxs/read_file.rb
|
206
206
|
- lib/mushy/fluxs/screenshot.rb
|
207
|
+
- lib/mushy/fluxs/sense_hat_environmental_sensors.rb
|
208
|
+
- lib/mushy/fluxs/simple_python_program.rb
|
207
209
|
- lib/mushy/fluxs/smtp.rb
|
208
210
|
- lib/mushy/fluxs/times.rb
|
209
211
|
- lib/mushy/fluxs/write_file.rb
|