rbpig 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rbpig.rb +15 -15
  2. metadata +4 -16
@@ -69,30 +69,30 @@ module RBPig
69
69
  end
70
70
  end
71
71
 
72
- pig_execution = "#{RBPig.executable(@configs)} -f #{pig_script_path} 2>&1"
73
- pig_out = []
74
- IO.popen(pig_execution) do |stdout|
75
- puts pig_execution
72
+ execute("#{RBPig.executable(@configs)} -f #{pig_script_path} 2>&1")
73
+ return *fetch_files_in_hdfs(aliases).map {|lines| lines.map{|e| e.chomp("\n").split("\t", -1)}}
74
+ end
75
+
76
+ private
77
+ def execute(execution)
78
+ out = []
79
+ IO.popen(execution) do |stdout|
80
+ puts execution
76
81
  until stdout.eof? do
77
- pig_out << stdout.gets
78
- puts pig_out.last
82
+ out << stdout.gets
83
+ puts out.last
79
84
  end
80
85
  end
81
-
82
- if $?.success?
83
- return *fetch_files_in_hdfs(aliases).map {|lines| lines.map{|e| e.chomp("\n").split("\t", -1)}}
84
- else
85
- raise "#{pig_out.join("\n")}Failed executing #{pig_execution}"
86
- end
86
+
87
+ raise "#{out.join("\n")}Failed executing #{execution}" unless $?.success?
87
88
  end
88
89
 
89
- private
90
90
  def fetch_files_in_hdfs(file_paths)
91
91
  mandy_config = @configs[:hadoop_config].nil? && "" || "-c #{@configs[:hadoop_config]}"
92
92
  return file_paths.map do |file_path|
93
93
  FileUtils.remove_file(file_path, true) if File.exists?(file_path)
94
- `mandy-get #{mandy_config} #{file_path} #{file_path}`
95
- `mandy-rm #{mandy_config} #{file_path}`
94
+ execute("mandy-get #{mandy_config} #{file_path} #{file_path} 2>&1")
95
+ execute("mandy-rm #{mandy_config} #{file_path} 2>&1")
96
96
  File.open(file_path) {|file| file.readlines}
97
97
  end
98
98
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbpig
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 2
9
- version: 0.1.2
4
+ prerelease:
5
+ version: 0.1.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Jae Lee
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-10 00:00:00 +00:00
13
+ date: 2011-05-25 00:00:00 +01:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 5
31
- - 0
32
24
  version: 0.5.0
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -65,21 +57,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
57
  requirements:
66
58
  - - ">="
67
59
  - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
60
  version: "0"
71
61
  required_rubygems_version: !ruby/object:Gem::Requirement
72
62
  none: false
73
63
  requirements:
74
64
  - - ">="
75
65
  - !ruby/object:Gem::Version
76
- segments:
77
- - 0
78
66
  version: "0"
79
67
  requirements: []
80
68
 
81
69
  rubyforge_project:
82
- rubygems_version: 1.3.7
70
+ rubygems_version: 1.5.2
83
71
  signing_key:
84
72
  specification_version: 3
85
73
  summary: Pig queries execution ruby binding