mushy 0.1.0 → 0.1.3

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: 5b0ff90e9b20233f5744ec73d94137a2a117dc5bbdcb1962242caf5d3fdec8f3
4
- data.tar.gz: dd834f5294cf131393881c7647a25c27d54275e7c510c2b19bac233b9193be43
3
+ metadata.gz: 5f516df95fc3919dd7d02ffe32228fd96364c06a56595ae8a7e986d406abc3af
4
+ data.tar.gz: c2dc07c4f8ad462134d674aeb4006eeabff5a07abee0d20d1ec5ff89312f80e7
5
5
  SHA512:
6
- metadata.gz: 41b4cdfd6d24547838ba11b0bbdb3515ec8baee305ab5b97079d040019951354d29074d9a93c88cf94be9b70c0875220f3b76630097c9cc697ddf4ea4cef550f
7
- data.tar.gz: 1ec8aab8a0ac9281d1ed036b84add01be639c6223ef46db6f7132d4140f09c10d2ea0a6707bca99aa79b3db024efa2f4cf34ce5430c68e8838953be21f125dd2
6
+ metadata.gz: b2e8a4bc112300daeb8089a455c10ef7c6842524a0a8dc3a00aa0c8715ecee836eff17f89c461ead76ae4ba716c56e49e436be57e8f163de3a57d8fe8249e816
7
+ data.tar.gz: ef23272c88796185deb60fd11ad9a326b3dd4a84d2df7aa86830727e72408811eda47a2fb13e59cb481b6a0fb0ad505a7ee4c606cf50b6478e7dc0d7303c0371
data/bin/mushy CHANGED
@@ -3,18 +3,20 @@
3
3
  require 'thor'
4
4
  require 'mushy'
5
5
 
6
- class RailsCLI < Thor
6
+ class MushyCLI < Thor
7
+
8
+ argument :file
9
+ argument :values, optional: true, type: :hash
7
10
 
8
11
  desc "start FILE", "Run this workflow file."
9
- def start file
10
- content = File.open(file).read
11
- puts content
12
+ def start
13
+ Mushy::Builder::Api.start file, values
12
14
  end
13
15
 
14
16
  desc "build FILE", 'Build a flow.'
15
- def build file
17
+ def build
16
18
 
17
- RailsCLI.set_special( { method: 'build', file: file } )
19
+ MushyCLI.set_special( { method: 'build', file: file } )
18
20
 
19
21
  end
20
22
 
@@ -28,14 +30,14 @@ class RailsCLI < Thor
28
30
 
29
31
  end
30
32
 
31
- RailsCLI.start(ARGV)
33
+ MushyCLI.start(ARGV)
32
34
 
33
- exit unless RailsCLI.get_special
35
+ exit unless MushyCLI.get_special
34
36
 
35
37
  require 'sinatra'
36
38
  enable :run
37
39
 
38
- the_file = RailsCLI.get_special[:file]
40
+ the_file = MushyCLI.get_special[:file]
39
41
 
40
42
  get '/' do
41
43
  Mushy::Builder::Index.file
@@ -28,6 +28,15 @@ module Mushy
28
28
 
29
29
  end
30
30
 
31
+ def self.start file, event
32
+ file = "#{file}.json" unless file.downcase.end_with?('.json')
33
+ flow = File.open(file).read
34
+ flow = Mushy::Flow.parse flow
35
+ flux = flow.fluxs.select { |x| x.type == 'Cli' }.first
36
+
37
+ Mushy::Runner.new.start event, flux, flow
38
+ end
39
+
31
40
  def self.get_flow file
32
41
  puts "trying to get: #{file}"
33
42
  file = "#{file}.json" unless file.downcase.end_with?('.json')
data/lib/mushy/flow.rb CHANGED
@@ -18,8 +18,10 @@ module Mushy
18
18
  end
19
19
 
20
20
  def self.build_flux record
