lex-conditioner 0.1.0 → 0.2.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 +4 -4
- data/.circleci/config.yml +61 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/lex-conditioner.iml +64 -0
- data/.idea/misc.xml +1 -1
- data/.idea/modules.xml +1 -1
- data/.idea/vagrant.xml +7 -0
- data/.idea/workspace.xml +8 -2
- data/.rubocop.yml +27 -0
- data/Gemfile +0 -4
- data/legion-extensions-conditioner.gemspec +4 -3
- data/lib/legion/extensions/conditioner.rb +1 -28
- data/lib/legion/extensions/conditioner/actors/conditioner.rb +17 -0
- data/lib/legion/extensions/conditioner/helpers/comparator.rb +43 -0
- data/lib/legion/extensions/conditioner/helpers/condition.rb +79 -0
- data/lib/legion/extensions/conditioner/runners/conditioner.rb +49 -0
- data/lib/legion/extensions/conditioner/transport.rb +13 -0
- data/lib/legion/extensions/conditioner/transport/exchanges/task.rb +8 -0
- data/lib/legion/extensions/conditioner/transport/messages/conditioner.rb +15 -0
- data/lib/legion/extensions/conditioner/transport/queues/conditioner.rb +11 -0
- data/lib/legion/extensions/conditioner/version.rb +1 -1
- metadata +39 -15
- data/.idea/encodings.xml +0 -4
- data/.idea/legion-extensions-conditioner.iml +0 -22
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1579af62de9fb477b021231116ccd9acb4707a8bae1f3d2a83df9b219bf17d57
|
|
4
|
+
data.tar.gz: 81a245120396bb7fa05e9c2157dbf14f9e1aa1b559896b4a65b5098aa91889b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1ed90f09fa47bcadeb4467612fdcc3db662293f20feccafb860769aac0e5886b73cd9095978a5d4f867dced9add09eba59ed250ac13416d066d7d85bb0a845c
|
|
7
|
+
data.tar.gz: 9fd73d8269c6a46cbef7dd6a18b067d842bc340641914acf3b55261848992b6a028e361067fe91a6eac0782086514f3a5bec790923b053f80869004c5bb0f606
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@0.2.1
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
"rubocop":
|
|
7
|
+
docker:
|
|
8
|
+
- image: circleci/ruby:2.5-node
|
|
9
|
+
steps:
|
|
10
|
+
- checkout
|
|
11
|
+
- ruby/load-cache
|
|
12
|
+
- ruby/install-deps
|
|
13
|
+
- run:
|
|
14
|
+
name: Run Rubocop
|
|
15
|
+
command: bundle exec rubocop
|
|
16
|
+
- ruby/save-cache
|
|
17
|
+
"ruby-two-five":
|
|
18
|
+
docker:
|
|
19
|
+
- image: circleci/ruby:2.5
|
|
20
|
+
- image: memcached:1.5-alpine
|
|
21
|
+
steps:
|
|
22
|
+
- checkout
|
|
23
|
+
- ruby/load-cache
|
|
24
|
+
- ruby/install-deps
|
|
25
|
+
- ruby/run-tests
|
|
26
|
+
- ruby/save-cache
|
|
27
|
+
"ruby-two-six":
|
|
28
|
+
docker:
|
|
29
|
+
- image: circleci/ruby:2.6
|
|
30
|
+
- image: memcached:1.5-alpine
|
|
31
|
+
steps:
|
|
32
|
+
- checkout
|
|
33
|
+
- ruby/load-cache
|
|
34
|
+
- ruby/install-deps
|
|
35
|
+
- ruby/run-tests
|
|
36
|
+
- ruby/save-cache
|
|
37
|
+
"ruby-two-seven":
|
|
38
|
+
docker:
|
|
39
|
+
- image: circleci/ruby:2.7
|
|
40
|
+
- image: memcached:1.5-alpine
|
|
41
|
+
steps:
|
|
42
|
+
- checkout
|
|
43
|
+
- ruby/load-cache
|
|
44
|
+
- ruby/install-deps
|
|
45
|
+
- ruby/run-tests
|
|
46
|
+
- ruby/save-cache
|
|
47
|
+
|
|
48
|
+
workflows:
|
|
49
|
+
version: 2
|
|
50
|
+
rubocop-rspec:
|
|
51
|
+
jobs:
|
|
52
|
+
- rubocop
|
|
53
|
+
- ruby-two-five:
|
|
54
|
+
requires:
|
|
55
|
+
- rubocop
|
|
56
|
+
- ruby-two-six:
|
|
57
|
+
requires:
|
|
58
|
+
- ruby-two-five
|
|
59
|
+
- ruby-two-seven:
|
|
60
|
+
requires:
|
|
61
|
+
- ruby-two-five
|
data/.idea/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build lex-conditioner-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install lex-conditioner-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install lex-conditioner-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push lex-conditioner-0.1.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
|
4
|
+
<shared />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="NewModuleRootManager">
|
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
|
8
|
+
<orderEntry type="inheritedJdk" />
|
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="amq-protocol (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="aws-eventstream (v1.0.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="aws-sigv4 (v1.1.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="bunny (v2.14.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="chef (v15.8.23, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby-ext (v1.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.2.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="daemons (v1.3.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="dalli (v2.7.10, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday (v0.17.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday_middleware (v0.14.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.5.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-cache (v0.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-crypt (v0.1.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-data (v0.2.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-exceptions (v1.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-json (v0.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-logging (v1.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-settings (v1.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-transport (v1.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="legionio (v0.2.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.1.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.5.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="oj (v3.10.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.7.0.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="rbnacl (v7.1.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="redis (v4.1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
52
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.80.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="sequel (v5.30.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
57
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
58
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
59
|
+
<orderEntry type="library" scope="PROVIDED" name="sleepiq (v0.2.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
60
|
+
<orderEntry type="library" scope="PROVIDED" name="thor (v1.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
61
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.6.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
62
|
+
<orderEntry type="library" scope="PROVIDED" name="vault (v0.13.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
|
63
|
+
</component>
|
|
64
|
+
</module>
|
data/.idea/misc.xml
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
<component name="JavaScriptSettings">
|
|
4
4
|
<option name="languageLevel" value="ES6" />
|
|
5
5
|
</component>
|
|
6
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
|
|
7
7
|
</project>
|
data/.idea/modules.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ProjectModuleManager">
|
|
4
4
|
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/lex-conditioner.iml" filepath="$PROJECT_DIR$/.idea/lex-conditioner.iml" />
|
|
6
6
|
</modules>
|
|
7
7
|
</component>
|
|
8
8
|
</project>
|
data/.idea/vagrant.xml
ADDED
data/.idea/workspace.xml
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
|
+
<component name="CoverageOptionsProvider">
|
|
4
|
+
<option name="myAddOrReplace" value="0" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="Git.Settings">
|
|
7
|
+
<option name="PUSH_AUTO_UPDATE" value="true" />
|
|
8
|
+
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
|
9
|
+
</component>
|
|
3
10
|
<component name="PropertiesComponent">
|
|
4
|
-
<property name="
|
|
5
|
-
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
|
11
|
+
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
|
|
6
12
|
</component>
|
|
7
13
|
</project>
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Layout/LineLength:
|
|
2
|
+
Max: 120
|
|
3
|
+
Metrics/MethodLength:
|
|
4
|
+
Max: 30
|
|
5
|
+
Metrics/ClassLength:
|
|
6
|
+
Max: 1500
|
|
7
|
+
Metrics/BlockLength:
|
|
8
|
+
Max: 50
|
|
9
|
+
Metrics/AbcSize:
|
|
10
|
+
Max: 20
|
|
11
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
12
|
+
EnforcedStyle: space
|
|
13
|
+
Style/SymbolArray:
|
|
14
|
+
Enabled: true
|
|
15
|
+
Layout/HashAlignment:
|
|
16
|
+
EnforcedHashRocketStyle: table
|
|
17
|
+
EnforcedColonStyle: table
|
|
18
|
+
Style/Documentation:
|
|
19
|
+
Enabled: false
|
|
20
|
+
AllCops:
|
|
21
|
+
TargetRubyVersion: 2.5
|
|
22
|
+
Style/FrozenStringLiteralComment:
|
|
23
|
+
Enabled: false
|
|
24
|
+
Naming/FileName:
|
|
25
|
+
Enabled: false
|
|
26
|
+
Style/ClassAndModuleChildren:
|
|
27
|
+
Enabled: false
|
data/Gemfile
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
if spec.respond_to?(:metadata)
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
18
|
spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner'
|
|
19
|
-
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner/src/master/CHANGELOG.md'
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
@@ -26,10 +26,11 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
27
|
spec.require_paths = ['lib']
|
|
28
28
|
|
|
29
|
-
spec.add_development_dependency '
|
|
29
|
+
spec.add_development_dependency 'legionio'
|
|
30
30
|
spec.add_development_dependency 'rake'
|
|
31
31
|
spec.add_development_dependency 'rspec'
|
|
32
|
+
spec.add_development_dependency 'rubocop'
|
|
33
|
+
spec.add_development_dependency 'simplecov'
|
|
32
34
|
|
|
33
35
|
spec.add_dependency 'legion-exceptions'
|
|
34
|
-
spec.add_dependency 'legion-extensions'
|
|
35
36
|
end
|
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
require 'legion/extensions/conditioner/version'
|
|
2
2
|
require 'legion/extensions'
|
|
3
|
-
require 'legion/extensions/default'
|
|
4
|
-
require 'legion/extensions/conditioner/actors/condition'
|
|
5
3
|
|
|
6
4
|
module Legion
|
|
7
5
|
module Extensions
|
|
8
6
|
module Conditioner
|
|
9
|
-
extend Legion::Extensions::
|
|
10
|
-
attr_reader :actors, :requirements, :default_settings, :autobuild
|
|
11
|
-
def self.klass
|
|
12
|
-
Legion::Extensions::Conditioner
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.path
|
|
16
|
-
'legion/extensions/conditioner/'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.actors
|
|
20
|
-
[{
|
|
21
|
-
path: path + 'actors/condition',
|
|
22
|
-
class: klass::Actor::Condition,
|
|
23
|
-
group_name: 'conditioner'
|
|
24
|
-
}]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.lex_methods
|
|
28
|
-
[{
|
|
29
|
-
namespace: 'legion::extensions::conditioner::runners::condition',
|
|
30
|
-
class_methods: {
|
|
31
|
-
check: {}
|
|
32
|
-
}
|
|
33
|
-
}]
|
|
34
|
-
end
|
|
7
|
+
extend Legion::Extensions::Core
|
|
35
8
|
end
|
|
36
9
|
end
|
|
37
10
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Legion::Extensions::Conditioner
|
|
2
|
+
module Actor
|
|
3
|
+
class Conditioner < Legion::Extensions::Actors::Subscription
|
|
4
|
+
def runner_function
|
|
5
|
+
'check'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def check_subtask?
|
|
9
|
+
false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def generate_task?
|
|
13
|
+
false
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Legion
|
|
2
|
+
module Extensions
|
|
3
|
+
module Conditioner
|
|
4
|
+
class Comparator
|
|
5
|
+
def self.equal?(fact, value, values)
|
|
6
|
+
values[fact] == value
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.not_equal?(fact, value, values)
|
|
10
|
+
values[fact] != value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.nil?(fact, values)
|
|
14
|
+
values[fact].nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.not_nil?(fact, values)
|
|
18
|
+
!values[fact].nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.is_false?(fact, values) # rubocop:disable Naming/PredicateName
|
|
22
|
+
true unless values[fact]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.is_true?(fact, values) # rubocop:disable Naming/PredicateName
|
|
26
|
+
values[fact]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.is_array?(fact, values) # rubocop:disable Naming/PredicateName
|
|
30
|
+
!values[fact]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.is_string?(fact, values) # rubocop:disable Naming/PredicateName
|
|
34
|
+
values[fact].is_a? String
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.is_integer?(fact, values) # rubocop:disable Naming/PredicateName
|
|
38
|
+
values[fact].is_a? Integer
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require_relative 'comparator'
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Conditioner
|
|
6
|
+
class Condition
|
|
7
|
+
def initialize(args)
|
|
8
|
+
@conditions = Legion::JSON.load(args[:conditions])
|
|
9
|
+
@values = to_dotted_hash(args[:values])
|
|
10
|
+
@task_id = args[:task_id]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_dotted_hash(source, target = {}, namespace = nil)
|
|
14
|
+
prefix = "#{namespace}." if namespace
|
|
15
|
+
case source
|
|
16
|
+
when Hash
|
|
17
|
+
source.each do |key, value|
|
|
18
|
+
to_dotted_hash(value, target, "#{prefix}#{key}")
|
|
19
|
+
end
|
|
20
|
+
when Array
|
|
21
|
+
source.each_with_index do |value, index|
|
|
22
|
+
to_dotted_hash(value, target, "#{prefix}#{index}")
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
target[namespace] = source
|
|
26
|
+
end
|
|
27
|
+
target
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def validate_vars # rubocop:disable Metrics/CyclomaticComplexity
|
|
31
|
+
raise Legion::Exception::MissingArgument, '@conditions is nil' if @conditions.nil?
|
|
32
|
+
raise Legion::Exception::MissingArgument, '@values is nil' if @values.nil?
|
|
33
|
+
raise Legion::Exception::MissingArgument, '@task_id is nil' if @task_id.nil?
|
|
34
|
+
raise Legion::Exception::WrongType::Hash, @values.class unless @values.is_a? Hash
|
|
35
|
+
raise Legion::Exception::WrongType::Integer, @task_id.class unless @task_id.is_a? Integer
|
|
36
|
+
raise Legion::Exception::WrongType::Hash, @conditions.class unless @conditions.is_a? Hash
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def validate_test(conditions = @conditions) # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize
|
|
40
|
+
conditions.each do |condition|
|
|
41
|
+
condition[1].each do |rule|
|
|
42
|
+
result = validate_test('conditions' => { 'all' => rule[:all] }) if rule.include? :all
|
|
43
|
+
result = validate_test('conditions' => { 'any' => rule[:any] }) if rule.include? :any
|
|
44
|
+
if rule[:operator] == 'equal'
|
|
45
|
+
result = Legion::Extensions::Conditioner::Comparator.equal?(rule[:fact], rule[:value], @values)
|
|
46
|
+
elsif rule[:operator] == 'not_equal'
|
|
47
|
+
result = Legion::Extensions::Conditioner::Comparator.not_equal?(rule[:fact], rule[:value], @values)
|
|
48
|
+
elsif rule[:operator] == 'nil'
|
|
49
|
+
result = Legion::Extensions::Conditioner::Comparator.nil?(rule[:fact], @values)
|
|
50
|
+
elsif rule[:operator] == 'not_nil'
|
|
51
|
+
result = Legion::Extensions::Conditioner::Comparator.not_nil?(rule[:fact], @values)
|
|
52
|
+
elsif rule[:operator] == 'is_false'
|
|
53
|
+
result = Legion::Extensions::Conditioner::Comparator.is_false?(rule[:fact], @values)
|
|
54
|
+
elsif rule[:operator] == 'is_true'
|
|
55
|
+
result = Legion::Extensions::Conditioner::Comparator.is_true?(rule[:fact], @values)
|
|
56
|
+
elsif rule[:operator] == 'is_string'
|
|
57
|
+
result = Legion::Extensions::Conditioner::Comparator.is_string?(rule[:fact], @values)
|
|
58
|
+
elsif rule[:operator] == 'is_array'
|
|
59
|
+
result = Legion::Extensions::Conditioner::Comparator.is_array?(rule[:fact], @values)
|
|
60
|
+
elsif rule[:operator] == 'is_integer'
|
|
61
|
+
result = Legion::Extensions::Conditioner::Comparator.is_integer?(rule[:fact], @values)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
return true if condition[0] == :any && result == true
|
|
65
|
+
return false if condition[0] == :all && result == false
|
|
66
|
+
end
|
|
67
|
+
return false if condition[0] == :any
|
|
68
|
+
return true if condition[0] == :all
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def valid?
|
|
73
|
+
@valid = validate_test if @valid.nil?
|
|
74
|
+
@valid
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'legion/extensions/conditioner/helpers/condition'
|
|
2
|
+
|
|
3
|
+
module Legion::Extensions::Conditioner
|
|
4
|
+
module Runners
|
|
5
|
+
module Conditioner
|
|
6
|
+
def self.check(**payload) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
7
|
+
conditioner = Legion::Extensions::Conditioner::Condition.new(conditions: payload[:conditions],
|
|
8
|
+
task_id: payload[:task_id],
|
|
9
|
+
values: payload,
|
|
10
|
+
type: payload[:type])
|
|
11
|
+
if conditioner.valid?
|
|
12
|
+
Legion::Extensions::Conditioner::Transport::Messages::Conditioner.new(**payload).publish
|
|
13
|
+
status = 'task.queued'
|
|
14
|
+
else
|
|
15
|
+
status = 'conditioner.failed'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
unless payload[:task_id].nil?
|
|
19
|
+
Legion::Transport::Messages::TaskUpdate.new(task_id: payload[:task_id], status: status).publish
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if payload[:debug] && payload.key?(:task_id)
|
|
23
|
+
generate_task_log(task_id: payload[:task_id],
|
|
24
|
+
function: 'check',
|
|
25
|
+
valid: conditioner.valid?,
|
|
26
|
+
conditions: payload[:conditions],
|
|
27
|
+
values: payload)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
{ success: true, valid: conditioner.valid? }
|
|
31
|
+
rescue StandardError => e
|
|
32
|
+
Legion::Logging.error 'LEX::Conditioner::Runners::Condition had an exception'
|
|
33
|
+
Legion::Logging.warn e.message
|
|
34
|
+
Legion::Logging.warn e.backtrace
|
|
35
|
+
unless payload[:task_id].nil?
|
|
36
|
+
Legion::Transport::Messages::TaskUpdate.new(task_id: payload[:task_id], status: 'conditioner.failed').publish
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.generate_task_log(task_id:, runner_class: to_s, function:, **payload)
|
|
41
|
+
require 'legion/transport/messages/task_log'
|
|
42
|
+
Legion::Transport::Messages::TaskLog.new(task_id: task_id,
|
|
43
|
+
runner_class: runner_class,
|
|
44
|
+
function: function,
|
|
45
|
+
entry: payload).publish
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'legion/extensions/transport'
|
|
2
|
+
|
|
3
|
+
module Legion::Extensions::Conditioner
|
|
4
|
+
module Transport
|
|
5
|
+
extend Legion::Extensions::Transport
|
|
6
|
+
def self.additional_e_to_q
|
|
7
|
+
[
|
|
8
|
+
{ from: 'task', to: 'conditioner', routing_key: 'task.subtask' },
|
|
9
|
+
{ from: 'task', to: 'conditioner', routing_key: 'task.subtask.conditioner' }
|
|
10
|
+
]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Legion::Extensions::Conditioner
|
|
2
|
+
module Transport
|
|
3
|
+
module Messages
|
|
4
|
+
class Conditioner < Legion::Transport::Message
|
|
5
|
+
def routing_key
|
|
6
|
+
'task.conditioner.succeeded'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def exchange
|
|
10
|
+
Legion::Transport::Exchanges::Task
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-conditioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miverson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: legionio
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,13 +53,13 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rubocop
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
|
-
type: :
|
|
62
|
+
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
@@ -67,7 +67,21 @@ dependencies:
|
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: legion-exceptions
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
87
|
- - ">="
|
|
@@ -87,14 +101,16 @@ executables: []
|
|
|
87
101
|
extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
|
89
103
|
files:
|
|
104
|
+
- ".circleci/config.yml"
|
|
90
105
|
- ".gitignore"
|
|
91
|
-
- ".idea
|
|
92
|
-
- ".idea/
|
|
106
|
+
- ".idea/.rakeTasks"
|
|
107
|
+
- ".idea/lex-conditioner.iml"
|
|
93
108
|
- ".idea/misc.xml"
|
|
94
109
|
- ".idea/modules.xml"
|
|
110
|
+
- ".idea/vagrant.xml"
|
|
95
111
|
- ".idea/workspace.xml"
|
|
96
112
|
- ".rspec"
|
|
97
|
-
- ".
|
|
113
|
+
- ".rubocop.yml"
|
|
98
114
|
- Gemfile
|
|
99
115
|
- LICENSE.txt
|
|
100
116
|
- README.md
|
|
@@ -103,6 +119,14 @@ files:
|
|
|
103
119
|
- bin/setup
|
|
104
120
|
- legion-extensions-conditioner.gemspec
|
|
105
121
|
- lib/legion/extensions/conditioner.rb
|
|
122
|
+
- lib/legion/extensions/conditioner/actors/conditioner.rb
|
|
123
|
+
- lib/legion/extensions/conditioner/helpers/comparator.rb
|
|
124
|
+
- lib/legion/extensions/conditioner/helpers/condition.rb
|
|
125
|
+
- lib/legion/extensions/conditioner/runners/conditioner.rb
|
|
126
|
+
- lib/legion/extensions/conditioner/transport.rb
|
|
127
|
+
- lib/legion/extensions/conditioner/transport/exchanges/task.rb
|
|
128
|
+
- lib/legion/extensions/conditioner/transport/messages/conditioner.rb
|
|
129
|
+
- lib/legion/extensions/conditioner/transport/queues/conditioner.rb
|
|
106
130
|
- lib/legion/extensions/conditioner/version.rb
|
|
107
131
|
homepage: https://bitbucket.org/legion-io/lex-conditioner
|
|
108
132
|
licenses:
|
|
@@ -110,6 +134,7 @@ licenses:
|
|
|
110
134
|
metadata:
|
|
111
135
|
homepage_uri: https://bitbucket.org/legion-io/lex-conditioner
|
|
112
136
|
source_code_uri: https://bitbucket.org/legion-io/lex-conditioner
|
|
137
|
+
changelog_uri: https://bitbucket.org/legion-io/lex-conditioner/src/master/CHANGELOG.md
|
|
113
138
|
post_install_message:
|
|
114
139
|
rdoc_options: []
|
|
115
140
|
require_paths:
|
|
@@ -125,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
150
|
- !ruby/object:Gem::Version
|
|
126
151
|
version: '0'
|
|
127
152
|
requirements: []
|
|
128
|
-
|
|
129
|
-
rubygems_version: 2.7.8
|
|
153
|
+
rubygems_version: 3.0.8
|
|
130
154
|
signing_key:
|
|
131
155
|
specification_version: 4
|
|
132
156
|
summary: LEX-Conditioner is used to apply conditional statements to tasks
|
data/.idea/encodings.xml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
|
4
|
-
<shared />
|
|
5
|
-
</component>
|
|
6
|
-
<component name="NewModuleRootManager">
|
|
7
|
-
<content url="file://$MODULE_DIR$" />
|
|
8
|
-
<orderEntry type="jdk" jdkName="RVM: ruby-2.4.5" jdkType="RUBY_SDK" />
|
|
9
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
-
<orderEntry type="library" scope="PROVIDED" name="amq-protocol (v2.3.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
11
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.3, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="bunny (v2.13.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
13
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="legion-exceptions (v0.1.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v12.3.2, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.8.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.8.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.8.2, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.8.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.8.0, RVM: ruby-2.4.5) [gem]" level="application" />
|
|
21
|
-
</component>
|
|
22
|
-
</module>
|