lex-conditioner 0.2.1 → 0.2.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: 22a9ebeed3f7daad4ca49da310545ccc0a10fccc521c40aeedc1c76827c242d4
4
- data.tar.gz: 2fdfcf7cc7d4abd57dcc865f31fe06547378f02f05f1d2f48e7fa44bcf2121ad
3
+ metadata.gz: a3c19810b2bf041292ba076fc0a51c3a5c323f57a4c16c3eb2b14e8256846735
4
+ data.tar.gz: c28abda1380e331c1145ea47dc1d6dd0e37aef6a80eac7c0a52b6b857938ddc4
5
5
  SHA512:
6
- metadata.gz: 9405d35955e167e61d9027155cf3f1d39aa13db967839f5df67b1070a361bd0383028e4ef028e933a29ebc77adc5d73b002d9ead1b1c7fa03cc95eff8506e5c8
7
- data.tar.gz: 2037a3795580b3cf6f101e75f875cbd63890a8ebc98ab197bafe6d9e889ded5d6912166d52bf6626872dd31a811c9a1610caf5e8d354ac1433cd5b97b8b1746f
6
+ metadata.gz: c3d98cb4fbad0ab36ff8d2cbf9f4b630ce850b75442290388e8ed57ba641e82e0816541a12b3c2397896d908b8dc2b57f2a2f905560e67eb8c7954eba2738173
7
+ data.tar.gz: e7c681eb8e9a2840a8e632c98e9c1289b6b6078e8bda6b1e74a1722cca113d6fc2392d905a7f3c8f137a8fa478114023cc8b1eb7ed37893afcb084c3105ae033
@@ -8,6 +8,10 @@ Metrics/BlockLength:
8
8
  Max: 50
9
9
  Metrics/AbcSize:
10
10
  Max: 20
11
+ Metrics/CyclomaticComplexity:
12
+ Max: 20
13
+ Metrics/PerceivedComplexity:
14
+ Max: 20
11
15
  Layout/SpaceAroundEqualsInParameterDefault:
12
16
  EnforcedStyle: space
13
17
  Style/SymbolArray:
@@ -20,6 +24,7 @@ Style/Documentation:
20
24
  AllCops:
21
25
  TargetRubyVersion: 2.5
22
26
  NewCops: enable
27
+ SuggestExtensions: false
23
28
  Style/FrozenStringLiteralComment:
24
29
  Enabled: false
25
30
  Naming/FileName:
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.7-alpine
2
+ LABEL maintainer="Matthew Iverson <matthewdiverson@gmail.com>"
3
+
4
+ RUN mkdir /etc/legionio
5
+ RUN apk update && apk add build-base tzdata gcc git
6
+
7
+ COPY . ./
8
+ RUN gem install legionio tzinfo-data tzinfo --no-document --no-prerelease
9
+ RUN gem install lex-conditioner --no-document --no-prerelease
10
+ CMD legionio
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lex-conditioner (0.2.1)
4
+ lex-conditioner (0.2.3)
5
5
  legion-exceptions
6
6
 
7
7
  GEM
@@ -12,110 +12,95 @@ GEM
12
12
  aws-eventstream (1.1.0)
13
13
  aws-sigv4 (1.2.2)
14
14
  aws-eventstream (~> 1, >= 1.0.2)
15
- bunny (2.16.1)
15
+ bunny (2.17.0)
16
16
  amq-protocol (~> 2.3, >= 2.3.1)
17
17
  concurrent-ruby (1.1.7)
18
18
  concurrent-ruby-ext (1.1.7)
19
19
  concurrent-ruby (= 1.1.7)
20
20
  connection_pool (2.2.3)
21
21
  daemons (1.3.1)
22
- dalli (2.7.10)
22
+ dalli (2.7.11)
23
23
  diff-lcs (1.4.4)
24
- docile (1.3.2)
25
- faraday (1.0.1)
26
- multipart-post (>= 1.2, < 3)
27
- faraday_middleware (1.0.0)
28
- faraday (~> 1.0)
29
- ffi (1.13.1)
30
- hashdiff (1.0.1)
31
- legion-cache (1.0.0)
32
- connection_pool
33
- dalli
34
- redis
35
- legion-crypt (0.2.0)
36
- rbnacl
24
+ docile (1.3.5)
25
+ json_pure (2.5.1)
26
+ legion-cache (1.1.1)
27
+ connection_pool (>= 2.2.3)
28
+ dalli (>= 2.7)
29
+ redis (>= 4.2)
30
+ legion-crypt (0.2.3)
37
31
  vault
