kiba-legacy-cli 1.0.0

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: 5573d5c6273b56e3d4a507f1d3af1f1234903930beaf984bb7bf721967c3189f
4
+ data.tar.gz: 602cb933f8019fd0ffd9eb062012942c9cf1d72287c147cd7e4a6e885c4f4b11
5
+ SHA512:
6
+ metadata.gz: 5a2ece118cbbaaa743e6b32251a943269b9c958cc0cbd63c9677be33961f8eaa5fc9d68fcd6ee4e83f5a7d1d612558f9a29f43902f19097838dd591ff0e3380e
7
+ data.tar.gz: 698c66820d75e88156236a14959daf439c6e50f30791b8b78db8331d23d24727ca2626ef9b0c8132a503de0a523221a2fb79500978faf9f407d7eea6b2266558
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+ Gemfile.lock
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ matrix:
3
+ include:
4
+ # see https://www.ruby-lang.org/en/downloads/branches/
5
+ - rvm: ruby-head
6
+ - rvm: 2.7
7
+ - rvm: 2.6
8
+ - rvm: 2.5
9
+ - rvm: 2.4
10
+ # NOTE: EOL since 2019-03-31
11
+ - rvm: 2.3
12
+ # see https://www.jruby.org/download
13
+ - rvm: jruby-9.1
14
+ - rvm: jruby-9.2
15
+ - rvm: truffleruby
16
+ jdk:
17
+ - openjdk8
@@ -0,0 +1,4 @@
1
+ 1.0.0
2
+ -----
3
+
4
+ - First version
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # TODO: remove this, once Kiba v3 is published, in favor of a gemspec declaration.
6
+ gem 'kiba', git: 'https://github.com/thbar/kiba.git', branch: 'deprecate-kiba-command-line'
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,5 @@
1
+ This gem provides a `bin/kiba-legacy-cli` command, which mimics the `bin/kiba` (removed in Kiba ETL v3), as described here:
2
+
3
+ https://github.com/thbar/kiba/issues/74
4
+
5
+ `kiba-legacy-cli` is here to temporarily provide backward compatibility for people using the CLI.
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new(:test) do |t|
4
+ t.pattern = 'test/test_*.rb'
5
+ end
6
+
7
+ task default: [:test]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/kiba-legacy-cli/cli'
4
+
5
+ Kiba::Legacy::CLI.run(ARGV)
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/kiba-legacy-cli/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Thibaut Barrère']
6
+ gem.email = ['thibaut.barrere@gmail.com']
7
+ gem.description = gem.summary = 'Legacy CLI command for Kiba ETL'
8
+ gem.homepage = 'https://github.com/thbar/kiba-legacy-cli'
9
+ gem.license = 'LGPL-3.0'
10
+ gem.files = `git ls-files | grep -Ev '^(examples)'`.split("\n")
11
+ gem.test_files = `git ls-files -- test/*`.split("\n")
12
+ gem.name = 'kiba-legacy-cli'
13
+ gem.require_paths = ['lib']
14
+ gem.version = Kiba::Legacy::CLI::VERSION
15
+ gem.executables = ['kiba-legacy-cli']
16
+ gem.metadata = {
17
+ 'source_code_uri' => 'https://github.com/thbar/kiba-legacy-cli',
18
+ 'documentation_uri' => 'https://github.com/thbar/kiba-legacy-cli/blob/master/README.md',
19
+ }
20
+
21
+ gem.add_dependency 'kiba', '~> 3.0'
22
+
23
+ gem.add_development_dependency 'rake'
24
+ gem.add_development_dependency 'minitest', '~> 5.9'
25
+ gem.add_development_dependency 'minitest-focus'
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'kiba'
2
+ require_relative 'legacy_parser'
3
+
4
+ module Kiba
5
+ module Legacy
6
+ module CLI
7
+ module_function
8
+
9
+ def run(args)
10
+ unless args.size == 1
11
+ puts 'Syntax: kiba-legacy-cli your-script.etl'
12
+ exit(-1)
13
+ end
14
+ filename = args[0]
15
+ script_content = IO.read(filename)
16
+ job_definition = Kiba::LegacyParser.parse(script_content, filename)
17
+ Kiba.run(job_definition)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # NOTE: using the "Kiba::Parser" declaration, as I discovered,
2
+ # provides increased isolation to the declared ETL script, compared
3
+ # to 2 nested modules.
4
+ # Before that, a user creating entities named Control, Context
5
+ # or DSLExtensions would see a conflict with Kiba own classes,
6
+ # as by default instance_eval will resolve references by adding
7
+ # the module containing the parser class (initially "Kiba").
8
+ # Now, the classes appear to be further hidden from the user,
9
+ # as Kiba::Parser is its own module.
10
+ # This allows the user to create a Parser, Context, Control class
11
+ # without it being interpreted as reopening Kiba::Parser, Kiba::Context,
12
+ # etc.
13
+ # See test in test_cli.rb (test_namespace_conflict)
14
+ module Kiba::LegacyParser
15
+ module_function
16
+
17
+ def parse(source_as_string = nil, source_file = nil, &source_as_block)
18
+ control = Kiba::Control.new
19
+ context = Kiba::Context.new(control)
20
+ context.instance_eval(*[source_as_string, source_file].compact)
21
+ control
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ module Kiba
2
+ module Legacy
3
+ module CLI
4
+ VERSION = '1.0.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ # this should fail because we have an unknown class
2
+ source UnknownThing
@@ -0,0 +1,9 @@
1
+ fail "Context should not be visible without Kiba namespace" if defined?(Context)
2
+ fail "Control should not be visible without Kiba namespace" if defined?(Control)
3
+ fail "Parser should not be visible without Kiba namespace" if defined?(Parser)
4
+ fail "Config should not be visible without Kiba namespace" if defined?(DSLExtensions::Config)
5
+
6
+ # verify Kiba config (namespaced under Kiba::DSLExtensions::Config)
7
+ # isn't causing troubles to implementers using a top-level DSLExtensions module
8
+ require_relative 'some_extension'
9
+ extend DSLExtensions::SomeExtension
@@ -0,0 +1,4 @@
1
+ module DSLExtensions
2
+ module SomeExtension
3
+ end
4
+ end
@@ -0,0 +1 @@
1
+ # this does nothing
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'minitest/focus'
@@ -0,0 +1,26 @@
1
+ require_relative 'helper'
2
+ require 'kiba-legacy-cli/cli'
3
+
4
+ class TestCli < Minitest::Test
5
+ def fixture(file)
6
+ File.join(File.dirname(__FILE__), 'fixtures', file)
7
+ end
8
+
9
+
10
+ def test_cli_launches
11
+ Kiba::Legacy::CLI.run([fixture('valid.etl')])
12
+ end
13
+
14
+ def test_cli_reports_filename_and_lineno
15
+ exception = assert_raises(NameError) do
16
+ Kiba::Legacy::CLI.run([fixture('bogus.etl')])
17
+ end
18
+
19
+ assert_match(/uninitialized constant(.*)UnknownThing/, exception.message)
20
+ assert_includes exception.backtrace.to_s, 'test/fixtures/bogus.etl:2:in'
21
+ end
22
+
23
+ def test_namespace_conflict
24
+ Kiba::Legacy::CLI.run([fixture('namespace_conflict.etl')])
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kiba-legacy-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thibaut Barrère
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kiba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-focus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Legacy CLI command for Kiba ETL
70
+ email:
71
+ - thibaut.barrere@gmail.com
72
+ executables:
73
+ - kiba-legacy-cli
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Changes.md
80
+ - Gemfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - bin/kiba-legacy-cli
85
+ - kiba-legacy-cli.gemspec
86
+ - lib/kiba-legacy-cli/cli.rb
87
+ - lib/kiba-legacy-cli/legacy_parser.rb
88
+ - lib/kiba-legacy-cli/version.rb
89
+ - test/fixtures/bogus.etl
90
+ - test/fixtures/namespace_conflict.etl
91
+ - test/fixtures/some_extension.rb
92
+ - test/fixtures/valid.etl
93
+ - test/helper.rb
94
+ - test/test_cli.rb
95
+ homepage: https://github.com/thbar/kiba-legacy-cli
96
+ licenses:
97
+ - LGPL-3.0
98
+ metadata:
99
+ source_code_uri: https://github.com/thbar/kiba-legacy-cli
100
+ documentation_uri: https://github.com/thbar/kiba-legacy-cli/blob/master/README.md
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubygems_version: 3.0.3
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Legacy CLI command for Kiba ETL
120
+ test_files:
121
+ - test/fixtures/bogus.etl
122
+ - test/fixtures/namespace_conflict.etl
123
+ - test/fixtures/some_extension.rb
124
+ - test/fixtures/valid.etl
125
+ - test/helper.rb
126
+ - test/test_cli.rb