class KatteHiveAutodep::HDP

Constants

ENV_SCRIPT
EXT_LIB_ROOT

wrapper class for hive-dependency-parser

HDP_JAR
HDP_MAIN_CLASS

Public Class Methods

new() click to toggle source
# File lib/katte_hive_autodep/hdp.rb, line 12
def initialize
end

Public Instance Methods

run(file) click to toggle source
# File lib/katte_hive_autodep/hdp.rb, line 15
    def run(file)
      return unless File.file? file

      dependency = IO.pipe do |o_r,o_w|
        ret = system(<<EOF, :out => o_w, :err => "/dev/null")
source #{ENV_SCRIPT}
CLASSPATH=$CLASSPATH:#{HDP_JAR} java -Xmx256m #{HDP_MAIN_CLASS} #{file}
EOF

        return unless ret

        o_w.close
        o_r.to_a.join
      end

      JSON.parse(dependency)
    end