38
- legion-data (0.2.0)
39
- legion-logging
40
- legion-settings
41
- mysql2
42
- sequel
43
- legion-exceptions (1.1.0)
44
- legion-json (1.1.0)
32
+ legion-exceptions (1.1.5)
33
+ legion-json (1.1.4)
34
+ json_pure
35
+ legion-exceptions (>= 1.1.5)
45
36
  multi_json
46
- legion-logging (1.1.0)
37
+ legion-logging (1.1.4)
47
38
  rainbow (~> 3)
48
- legion-settings (1.1.1)
39
+ legion-settings (1.1.3)
49
40
  legion-json
50
41
  legion-logging
51
- legion-transport (1.1.1)
52
- bunny
53
- concurrent-ruby
54
- legionio (0.2.0)
55
- concurrent-ruby
56
- concurrent-ruby-ext
57
- daemons
58
- hashdiff
42
+ legion-transport (1.1.8)
43
+ bunny (>= 2.17.0)
44
+ concurrent-ruby (>= 1.1.7)
45
+ legion-json
46
+ legionio (0.4.0)
47
+ concurrent-ruby (>= 1.1.7)
48
+ concurrent-ruby-ext (>= 1.1.7)
49
+ daemons (>= 1.3.1)
59
50
  legion-cache
60
- legion-crypt
61
- legion-data
51
+ legion-crypt (>= 0.2.0)
62
52
  legion-exceptions
63
53
  legion-json
64
54
  legion-logging
65
55
  legion-settings
66
- legion-transport
67
- sleepiq
68
- vault
56
+ legion-transport (>= 1.1.8)
57
+ lex-node
58
+ oj (>= 3.10)
59
+ thor (>= 1)
60
+ lex-node (0.1.3)
69
61
  multi_json (1.15.0)
70
- multipart-post (2.1.1)
71
- mysql2 (0.5.3)
72
- parallel (1.19.2)
73
- parser (2.7.1.4)
62
+ oj (3.11.0)
63
+ parallel (1.20.1)
64
+ parser (3.0.0.0)
74
65
  ast (~> 2.4.1)
75
66
  rainbow (3.0.0)
76
- rake (13.0.1)
77
- rbnacl (7.1.1)
78
- ffi
79
- redis (4.2.1)
80
- regexp_parser (1.7.1)
67
+ rake (13.0.3)
68
+ redis (4.2.5)
69
+ regexp_parser (2.0.3)
81
70
  rexml (3.2.4)
82
- rspec (3.9.0)
83
- rspec-core (~> 3.9.0)
84
- rspec-expectations (~> 3.9.0)
85
- rspec-mocks (~> 3.9.0)
86
- rspec-core (3.9.2)
87
- rspec-support (~> 3.9.3)
88
- rspec-expectations (3.9.2)
71
+ rspec (3.10.0)
72
+ rspec-core (~> 3.10.0)
73
+ rspec-expectations (~> 3.10.0)
74
+ rspec-mocks (~> 3.10.0)
75
+ rspec-core (3.10.1)
76
+ rspec-support (~> 3.10.0)
77
+ rspec-expectations (3.10.1)
89
78
  diff-lcs (>= 1.2.0, < 2.0)
90
- rspec-support (~> 3.9.0)
91
- rspec-mocks (3.9.1)
79
+ rspec-support (~> 3.10.0)
80
+ rspec-mocks (3.10.1)
92
81
  diff-lcs (>= 1.2.0, < 2.0)
93
- rspec-support (~> 3.9.0)
94
- rspec-support (3.9.3)
95
- rubocop (0.89.1)
82
+ rspec-support (~> 3.10.0)
83
+ rspec-support (3.10.1)
84
+ rubocop (1.8.1)
96
85
  parallel (~> 1.10)
97
- parser (>= 2.7.1.1)
86
+ parser (>= 3.0.0.0)
98
87
  rainbow (>= 2.2.2, < 4.0)
99
- regexp_parser (>= 1.7)
88
+ regexp_parser (>= 1.8, < 3.0)
100
89
  rexml
101
- rubocop-ast (>= 0.3.0, < 1.0)
90
+ rubocop-ast (>= 1.2.0, < 2.0)
102
91
  ruby-progressbar (~> 1.7)
103
- unicode-display_width (>= 1.4.0, < 2.0)
104
- rubocop-ast (0.3.0)
105
- parser (>= 2.7.1.4)
106
- ruby-progressbar (1.10.1)
107
- sequel (5.35.0)
108
- simplecov (0.19.0)
92
+ unicode-display_width (>= 1.4.0, < 3.0)
93
+ rubocop-ast (1.4.0)
94
+ parser (>= 2.7.1.5)
95
+ ruby-progressbar (1.11.0)
96
+ simplecov (0.21.2)
109
97
  docile (~> 1.1)
110
98
  simplecov-html (~> 0.11)
