pigspec 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ff6b83a92486fddcc094dc3b1659ef2c2012b56
4
- data.tar.gz: d03df5c39e749ae6f913f9b60a0d36a40c73017a
3
+ metadata.gz: 208d740c894defd31ca2d2676ea9cefa0db09408
4
+ data.tar.gz: 30024c138ed78cd9dfa9aa88e5f701a5abe9e407
5
5
  SHA512:
6
- metadata.gz: 28d0d8443c85e178019daa75120e11b705dbb8e05f3328012880018b35ac72998001f8ab7c1cc9b5f93f832697230949c06e5a547a0d0f318537d31a498c1682
7
- data.tar.gz: ef2511893dad84cc351967e91c228df9d42cd2b3686588a52c36ef686ee75672c792332e589f93548f7e6b4bdce4191eefbadc1cb6ac0b6ea3400bb9c66ea403
6
+ metadata.gz: c4697ee7aa6edee7d9f8cecc4695e58c550a01dd991bada4aa1d50586a24a5ebbd1f8e924ca534396b8385255617c9f2da41fa907996af3cea599ca2162167c8
7
+ data.tar.gz: 694b32e7286010429e9877343ac30eca05b15814b7d6360dcd6f81b323037837338ba7cba939b0af254ae27e476e2ca2e7334e2c43ae0e63f051b61c02025bf9
@@ -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
- fail ArgumentError, 'pig_path must not be nil.' if pig_path.nil?
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')
@@ -1,4 +1,4 @@
1
1
  # PigSpec version constant
2
2
  module PigSpec
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
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 = pig_path if @pig_path.nil?
17
- @pigunit_path = pigunit_path if @pigunit_path.nil?
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 a unique pig_path for one process.' unless @pig_path == pig_path
20
- fail ArgumentError, 'This version pigspec only can a unique pigunit_path for one process.' unless @pigunit_path == pigunit_path
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
- Test.construct pig_path, pigunit_path
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
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-08 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rjb