pdi 1.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7934ad85a3ff2d1c40beb617ca4d1d0ad24aaa3b937bb09409836ef12b245f06
4
+ data.tar.gz: d4a096374986562781a18905a8e9ea64039750f22e82e3b67d386143c31b2915
5
+ SHA512:
6
+ metadata.gz: c3f8ecf38e493e95100bfba8e92da5c344e629b89268c484ddb03834f32e8627e150e54705ca034176c63255c29db87c2b87b2ded8a5daf9033b161e57bdef5e
7
+ data.tar.gz: 0b299a6e8466c26de5c9dfada312beaae2a171c913b35dcba06ad2d34fb7a5cb9a82f1d48bd972bc08912acffed6f4e4941ad2665ab5a80fe6add18bacb71d00
@@ -0,0 +1,8 @@
1
+ # See http://editorconfig.org/
2
+
3
+ [*]
4
+ trim_trailing_whitespace = true
5
+ indent_style = space
6
+ indent_size = 2
7
+ insert_final_newline = true
8
+ end_of_line = lf
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.gem
3
+ /tmp
4
+ /coverage
5
+ Gemfile.lock
6
+ /pkg
@@ -0,0 +1,25 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+ Exclude:
4
+ - pdi.gemspec
5
+
6
+ Metrics/BlockLength:
7
+ ExcludedMethods:
8
+ - let
9
+ - it
10
+ - describe
11
+ - context
12
+ - specify
13
+ - define
14
+
15
+ Metrics/MethodLength:
16
+ Max: 25
17
+
18
+ AllCops:
19
+ TargetRubyVersion: 2.3
20
+
21
+ Metrics/AbcSize:
22
+ Max: 16
23
+
24
+ Metrics/ClassLength:
25
+ Max: 125
@@ -0,0 +1 @@
1
+ 2.6.5
@@ -0,0 +1,25 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=b2689967e1b2c3b5781da37cfc0eb4e0058178a78bba54294bf0c2a7c9e5cb63
4
+ language: ruby
5
+ rvm:
6
+ # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
+ - 2.3.8
8
+ - 2.4.6
9
+ - 2.5.5
10
+ - 2.6.5
11
+ cache: bundler
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
16
+ script:
17
+ - bundle exec rubocop
18
+ - bundle exec rspec spec --format documentation
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
+ addons:
22
+ # https://docs.travis-ci.com/user/uploading-artifacts/
23
+ artifacts:
24
+ paths:
25
+ - Gemfile.lock
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at oss@bluemarblepayroll.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
4
+ require 'guard/rspec/dsl'
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2020 Blue Marble Payroll, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,133 @@
1
+ # PDI
2
+
3
+ ---
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/pdi.svg)](https://badge.fury.io/rb/pdi) [![Build Status](https://travis-ci.org/bluemarblepayroll/pdi.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/pdi) [![Maintainability](https://api.codeclimate.com/v1/badges/955e491a34465360bf64/maintainability)](https://codeclimate.com/github/bluemarblepayroll/pdi/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/955e491a34465360bf64/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/pdi/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ *Note: This is not officially supported by Hitachi Vantara.*
8
+
9
+ This library provides a Ruby wrapper around [Pentaho Data Integration](https://www.hitachivantara.com/en-us/products/data-management-analytics/pentaho-platform/pentaho-data-integration.html) that allows you to execute tranformations and jobs via command line.
10
+
11
+ ## Installation
12
+
13
+ To install through Rubygems:
14
+
15
+ ````bash
16
+ gem install pdi
17
+ ````
18
+
19
+ You can also add this to your Gemfile:
20
+
21
+ ````bash
22
+ bundle add pdi
23
+ ````
24
+
25
+ ## Compatibility
26
+
27
+ This library was tested against:
28
+
29
+ * Kettle version 6.1.0.1-196
30
+ * MacOS and Linux
31
+
32
+ Pull Requests are welcome for:
33
+
34
+ * Windows support
35
+ * Upgraded Kettle versions (while maintaining backwards compatibility)
36
+
37
+ ## Examples
38
+
39
+ All examples assume PDI has been installed to your home directory: `~/data-integration`.
40
+
41
+ ### Creating a Spoon Instance
42
+
43
+ `PDI::Spoon` is the common interface you will use when interacting with PDI. It will use Pan and Kitchen for executing Spoon commands.
44
+
45
+ ```ruby
46
+ spoon = PDI::Spoon.new(dir: `~/data-integration`)
47
+ ```
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.
50
+
51
+ ### Executing a Job/Transformation
52
+
53
+ ```ruby
54
+ options = {
55
+ level: PDI::Spoon::Level::DETAILED,
56
+ name: 'update_address',
57
+ repository: 'transformations/demographics',
58
+ params: {
59
+ file: 'addresses.csv'
60
+ },
61
+ type: :transformation
62
+ }
63
+
64
+ result = spoon.run(options)
65
+ ```
66
+
67
+ `Spoon#run` will return:
68
+
69
+ * `PDI::Spoon::Result` upon a successful run.
70
+ * If a non-zero exit code was returned then a `PDI::Spoon::PanError` or `PDI::Spoon::KitchenError` will be raised.
71
+
72
+ You can access the raw command line results by tapping into the execution attribute of the result or error object.
73
+
74
+ Note: Not all options are currently supported. See PDI's official references for [Pan](https://help.pentaho.com/Documentation/6.1/0L0/0Y0/070/000) and [Kitchen](https://help.pentaho.com/Documentation/6.1/0L0/0Y0/070/010) to see all options.
75
+
76
+ ## Contributing
77
+
78
+ ### Development Environment Configuration
79
+
80
+ Basic steps to take to get this repository compiling:
81
+
82
+ 1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (check pdi.gemspec for versions supported)
83
+ 2. Install bundler (gem install bundler)
84
+ 3. Clone the repository (git clone git@github.com:bluemarblepayroll/pdi.git)
85
+ 4. Navigate to the root folder (cd pdi)
86
+ 5. Install dependencies (bundle)
87
+
88
+ ### Running Tests
89
+
90
+ To execute the test suite and code-coverage tool, run:
91
+
92
+ ````bash
93
+ bundle exec rspec spec --format documentation
94
+ ````
95
+
96
+ Alternatively, you can have Guard watch for changes:
97
+
98
+ ````bash
99
+ bundle exec guard
100
+ ````
101
+
102
+ Also, do not forget to run Rubocop:
103
+
104
+ ````bash
105
+ bundle exec rubocop
106
+ ````
107
+
108
+ or run all three in one command:
109
+
110
+ ````bash
111
+ bundle exec rake
112
+ ````
113
+
114
+ ### Publishing
115
+
116
+ Note: ensure you have proper authorization before trying to publish new versions.
117
+
118
+ After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
119
+
120
+ 1. Merge Pull Request into master
121
+ 2. Update `lib/pdi/version.rb` using [semantic versioning](https://semver.org/)
122
+ 3. Install dependencies: `bundle`
123
+ 4. Update `CHANGELOG.md` with release notes
124
+ 5. Commit & push master to remote and ensure CI builds master successfully
125
+ 6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
126
+
127
+ ## Code of Conduct
128
+
129
+ Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/pdi/blob/master/CODE_OF_CONDUCT.md).
130
+
131
+ ## License
132
+
133
+ This project is MIT Licensed.
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-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 'bundler/gem_tasks'
11
+ require 'rspec/core/rake_task'
12
+ require 'rubocop/rake_task'
13
+
14
+ RSpec::Core::RakeTask.new(:spec)
15
+ RuboCop::RakeTask.new
16
+
17
+ task default: %i[rubocop spec]
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # Copyright (c) 2018-present, Blue Marble Payroll, LLC
6
+ #
7
+ # This source code is licensed under the MIT license found in the
8
+ # LICENSE file in the root directory of this source tree.
9
+ #
10
+
11
+ require 'bundler/setup'
12
+ require 'pdi'
13
+
14
+ # You can add fixtures and/or initialization code here to make experimenting
15
+ # with your gem easier. You can also use a different console, if you like.
16
+
17
+ require 'pry'
18
+ Pry.start
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-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 'acts_as_hashable'
11
+ require 'open3'
12
+
13
+ require_relative 'pdi/executor'
14
+ require_relative 'pdi/spoon'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-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_relative 'executor/result'
11
+
12
+ module PDI
13
+ # This class is the library's "metal" layer, the one which actually makes the system call and
14
+ # interacts with the operating system (through Ruby's standard library.)
15
+ class Executor
16
+ SPACE = ' '
17
+
18
+ def run(*args)
19
+ cmd = args.flatten.join(SPACE)
20
+
21
+ Open3.popen2e(cmd) do |_stdin, stdout_and_stderr, wait_thr|
22
+ pid = wait_thr.pid
23
+ code = wait_thr.value.to_s.split(SPACE).last.to_i
24
+ out_and_err = stdout_and_stderr.read
25
+
26
+ Result.new(cmd, code, out_and_err, pid)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-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
+ module PDI
11
+ class Executor
12
+ # General return object for an execution call result.
13
+ class Result
14
+ attr_reader :cmd,
15
+ :code,
16
+ :out_and_err,
17
+ :pid
18
+
19
+ def initialize(cmd, code, out_and_err, pid)
20
+ @cmd = cmd
21
+ @code = code
22
+ @out_and_err = out_and_err
23
+ @pid = pid
24
+
25
+ freeze
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-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_relative 'spoon/options'
11
+ require_relative 'spoon/parser'
12
+ require_relative 'spoon/result'
13
+
14
+ module PDI
15
+ # This class is the main wrapper for PDI's pan and kitchen scripts.
16
+ class Spoon
17
+ DEFAULT_KITCHEN = 'kitchen.sh'
18
+ DEFAULT_PAN = 'pan.sh'
19
+
20
+ attr_reader :dir, :kitchen, :pan
21
+
22
+ def initialize(
23
+ dir:,
24
+ kitchen: DEFAULT_KITCHEN,
25
+ pan: DEFAULT_PAN
26
+ )
27
+ assert_required(:dir, dir)
28
+ assert_required(:kitchen, kitchen)
29
+ assert_required(:pan, pan)
30
+
31
+ @dir = dir.to_s
32
+ @kitchen = kitchen.to_s
33
+ @pan = pan.to_s
34
+ @executor = Executor.new
35
+ @parser = Parser.new
36
+
37
+ freeze
38
+ end
39
+
40
+ def version
41
+ args = [
42
+ kitchen_path,
43
+ Options::Arg.new(Options::Arg::Key::VERSION)
44
+ ]
45
+
46
+ result = executor.run(args)
47
+ version_line = parser.version(result.out_and_err)
48
+
49
+ Result.new(result, version_line)
50
+ end
51
+
52
+ def run(options)
53
+ options = Options.make(options)
54
+
55
+ args = [
56
+ pan_path
57
+ ] + options.to_args
58
+
59
+ result = executor.run(args)
60
+
61
+ raise(options.error_constant, result) if result.code != 0
62
+
63
+ Result.new(result, result.code)
64
+ end
65
+
66
+ private
67
+
68
+ attr_reader :executor, :parser
69
+
70
+ def kitchen_path
71
+ File.join(dir, kitchen)
72
+ end
73
+
74
+ def pan_path
75
+ File.join(dir, pan)
76
+ end
77
+
78
+ def assert_required(name, value)
79
+ raise ArgumentError, "#{name} is required" if value.to_s.empty?
80
+ end
81
+ end
82
+ end