111
- simplecov-html (0.12.2)
112
- sleepiq (0.2.2)
113
- dalli
114
- faraday
115
- faraday_middleware
116
- thor
99
+ simplecov_json_formatter (~> 0.1)
100
+ simplecov-html (0.12.3)
101
+ simplecov_json_formatter (0.1.2)
117
102
  thor (1.0.1)
118
- unicode-display_width (1.7.0)
103
+ unicode-display_width (2.0.0)
119
104
  vault (0.15.0)
120
105
  aws-sigv4
121
106
 
@@ -0,0 +1,19 @@
1
+ image: ruby:2.7
2
+
3
+ pipelines:
4
+ tags:
5
+ "v*":
6
+ - step:
7
+ name: Push to RubyGems
8
+ deployment: RubyGems
9
+ script:
10
+ - gem install gem-release
11
+ - (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
12
+ - gem release
13
+ artifacts:
14
+ - pkg/**
15
+ - step:
16
+ name: Push to Docker
17
+ deployment: Docker
18
+ script:
19
+ - './docker_deploy.rb'
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ version = Legion::Extensions::Conditioner::VERSION
4
+ name = 'conditioner'
5
+
6
+ require "./lib/legion/extensions/#{name}/version"
7
+ puts "Building docker image for Legion v#{version}"
8
+ system("docker build --tag legionio/lex-#{name}:v#{version} .")
9
+ puts 'Pushing to hub.docker.com'
10
+ system("docker push legionio/lex-#{name}:v#{version}")
11
+ system("docker push legionio/lex-#{name}:latest")
12
+ puts 'completed'
@@ -5,7 +5,7 @@ require 'legion/extensions/conditioner/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'lex-conditioner'
7
7
  spec.version = Legion::Extensions::Conditioner::VERSION
8
- spec.authors = ['Miverson']
8
+ spec.authors = ['Esity']
9
9
  spec.email = ['matthewdiverson@gmail.com']
10
10
 
11
11
  spec.summary = 'LEX-Conditioner is used to apply conditional statements to tasks'
@@ -14,16 +14,15 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
16
 
17
- if spec.respond_to?(:metadata)
18
- spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner'
20
- spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner/src/master/CHANGELOG.md'
21
- end
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner'
19
+ spec.metadata['documentation_uri'] = 'https://legionio.atlassian.net/wiki/spaces/LEX/pages/614957181'
20
+ spec.metadata['changelog_uri'] = 'https://legionio.atlassian.net/wiki/spaces/LEX/pages/612270436'
21
+ spec.metadata['bug_tracker_uri'] = 'https://bitbucket.org/legion-io/lex-conditioner/issues'
22
22
 
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
26
  spec.require_paths = ['lib']
28
27
 
29
28
  spec.add_development_dependency 'legionio'
@@ -1,10 +1,9 @@
1
1
  require 'legion/extensions/conditioner/version'
2
- require 'legion/extensions'
3
2
 
4
3
  module Legion
5
4
  module Extensions
6
5
  module Conditioner
7
- extend Legion::Extensions::Core
6
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
8
7
  end
9
8
  end
10
9
  end
@@ -7,7 +7,6 @@ module Legion
7
7
  def initialize(args)
8
8
  @conditions = Legion::JSON.load(args[:conditions])
9
9
  @values = to_dotted_hash(args[:values])
10
- @task_id = args[:task_id]
11
10
  end
12
11
 
13
12
  def to_dotted_hash(source, target = {}, namespace = nil)
@@ -30,13 +29,11 @@ module Legion
30
29
  def validate_vars
31
30
  raise Legion::Exception::MissingArgument, '@conditions is nil' if @conditions.nil?
32
31
  raise Legion::Exception::MissingArgument, '@values is nil' if @values.nil?
33
- raise Legion::Exception::MissingArgument, '@task_id is nil' if @task_id.nil?
34
32
  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
33
  raise Legion::Exception::WrongType::Hash, @conditions.class unless @conditions.is_a? Hash
37
34
  end
38
35
 
39
- def validate_test(conditions = @conditions) # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize
36
+ def validate_test(conditions = @conditions) # rubocop:disable Metrics/AbcSize
40
37
  conditions.each do |condition|
41
38
  condition[1].each do |rule|
42
39
  result = validate_test('conditions' => { 'all' => rule[:all] }) if rule.include? :all
@@ -3,18 +3,22 @@ require 'legion/extensions/conditioner/helpers/condition'
3
3
  module Legion::Extensions::Conditioner
4
4
  module Runners
5
5
  module Conditioner
6
- def self.check(**payload) # rubocop:disable Metrics/AbcSize
7
- conditioner = Legion::Extensions::Conditioner::Condition.new(conditions: payload[:conditions],
8
- task_id: payload[:task_id],
6
+ def check(conditions:, **payload) # rubocop:disable Metrics/AbcSize
7
+ conditioner = Legion::Extensions::Conditioner::Condition.new(conditions: conditions,
9
8
  values: payload,
10
9
  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
10
 
11
+ status = if conditioner.valid? && payload.key?(:transformation)
12
+ 'transformation.queued'
13
+ elsif conditioner.valid? && payload.key?(:runner_routing_key)
14
+ 'task.queued'
15
+ elsif conditioner.valid?
16
+ 'task.exception'
17
+ else
18
+ 'conditioner.failed'
19
+ end
20
+
21
+ send_task(**payload) unless status == 'conditioner.failed'
18
22
  task_update(payload[:task_id], status, **payload) unless payload[:task_id].nil?
19
23
 
20
24
  if payload[:debug] && payload.key?(:task_id)
@@ -30,9 +34,24 @@ module Legion::Extensions::Conditioner
30
34
  Legion::Logging.error 'LEX::Conditioner::Runners::Condition had an exception'
31
35
  Legion::Logging.warn e.message
32
36
  Legion::Logging.warn e.backtrace
33
- unless payload[:task_id].nil?
34
- Legion::Transport::Messages::TaskUpdate.new(task_id: payload[:task_id], status: 'conditioner.failed').publish
37
+ task_update(payload[:task_id], 'conditioner.exception', **payload) unless payload[:task_id].nil?
38
+ end
39
+
40
+ def send_task(**opts)
41
+ subtask_hash = {}
42
+ %i[runner_routing_key relationship_id chain_id trigger_runner_id trigger_function_id funciton_id function runner_id runner_class transformation debug task_id results].each do |column| # rubocop:disable Layout/LineLength
43
+ subtask_hash[column] = opts[column] if opts.key? column
35
44
  end
45
+
46
+ subtask_hash[:routing_key] = if subtask_hash.key? :transformation
47
+ 'task.subtask.transform'
48
+ elsif subtask_hash.key? :runner_routing_key
49
+ subtask_hash[:runner_routing_key]
50
+ end
51
+
52
+ raise Legion::Exception::MissingArgument 'Missing :routing_key' unless subtask_hash.key? :routing_key
53
+
54
+ Legion::Transport::Messages::SubTask.new(**subtask_hash).publish
36
55
  end
37
56
 
38
57
  include Legion::Extensions::Helpers::Lex
@@ -1,7 +1,7 @@
1
1
  module Legion
2
2
  module Extensions
3
3
  module Conditioner
4
- VERSION = '0.2.1'.freeze
4
+ VERSION = '0.2.3'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-conditioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
- - Miverson
8
- autorequire:
7
+ - Esity
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: legionio
@@ -101,18 +101,18 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".circleci/config.yml"
105
104
  - ".gitignore"
106
105
  - ".rspec"
107
106
  - ".rubocop.yml"
107
+ - Dockerfile
108
108
  - Gemfile
109
109
  - Gemfile.lock
110
110
  - LICENSE.txt
111
111
  - README.md
112
112
  - Rakefile
113
- - bin/console
114
- - bin/setup
115
- - legion-extensions-conditioner.gemspec
113
+ - bitbucket-pipelines.yml
114
+ - docker_deploy.rb
115
+ - lex-conditioner.gemspec
116
116
  - lib/legion/extensions/conditioner.rb
117
117
  - lib/legion/extensions/conditioner/actors/conditioner.rb
118
118
  - lib/legion/extensions/conditioner/helpers/comparator.rb
@@ -129,8 +129,10 @@ licenses:
129
129
  metadata:
130
130
  homepage_uri: https://bitbucket.org/legion-io/lex-conditioner
131
131
  source_code_uri: https://bitbucket.org/legion-io/lex-conditioner
132
- changelog_uri: https://bitbucket.org/legion-io/lex-conditioner/src/master/CHANGELOG.md
133
- post_install_message:
132
+ documentation_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/614957181
133
+ changelog_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/612270436
134
+ bug_tracker_uri: https://bitbucket.org/legion-io/lex-conditioner/issues
135
+ post_install_message:
134
136
  rdoc_options: []
135
137
  require_paths:
136
138
  - lib
@@ -145,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
147
  - !ruby/object:Gem::Version
146
148
  version: '0'
147
149
  requirements: []
148
- rubygems_version: 3.1.2
149
- signing_key:
150
+ rubygems_version: 3.1.4
151
+ signing_key:
150
152
  specification_version: 4
151
153
  summary: LEX-Conditioner is used to apply conditional statements to tasks
152
154
  test_files: []
@@ -1,61 +0,0 @@
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
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'legion/extensions/conditioner'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here