lex-transformer 0.1.3 → 0.1.4

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: bc75a07d6813a3629e479db7d5d5332df5732774ccd67cb2409511fb081b3030
4
- data.tar.gz: 8f1a7eb3b7e78458b1cd435b813bc5a1c71e877357eff8808e93bb909550a830
3
+ metadata.gz: 24dbbb177015cc67b411b4992d4b220082ae85fc3740a233439ba983ab496736
4
+ data.tar.gz: 5b836b34ed00f6937773638ea9dc9056e224f64b785ceb55b03bb0381c3ab899
5
5
  SHA512:
6
- metadata.gz: b58d6e24f6e205e7a9f5a5317e3260709c288066916864cc215f4c788a9688b69023678f269412d5d83ecfae5916b5d5b81ab48b97116f0fa0174cb16060738d
7
- data.tar.gz: d2bef037e4c5e5ae863b5dc066021d2e1ea92063f19c175239e69f25e59acb6bfc7e30a3868a9d188b7fe4ebfe686f022778e532f6c0624f859a92ad014aa25c
6
+ metadata.gz: b0b9b63fa282d53dff4b096a585788cec55440b178eeaa6b2b2b93ebd5caa7323b671f135e0a85e8f6bf3a970ce651fd1054f5b3305c7ff707afdf500911e524
7
+ data.tar.gz: fa7c078497b01e4a89ebfa10401e38f79a8914e2778e5737ede513e7e17571cd6b481ebf02b61b478bf753db4d2edc2c4da1acbc515c343db8ab33e0faf9690c
data/.rubocop.yml CHANGED
@@ -9,9 +9,9 @@ Metrics/BlockLength:
9
9
  Metrics/PerceivedComplexity:
10
10
  Max: 20
11
11
  Metrics/CyclomaticComplexity:
12
- Max: 15
12
+ Max: 117
13
13
  Metrics/AbcSize:
14
- Max: 50
14
+ Max: 52
15
15
  Layout/SpaceAroundEqualsInParameterDefault:
16
16
  EnforcedStyle: space
17
17
  Style/SymbolArray:
@@ -24,6 +24,7 @@ Style/Documentation:
24
24
  AllCops:
25
25
  TargetRubyVersion: 2.5
26
26
  NewCops: enable
27
+ SuggestExtensions: false
27
28
  Style/FrozenStringLiteralComment:
28
29
  Enabled: false
29
30
  Naming/FileName:
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM legionio/legion:latest
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 lex-transformer legion-data --no-document --no-prerelease
9
+ CMD ruby --jit $(which legionio)
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in legion-extensions-transformer.gemspec
4
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,37 +1,58 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lex-transformer (0.1.3)
4
+ lex-transformer (0.1.4)
5
5
  tilt
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.2)
10
11
  diff-lcs (1.4.4)
11
- rake (13.0.1)
12
- rspec (3.9.0)
13
- rspec-core (~> 3.9.0)
14
- rspec-expectations (~> 3.9.0)
15
- rspec-mocks (~> 3.9.0)
16
- rspec-core (3.9.3)
17
- rspec-support (~> 3.9.3)
18
- rspec-expectations (3.9.2)
12
+ parallel (1.20.1)
13
+ parser (3.0.0.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.0.0)
16
+ rake (13.0.3)
17
+ regexp_parser (2.1.1)
18
+ rexml (3.2.4)
19
+ rspec (3.10.0)
20
+ rspec-core (~> 3.10.0)
21
+ rspec-expectations (~> 3.10.0)
22
+ rspec-mocks (~> 3.10.0)
23
+ rspec-core (3.10.1)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-expectations (3.10.1)
19
26
  diff-lcs (>= 1.2.0, < 2.0)