21
- flux = Object.const_get("Mushy::#{record[:type] || record['type'] || 'Flux'}").new
21
+ type = record[:type] || record['type'] || record[:flux] || record['flux'] || 'Flux'
22
+ flux = Object.const_get("Mushy::#{type}").new
22
23
  flux.id = record[:id] || record['id'] || flux.id
24
+ flux.type = type
23
25
  flux.config = SymbolizedHash.new(record[:config] || record['config'])
24
26
  flux
25
27
  end
data/lib/mushy/flux.rb CHANGED
@@ -3,6 +3,7 @@ module Mushy
3
3
  class Flux
4
4
 
5
5
  attr_accessor :id
6
+ attr_accessor :type
6
7
  attr_accessor :parent_fluxs
7
8
  attr_accessor :subscribed_to
8
9
  attr_accessor :config
@@ -20,6 +20,12 @@ module Mushy
20
20
  shrink: true,
21
21
  value: 'true',
22
22
  },
23
+ timeout: {
24
+ description: 'The default timeout (in seconds) before closing the browser. Default is 5 seconds.',
25
+ type: 'integer',
26
+ shrink: true,
27
+ value: '',
28
+ },
23
29
  execute: {
24
30
  description: 'Javascript to run after the page is loaded.',
25
31
  type: 'textarea',
@@ -74,7 +80,11 @@ module Mushy
74
80
 
75
81
  def process event, config
76
82
 
77
- browser = Ferrum::Browser.new(headless: (config[:headless].to_s != 'false'))
83
+ timeout = config[:timeout] ? config[:timeout].to_i : 5
84
+
85
+ browser = Ferrum::Browser.new(
86
+ headless: (config[:headless].to_s != 'false'),
87
+ timeout: timeout)
78
88
 
79
89
  get_the_cookies_from(event, config).each { |c| browser.cookies.set(c) }
80
90
 
@@ -88,6 +98,8 @@ module Mushy
88
98
 
89
99
  result = {
90
100
  url: browser.url,
101
+ status: browser.network.status,
102
+ title: browser.frames[0].title,
91
103
  cookies: browser.cookies.all.map { |k, v| v.instance_variable_get('@attributes') },
92
104
  headers: browser.headers.get,
93
105
  body: browser.body
@@ -0,0 +1,20 @@
1
+ module Mushy
2
+
3
+ class Cli < Flux
4
+
5
+ def self.details
6
+ {
7
+ name: 'Cli',
8
+ description: 'Accept CLI arguments from the run command.',
9
+ config: {
10
+ },
11
+ }
12
+ end
13
+
14
+ def process event, config
15
+ event
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -2,6 +2,29 @@ module Mushy
2
2
 
3
3
  class Filter < Flux
4
4
 
5
+ def self.details
6
+ {
7
+ name: 'Filter',
8
+ description: 'Filters events based on criteria.',
9
+ config: {
10
+ equal: {
11
+ description: 'Provide key/value pairs that must match in the event.',
12
+ shrink: true,
13
+ label: 'Equal To',
14
+ type: 'keyvalue',
15
+ value: {},
16
+ },
17
+ notequal: {
18
+ description: 'Provide key/value pairs that must NOT match in the event.',
19
+ shrink: true,
20
+ label: 'Not Equal To',
21
+ type: 'keyvalue',
22
+ value: {},
23
+ },
24
+ },
25
+ }
26
+ end
27
+
5
28
  def process event, config
6
29
 
7
30
  differences = [:equal, :notequal]
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.1.0'
7
+ s.version = '0.1.3'
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.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
@@ -142,6 +142,7 @@ files:
142
142
  - lib/mushy/fluxs/bash.rb
143
143
  - lib/mushy/fluxs/browser.rb
144
144
  - lib/mushy/fluxs/build_csv.rb
145
+ - lib/mushy/fluxs/cli.rb
145
146
  - lib/mushy/fluxs/collection.rb
146
147
  - lib/mushy/fluxs/filter.rb
147
148
  - lib/mushy/fluxs/format.rb