Module: HadoopDsl::HiveLike::HiveLikeMapRed

Included in:
HiveLikeMapper, HiveLikeReducer, HiveLikeSetup
Defined in:
lib/hive_like.rb

Overview

common

Instance Method Summary collapse

Instance Method Details

#pre_process(body) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/hive_like.rb', line 6

def pre_process(body)
  processed = ""
  body.each do |line|
    next if line =~ /^#/
    if line =~ /^(\w*)\s+(.*);$/
      method = $1
      args = sprit_and_marge_args($2)
      processed << "#{method}(#{args})\n"
    else 
      processed << line + "\n" if line
    end
  end
  processed
end

#sprit_and_marge_args(raw) ⇒ Object



21
22
23
24
25
26
# File 'lib/hive_like.rb', line 21

def sprit_and_marge_args(raw)
  raw.gsub(/[\(\)]/, ' ').split.map do |s|
    stripped = s.gsub(/[\s,"']/, '')
    %Q!"#{stripped}"!
  end.join(", ")
end