pdi 1.0.0 → 1.0.1

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: dc210f1ffd8bc1229082e29d8f2a54caea3d8e037d0b8e0e641265e171628b15
4
- data.tar.gz: aae44f8e89bd3ebee8ca03164cef6b1b0ddb07af2fafa2e412e481123451bc10
3
+ metadata.gz: 4dc8c8b41b233e1982d4c6164318cf9b4682dfcb335699d4027372edee921f8a
4
+ data.tar.gz: 6f61afc314e69019464cb4722063f02513a06f493e820661e2f12128af5d6658
5
5
  SHA512:
6
- metadata.gz: 99c07ce29149acef3b7dae5528a777d7e0172124fe0d987383157f3deeacfc6d3ccdb9ee2d66a20fb778b91729a083946502ffc9c4d1c2ca9e4d7c54daf591bc
7
- data.tar.gz: bb1724a9dfa3999a4a66ede97246b20b6945f231b087e132b55135c299637ca79fac556f80dee0e7782e73a1485f4bc24690000e7498a5bde854edb11955d032
6
+ metadata.gz: a540f0ad04dc38d0155c156041e22269155aa2fcad3958ec9a874302d888af4f70afdb69cf88ecebd624457d2fa8b03bba59c9963e5772d86f679088186a59bb
7
+ data.tar.gz: '085f9c0f9a0e2a3d4487d63a0c3a59ab0f5757e7eace1c757abedd96faf7d9152894e9c41a5c37bafe985a64889d03d5f8de3be72960a0ed9247ced3a14adfed'
@@ -1,4 +1,4 @@
1
- Metrics/LineLength:
1
+ Layout/LineLength:
2
2
  Max: 100
3
3
  Exclude:
4
4
  - pdi.gemspec
@@ -1,3 +1,9 @@
1
+ # 1.0.1 (February 19th, 2020)
2
+
3
+ Fixes:
4
+
5
+ * It now properly calls kitchen for jobs (it was previously calling pan.)
6
+
1
7
  # 1.0.0 (February 19th, 2020)
2
8
 
3
9
  Initial release.
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
- Note: 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.
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
 
@@ -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 = Options.make(options)
59
- final_args = [pan_path] + args + options.to_args
65
+ options = Options.make(options)
66
+ all_args = run_args(options)
60
67
 
61
- executor.run(final_args).tap do |result|
62
- raise(options.error_constant, result) if result.code != 0
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
@@ -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
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Pdi
11
- VERSION = '1.0.0'
11
+ VERSION = '1.0.1'
12
12
  end
@@ -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
@@ -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.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-19 00:00:00.000000000 Z
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/error_spec.rb
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/error_spec.rb
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