Module: Pipely::Build::TemplateHelpers

Included in:
Template
Defined in:
lib/pipely/build/template_helpers.rb

Overview

Helper methods used by ERB templates.

Instance Method Summary collapse

Instance Method Details

#s3_asset_path(path) ⇒ Object



8
9
10
# File 'lib/pipely/build/template_helpers.rb', line 8

def s3_asset_path(path)
  "#{s3_asset_prefix if '/' == path[0]}#{path}"
end

#s3n_asset_path(path) ⇒ Object



12
13
14
# File 'lib/pipely/build/template_helpers.rb', line 12

def s3n_asset_path(path)
  "#{s3n_asset_prefix if '/' == path[0]}#{path}"
end

#s3n_step_path(path) ⇒ Object



16
17
18
# File 'lib/pipely/build/template_helpers.rb', line 16

def s3n_step_path(path)
  "#{s3n_step_prefix if '/' == path[0]}#{path}"
end

#streaming_hadoop_step(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pipely/build/template_helpers.rb', line 20

def streaming_hadoop_step(options)
  parts = [ '/home/hadoop/contrib/streaming/hadoop-streaming.jar' ]

  if jars = options[:lib_jars]
    parts += Array(jars).map { |jar| ['-libjars', "#{jar}"] }.flatten
  end

  (options[:defs] || {}).each do |name, value|
    parts += ['-D', "#{name}=#{value}".gsub(',', "\\,")]
  end

  Array(options[:input]).each do |input|
    parts += [ '-input', s3n_asset_path(input) ]
  end

  Array(options[:output]).each do |output|
    parts += ['-output', s3_asset_path(output) ]
  end

  if options[:outputformat]
    parts += ['-outputformat', options[:outputformat] ]
  end

  if options[:partitioner]
    parts += ['-partitioner', options[:partitioner] ]
  end

  Array(options[:mapper]).each do |mapper|
    parts += ['-mapper', s3n_step_path(mapper) ]
  end

  Array(options[:reducer]).each do |reducer|
    parts += ['-reducer', s3n_step_path(reducer) ]
  end

  Array(options[:cache_file]).each do |cache_file|
    parts += ['-cacheFile', s3n_asset_path(cache_file)]
  end

  (options[:env] || {}).each do |name, value|
    parts += ['-cmdenv', "#{name}=#{value}"]
  end

  parts.join(',')
end