pigspec 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pigspec/javabridge.rb +15 -12
- data/lib/pigspec/version.rb +1 -1
- data/lib/pigspec.rb +15 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 208d740c894defd31ca2d2676ea9cefa0db09408
|
4
|
+
data.tar.gz: 30024c138ed78cd9dfa9aa88e5f701a5abe9e407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4697ee7aa6edee7d9f8cecc4695e58c550a01dd991bada4aa1d50586a24a5ebbd1f8e924ca534396b8385255617c9f2da41fa907996af3cea599ca2162167c8
|
7
|
+
data.tar.gz: 694b32e7286010429e9877343ac30eca05b15814b7d6360dcd6f81b323037837338ba7cba939b0af254ae27e476e2ca2e7334e2c43ae0e63f051b61c02025bf9
|
data/lib/pigspec/javabridge.rb
CHANGED
@@ -5,18 +5,8 @@ require 'tempfile'
|
|
5
5
|
module PigSpec
|
6
6
|
# bridge for java pig classies
|
7
7
|
class JavaBridge
|
8
|
-
def initialize(pig_path, pigunit_path)
|
9
|
-
|
10
|
-
fail ArgumentError, 'pigunit_path must not be nil.' if pigunit_path.nil?
|
11
|
-
|
12
|
-
Rjb.add_classpath(pig_path)
|
13
|
-
Rjb.add_classpath(pigunit_path)
|
14
|
-
|
15
|
-
Rjb.load '.', ['-Dfile.encoding=UTF-8']
|
16
|
-
|
17
|
-
Rjb.add_jar(pig_path)
|
18
|
-
Rjb.add_jar(pigunit_path)
|
19
|
-
|
8
|
+
def initialize(pig_path, pigunit_path, options)
|
9
|
+
load_pig pig_path, pigunit_path, options
|
20
10
|
import_classies
|
21
11
|
end
|
22
12
|
|
@@ -75,6 +65,19 @@ module PigSpec
|
|
75
65
|
|
76
66
|
private
|
77
67
|
|
68
|
+
def load_pig(pig_path, pigunit_path, options)
|
69
|
+
fail ArgumentError, 'pig_path must not be nil.' if pig_path.nil?
|
70
|
+
fail ArgumentError, 'pigunit_path must not be nil.' if pigunit_path.nil?
|
71
|
+
|
72
|
+
Rjb.add_classpath(pig_path)
|
73
|
+
Rjb.add_classpath(pigunit_path)
|
74
|
+
|
75
|
+
Rjb.load '.', options.map { |k, v| "-D#{k}=#{v}" }
|
76
|
+
|
77
|
+
Rjb.add_jar(pig_path)
|
78
|
+
Rjb.add_jar(pigunit_path)
|
79
|
+
end
|
80
|
+
|
78
81
|
def import_classies
|
79
82
|
require 'rjb/list'
|
80
83
|
@pig_test_class = Rjb.import('org.apache.pig.pigunit.PigTest')
|
data/lib/pigspec/version.rb
CHANGED
data/lib/pigspec.rb
CHANGED
@@ -12,25 +12,28 @@ module PigSpec
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
attr_reader :bridge
|
15
|
-
def construct(pig_path, pigunit_path)
|
16
|
-
@pig_path
|
17
|
-
@pigunit_path
|
15
|
+
def construct(pig_path, pigunit_path, options)
|
16
|
+
@pig_path ||= pig_path
|
17
|
+
@pigunit_path ||= pigunit_path
|
18
|
+
@options ||= options
|
18
19
|
|
19
|
-
fail ArgumentError, 'This version pigspec only can
|
20
|
-
fail ArgumentError, 'This version pigspec only can
|
20
|
+
fail ArgumentError, 'This version pigspec only can same pig_path for all processes.' unless @pig_path == pig_path
|
21
|
+
fail ArgumentError, 'This version pigspec only can same pigunit_path for all processes.' unless @pigunit_path == pigunit_path
|
22
|
+
fail ArgumentError, 'This version pigspec only can same options for all processes.' unless @options == options
|
21
23
|
|
22
|
-
@bridge ||= JavaBridge.new @pig_path, @pigunit_path
|
24
|
+
@bridge ||= JavaBridge.new @pig_path, @pigunit_path, @options
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
def setup(pig_path, pigunit_path)
|
27
|
-
|
28
|
+
def setup(pig_path, pigunit_path, options)
|
29
|
+
fail ArgumentError, 'Must needs pig_path. It must point to your installation of Apache Pig/PigUnit jar files.' if pig_path.nil?
|
30
|
+
fail ArgumentError, 'Must needs pigunit_path. It must point to your installation of Apache Pig/PigUnit jar files.' if pigunit_path.nil?
|
31
|
+
|
32
|
+
Test.construct pig_path, pigunit_path, options
|
28
33
|
@script = []
|
29
34
|
@args = []
|
30
35
|
@override = []
|
31
36
|
@pickup = nil
|
32
|
-
# rescue ArgumentError
|
33
|
-
# raise 'Must needs pig_path and pigunit_path. It must point to your installation of Apache Pig/PigUnit jar files.'
|
34
37
|
end
|
35
38
|
|
36
39
|
def shutdown
|
@@ -97,10 +100,10 @@ module_function
|
|
97
100
|
def pig(
|
98
101
|
pig_path = File.join(ENV['PIG_HOME'], 'pig.jar'),
|
99
102
|
pigunit_path = File.join(ENV['PIG_HOME'], 'pigunit.jar'),
|
100
|
-
&block
|
103
|
+
options = { 'file.encoding' => 'UTF-8' }, &block
|
101
104
|
)
|
102
105
|
test = Test.new
|
103
|
-
test.setup(pig_path, pigunit_path)
|
106
|
+
test.setup(pig_path, pigunit_path, options)
|
104
107
|
test.evaluate(&block)
|
105
108
|
result = test.run
|
106
109
|
test.shutdown
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pigspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shiracha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rjb
|