Class: PigSpec::Test
Overview
TestCase of PigSpec
Class Attribute Summary collapse
-
.bridge ⇒ Object
readonly
Returns the value of attribute bridge.
Class Method Summary collapse
Instance Method Summary collapse
- #override(name, value) ⇒ Object
-
#pickup(name) ⇒ Object
to ‘expose’.
- #run ⇒ Object
- #script(text) ⇒ Object
- #script_file(path) ⇒ Object
- #setup ⇒ Object
- #shutdown ⇒ Object
- #with_args(*args) ⇒ Object
Class Attribute Details
.bridge ⇒ Object (readonly)
Returns the value of attribute bridge.
14 15 16 |
# File 'lib/pigspec.rb', line 14 def bridge @bridge end |
Class Method Details
.construct ⇒ Object
15 16 17 18 19 |
# File 'lib/pigspec.rb', line 15 def construct @bridge ||= JavaBridge.new rescue ArgumentError raise 'Environment variable PIG_HOME does not found or does not correct. It must point to your installation of Apache Pig.' end |
Instance Method Details
#override(name, value) ⇒ Object
52 53 54 |
# File 'lib/pigspec.rb', line 52 def override(name, value) @override.push name: name, value: value end |
#pickup(name) ⇒ Object
to ‘expose’
58 59 60 |
# File 'lib/pigspec.rb', line 58 def pickup(name) # rubocop:disable Style/TrivialAccessors @pickup = name end |
#run ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/pigspec.rb', line 63 def run # If no output alias, must result nil return nil unless @pickup test = Test.bridge.create_test @script, *@args test.register_script apply_override test test.run_script @pickup end |
#script(text) ⇒ Object
37 38 39 |
# File 'lib/pigspec.rb', line 37 def script(text) @script = text.split("\n") end |
#script_file(path) ⇒ Object
42 43 44 |
# File 'lib/pigspec.rb', line 42 def script_file(path) @script = open(path, 'r') { |f| f.each_line.to_a } end |
#setup ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/pigspec.rb', line 22 def setup Test.construct @script = [] @args = [] @override = [] @pickup = nil end |
#shutdown ⇒ Object
30 31 32 33 34 35 |
# File 'lib/pigspec.rb', line 30 def shutdown # Rjb unload -> load is not work.(current restriction.) # s.a https://github.com/arton/rjb/issues/34 # If the JNI bug fixed then we can uncomment follow line. # @bridge.unload end |
#with_args(*args) ⇒ Object
47 48 49 |
# File 'lib/pigspec.rb', line 47 def with_args(*args) @args = args end |