20
- rspec-support (~> 3.9.0)
21
- rspec-mocks (3.9.1)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-mocks (3.10.2)
22
29
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.9.0)
24
- rspec-support (3.9.3)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-support (3.10.2)
32
+ rubocop (1.11.0)
33
+ parallel (~> 1.10)
34
+ parser (>= 3.0.0.0)
35
+ rainbow (>= 2.2.2, < 4.0)
36
+ regexp_parser (>= 1.8, < 3.0)
37
+ rexml
38
+ rubocop-ast (>= 1.2.0, < 2.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (>= 1.4.0, < 3.0)
41
+ rubocop-ast (1.4.1)
42
+ parser (>= 2.7.1.5)
43
+ ruby-progressbar (1.11.0)
25
44
  tilt (2.0.10)
45
+ unicode-display_width (2.0.0)
26
46
 
27
47
  PLATFORMS
28
48
  ruby
29
49
 
30
50
  DEPENDENCIES
31
- bundler
51
+ bundler (>= 2)
32
52
  lex-transformer!
33
53
  rake
34
54
  rspec
55
+ rubocop
35
56
 
36
57
  BUNDLED WITH
37
58
  2.1.4
@@ -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'
data/docker_deploy.rb ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ name = 'transformer'
4
+ require "./lib/legion/extensions/#{name}/version"
5
+ version = Legion::Extensions::Transformer::VERSION
6
+
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 tag legionio/lex-#{name}:v#{version} legionio/lex-#{name}:latest")
12
+ system("docker push legionio/lex-#{name}:latest")
13
+ puts 'completed'
@@ -5,7 +5,7 @@ require 'legion/extensions/transformer/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'lex-transformer'
7
7
  spec.version = Legion::Extensions::Transformer::VERSION
8
- spec.authors = ['Miverson']
8
+ spec.authors = ['Esity']
9
9
  spec.email = ['matthewdiverson@gmail.com']
10
10
 
11
11
  spec.summary = 'LEX-Transformer is used to transform payloads for the output'
@@ -14,14 +14,11 @@ 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-transformer'
20
- spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/lex-transformer'
21
- else
22
- raise 'RubyGems 2.0 or newer is required to protect against ' \
23
- 'public gem pushes.'
24
- end
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-transformer'
19
+ spec.metadata['documentation_uri'] = 'https://legionio.atlassian.net/wiki/spaces/LEX/pages/612270222'
20
+ spec.metadata['changelog_uri'] = 'https://legionio.atlassian.net/wiki/spaces/LEX/pages/614858842'
21
+ spec.metadata['bug_tracker_uri'] = 'https://bitbucket.org/legion-io/lex-transformer/issues'
25
22
 
26
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -30,7 +27,8 @@ Gem::Specification.new do |spec|
30
27
 
31
28
  spec.add_dependency 'tilt'
32
29
 
33
- spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'bundler', '>= 2'
34
31
  spec.add_development_dependency 'rake'
35
32
  spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop'
36
34
  end
@@ -1,10 +1,13 @@
1
1
  require 'legion/extensions/transformer/version'
2
- require 'legion/extensions'
3
2
 
4
3
  module Legion
5
4
  module Extensions
6
5
  module Transformer
7
- extend Legion::Extensions::Core
6
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
7
+
8
+ def self.data_required?
9
+ true
10
+ end
8
11
 
9
12
  def data_required?
10
13
  true
@@ -2,27 +2,30 @@ require 'tilt'
2
2
 
3
3
  module Legion::Extensions::Transformer
4
4
  module Runners
5
- class Transform
6
- extend Legion::Extensions::Helpers::Lex
7
- extend Legion::Extensions::Helpers::Task
5
+ module Transform
6
+ def transform(transformation:, **payload)
7
+ if transformation.include?('<%') || transformation.include?('%>')
8
+ template = Tilt['erb'].new { transformation }
9
+ variables = { **payload }
10
+ variables[:crypt] = Legion::Crypt if transformation.include? 'crypt'
11
+ variables[:settings] = Legion::Settings if transformation.include? 'settings'
12
+ variables[:cache] = Legion::Cache if transformation.include? 'cache'
13
+ if payload.key?(:task_id) && transformation.include?('task')
14
+ variables[:task] = Legion::Data::Model::Task[payload[:task_id]]
15
+ end
8
16
 
9
- def self.transform(transformation:, **payload)
10
- template = Tilt['erb'].new { transformation }
11
- variables = { **payload }
12
- variables[:crypt] = Legion::Crypt if transformation.include? 'crypt'
13
- variables[:settings] = Legion::Settings if transformation.include? 'settings'
14
- variables[:cache] = Legion::Cache if transformation.include? 'cache'
15
- if payload.key?(:task_id) && transformation.include?('task')
16
- variables[:task] = Legion::Data::Model::Task[payload[:task_id]]
17
+ payload[:args] = from_json(template.render(self, variables))
18
+ else
19
+ payload[:args] = from_json(transformation)
17
20
  end
18
21
 
19
- payload[:args] = from_json(template.render(self, variables))
20
22
  case payload[:args]
21
23
  when Hash
22
24
  unless payload[:task_id].nil?
23
25
  task_update(payload[:task_id], 'transformer.succeeded', function_args: payload[:args])
24
26
  end
25
27
  send_task(**payload)
28
+ task_update(payload[:task_id], 'task.queued', use_database: false) unless payload[:task_id].nil?
26
29
  when Array
27
30
  payload[:args].each do |thing|
28
31
  new_payload = payload
@@ -41,14 +44,13 @@ module Legion::Extensions::Transformer
41
44
  end
42
45
  end
43
46
 
44
- task_update(payload[:task_id], 'task.queued') unless payload[:task_id].nil?
45
47
  if payload[:debug] && payload.key?(:task_id)
46
48
  generate_task_log(task_id: payload[:task_id], function: 'transform', values: payload)
47
49
  end
48
50
  { success: true, **payload }
49
51
  end
50
52
 
51
- def self.send_task(**opts)
53
+ def send_task(**opts)
52
54
  payload = {}
53
55
  %i[task_id relationship_id trigger_function_id runner_class function_id function chain_id debug args].each do |thing| # rubocop:disable Layout/LineLength
54
56
  payload[thing] = opts[thing] if opts.key? thing
@@ -56,6 +58,9 @@ module Legion::Extensions::Transformer
56
58
 
57
59
  Legion::Extensions::Transformer::Transport::Messages::Message.new(**payload).publish
58
60
  end
61
+
62
+ include Legion::Extensions::Helpers::Lex
63
+ extend Legion::Extensions::Helpers::Task
59
64
  end
60
65
  end
61
66
  end
@@ -1,7 +1,7 @@
1
1
  module Legion
2
2
  module Extensions
3
3
  module Transformer
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.1.4'.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-transformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-10-15 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
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'
69
83
  description: Runs transformer statements against tasks in a relationship
70
84
  email:
71
85
  - matthewdiverson@gmail.com
@@ -73,18 +87,18 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - ".circleci/config.yml"
77
90
  - ".gitignore"
78
91
  - ".rspec"
79
92
  - ".rubocop.yml"
80
93
  - CODE_OF_CONDUCT.md
94
+ - Dockerfile
81
95
  - Gemfile
82
96
  - Gemfile.lock
83
97
  - LICENSE.txt
84
98
  - README.md
85
99
  - Rakefile
86
- - bin/console
87
- - bin/setup
100
+ - bitbucket-pipelines.yml
101
+ - docker_deploy.rb
88
102
  - lex-transformer.gemspec
89
103
  - lib/legion/extensions/transformer.rb
90
104
  - lib/legion/extensions/transformer/actors/transform.rb
@@ -100,8 +114,10 @@ licenses:
100
114
  metadata:
101
115
  homepage_uri: https://bitbucket.org/legion-io/lex-transformer
102
116
  source_code_uri: https://bitbucket.org/legion-io/lex-transformer
103
- changelog_uri: https://bitbucket.org/legion-io/lex-transformer
104
- post_install_message:
117
+ documentation_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/612270222
118
+ changelog_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/614858842
119
+ bug_tracker_uri: https://bitbucket.org/legion-io/lex-transformer/issues
120
+ post_install_message:
105
121
  rdoc_options: []
106
122
  require_paths:
107
123
  - lib
@@ -116,8 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  requirements: []
119
- rubygems_version: 3.1.2
120
- signing_key:
135
+ rubygems_version: 3.1.4
136
+ signing_key:
121
137
  specification_version: 4
122
138
  summary: LEX-Transformer is used to transform payloads for the output
123
139
  test_files: []
data/.circleci/config.yml DELETED
@@ -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
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'legion/extensions/transformer'
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