Class: Hjc::Util
- Inherits:
-
Object
- Object
- Hjc::Util
- Defined in:
- lib/hjc/util.rb
Constant Summary collapse
- TMP_DIR =
'tmp'
Class Method Summary collapse
- .hadoop_home ⇒ Object
- .hadoop_jars ⇒ Object
- .setup ⇒ Object
- .to_temp_file(filename, body, options = {}) ⇒ Object
Class Method Details
.hadoop_home ⇒ Object
23 24 25 |
# File 'lib/hjc/util.rb', line 23 def self.hadoop_home ENV['HADOOP_HOME'] end |
.hadoop_jars ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hjc/util.rb', line 15 def self.hadoop_jars jars = [] ['', 'lib', 'contrib/streaming'].each do |path| jars.concat Dir.glob(File.join(hadoop_home, path, "*.jar")) end jars end |
.setup ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/hjc/util.rb', line 7 def self.setup hadoop_jars.each do |jar| require jar # fro JRuby end $CLASSPATH << "#{hadoop_home}/conf" end |
.to_temp_file(filename, body, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hjc/util.rb', line 27 def self.to_temp_file(filename, body, ={}) file = Tempfile.new(filename, TMP_DIR) file.print body file.close unless .empty? if .keys.include? :mod File.chmod([:mod], file.path) end end file end |