pdi 1.0.0 → 1.0.1
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +4 -1
- data/lib/pdi/spoon.rb +27 -4
- data/lib/pdi/spoon/options.rb +0 -11
- data/lib/pdi/version.rb +1 -1
- data/spec/pdi/spoon/kitchen_error_spec.rb +42 -0
- data/spec/pdi/spoon/{error_spec.rb → pan_error_spec.rb} +0 -0
- data/spec/pdi/spoon_spec.rb +16 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dc8c8b41b233e1982d4c6164318cf9b4682dfcb335699d4027372edee921f8a
|
4
|
+
data.tar.gz: 6f61afc314e69019464cb4722063f02513a06f493e820661e2f12128af5d6658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a540f0ad04dc38d0155c156041e22269155aa2fcad3958ec9a874302d888af4f70afdb69cf88ecebd624457d2fa8b03bba59c9963e5772d86f679088186a59bb
|
7
|
+
data.tar.gz: '085f9c0f9a0e2a3d4487d63a0c3a59ab0f5757e7eace1c757abedd96faf7d9152894e9c41a5c37bafe985a64889d03d5f8de3be72960a0ed9247ced3a14adfed'
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -46,7 +46,10 @@ All examples assume PDI has been installed to your home directory: `~/data-integ
|
|
46
46
|
spoon = Pdi::Spoon.new(dir: '~/data-integration')
|
47
47
|
```
|
48
48
|
|
49
|
-
|
49
|
+
Notes:
|
50
|
+
|
51
|
+
* You can also override the names of the scripts using the `kitchen` and `pan` constructor keyword arguments. The defaults are `kitchen.sh` and `pan.sh`, respectively.
|
52
|
+
* For other command line arguments that are not supported first-class in the Options objects below you can utilize the `args` argument when instantiating a `Spoon` instance.
|
50
53
|
|
51
54
|
### Executing a Job/Transformation
|
52
55
|
|
data/lib/pdi/spoon.rb
CHANGED
@@ -7,7 +7,9 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
+
require_relative 'spoon/kitchen_error'
|
10
11
|
require_relative 'spoon/options'
|
12
|
+
require_relative 'spoon/pan_error'
|
11
13
|
require_relative 'spoon/parser'
|
12
14
|
require_relative 'spoon/result'
|
13
15
|
|
@@ -17,6 +19,11 @@ module Pdi
|
|
17
19
|
DEFAULT_KITCHEN = 'kitchen.sh'
|
18
20
|
DEFAULT_PAN = 'pan.sh'
|
19
21
|
|
22
|
+
TYPES_TO_ERRORS = {
|
23
|
+
Options::Type::JOB => KitchenError,
|
24
|
+
Options::Type::TRANSFORMATION => PanError
|
25
|
+
}.freeze
|
26
|
+
|
20
27
|
attr_reader :args, :dir, :kitchen, :pan
|
21
28
|
|
22
29
|
def initialize(
|
@@ -55,11 +62,11 @@ module Pdi
|
|
55
62
|
# Returns an Executor::Result instance when PDI returns error code 0 or else raises
|
56
63
|
# a PanError (transformation) or KitchenError (job).
|
57
64
|
def run(options)
|
58
|
-
options
|
59
|
-
|
65
|
+
options = Options.make(options)
|
66
|
+
all_args = run_args(options)
|
60
67
|
|
61
|
-
executor.run(
|
62
|
-
raise(options
|
68
|
+
executor.run(all_args).tap do |result|
|
69
|
+
raise(error_constant(options), result) if result.code != 0
|
63
70
|
end
|
64
71
|
end
|
65
72
|
|
@@ -67,6 +74,22 @@ module Pdi
|
|
67
74
|
|
68
75
|
attr_reader :executor, :parser
|
69
76
|
|
77
|
+
def error_constant(options)
|
78
|
+
TYPES_TO_ERRORS.fetch(options.type)
|
79
|
+
end
|
80
|
+
|
81
|
+
def run_args(options)
|
82
|
+
[script_path(options.type)] + args + options.to_args
|
83
|
+
end
|
84
|
+
|
85
|
+
def script_path(options_type)
|
86
|
+
if options_type == Options::Type::JOB
|
87
|
+
kitchen_path
|
88
|
+
elsif options_type == Options::Type::TRANSFORMATION
|
89
|
+
pan_path
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
70
93
|
def kitchen_path
|
71
94
|
File.join(dir, kitchen)
|
72
95
|
end
|
data/lib/pdi/spoon/options.rb
CHANGED
@@ -7,10 +7,8 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
require_relative 'kitchen_error'
|
11
10
|
require_relative 'options/level'
|
12
11
|
require_relative 'options/param'
|
13
|
-
require_relative 'pan_error'
|
14
12
|
|
15
13
|
module Pdi
|
16
14
|
class Spoon
|
@@ -23,11 +21,6 @@ module Pdi
|
|
23
21
|
TRANSFORMATION = :transformation
|
24
22
|
end
|
25
23
|
|
26
|
-
TYPES_TO_ERRORS = {
|
27
|
-
Type::JOB => KitchenError,
|
28
|
-
Type::TRANSFORMATION => PanError
|
29
|
-
}.freeze
|
30
|
-
|
31
24
|
TYPES_TO_KEYS = {
|
32
25
|
Type::JOB => Arg::Key::JOB,
|
33
26
|
Type::TRANSFORMATION => Arg::Key::TRANS
|
@@ -63,10 +56,6 @@ module Pdi
|
|
63
56
|
base_args + param_args
|
64
57
|
end
|
65
58
|
|
66
|
-
def error_constant
|
67
|
-
TYPES_TO_ERRORS.fetch(type)
|
68
|
-
end
|
69
|
-
|
70
59
|
private
|
71
60
|
|
72
61
|
def key
|
data/lib/pdi/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
describe Pdi::Spoon::KitchenError do
|
13
|
+
describe 'initialization' do
|
14
|
+
[1, 2, 7, 8, 9].each do |code|
|
15
|
+
specify "code #{code} should have message" do
|
16
|
+
result = Pdi::Executor::Result.new(
|
17
|
+
args: [],
|
18
|
+
status: {
|
19
|
+
code: code,
|
20
|
+
pid: 123
|
21
|
+
}
|
22
|
+
)
|
23
|
+
|
24
|
+
expect(described_class.new(result).message).not_to eq('Unknown')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
[-1, 0, 3, 4, 5, 6, 10, 11].each do |code|
|
29
|
+
specify "code #{code} should not have message" do
|
30
|
+
result = Pdi::Executor::Result.new(
|
31
|
+
args: [],
|
32
|
+
status: {
|
33
|
+
code: code,
|
34
|
+
pid: 123
|
35
|
+
}
|
36
|
+
)
|
37
|
+
|
38
|
+
expect(described_class.new(result).message).to eq('Unknown')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
File without changes
|
data/spec/pdi/spoon_spec.rb
CHANGED
@@ -24,6 +24,14 @@ describe Pdi::Spoon do
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'will call pan script' do
|
28
|
+
subject = described_class.new(args: 0, dir: dir, pan: script)
|
29
|
+
|
30
|
+
result = subject.run(options)
|
31
|
+
|
32
|
+
expect(result.args.first).to include(script)
|
33
|
+
end
|
34
|
+
|
27
35
|
context 'when code is 0' do
|
28
36
|
it 'returns correct stdout, stderr and code' do
|
29
37
|
subject = described_class.new(
|
@@ -70,6 +78,14 @@ describe Pdi::Spoon do
|
|
70
78
|
}
|
71
79
|
end
|
72
80
|
|
81
|
+
it 'will call kitchen script' do
|
82
|
+
subject = described_class.new(args: 0, dir: dir, kitchen: script)
|
83
|
+
|
84
|
+
result = subject.run(options)
|
85
|
+
|
86
|
+
expect(result.args.first).to include(script)
|
87
|
+
end
|
88
|
+
|
73
89
|
context 'when code is 0' do
|
74
90
|
it 'returns correct stdout, stderr and code' do
|
75
91
|
subject = described_class.new(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -161,10 +161,11 @@ files:
|
|
161
161
|
- pdi.gemspec
|
162
162
|
- spec/mocks/spoon/return_code.sh
|
163
163
|
- spec/mocks/spoon/version.sh
|
164
|
-
- spec/pdi/spoon/
|
164
|
+
- spec/pdi/spoon/kitchen_error_spec.rb
|
165
165
|
- spec/pdi/spoon/options/arg_spec.rb
|
166
166
|
- spec/pdi/spoon/options/param_spec.rb
|
167
167
|
- spec/pdi/spoon/options_spec.rb
|
168
|
+
- spec/pdi/spoon/pan_error_spec.rb
|
168
169
|
- spec/pdi/spoon_spec.rb
|
169
170
|
- spec/spec_helper.rb
|
170
171
|
homepage: https://github.com/bluemarblepayroll/pdi
|
@@ -193,9 +194,10 @@ summary: Ruby wrapper for invoking Pentaho Data Integration
|
|
193
194
|
test_files:
|
194
195
|
- spec/mocks/spoon/return_code.sh
|
195
196
|
- spec/mocks/spoon/version.sh
|
196
|
-
- spec/pdi/spoon/
|
197
|
+
- spec/pdi/spoon/kitchen_error_spec.rb
|
197
198
|
- spec/pdi/spoon/options/arg_spec.rb
|
198
199
|
- spec/pdi/spoon/options/param_spec.rb
|
199
200
|
- spec/pdi/spoon/options_spec.rb
|
201
|
+
- spec/pdi/spoon/pan_error_spec.rb
|
200
202
|
- spec/pdi/spoon_spec.rb
|
201
203
|
- spec/spec_helper.rb
|