Sha256: d5a3ce8c5b07a997da3626b858506b013146497c5329aec54779f87fef94930e
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'ostruct' require 'cgi' options = OpenStruct.new OptionParser.new do |opts| opts.banner = "USAGE: mandy-local my_script.rb local_input_file local_output_folder [options]" opts.on("-v", '--variables name=value', "Pass additional parameters to jobs") do |config| options.cmdenv = config end opts.on("-j", '--json {"key":"1 value"}', "Pass JSON encoded parameters to jobs") do |config| options.cmdenv = "json=#{CGI.escape(config)}" end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end.parse! exec('mandy-local -h') unless ARGV.size >= 3 require "fileutils" def absolute_path(path) path =~ /^\// ? path : File.join(Dir.pwd, path) end def set_env(opts_string) opts_string.split(' ').each do |pair| key, value = pair.split("=") ENV[key] = value end end set_env(options.cmdenv) if options.cmdenv file = absolute_path(ARGV[0]) input = absolute_path(ARGV[1]) output_folder = FileUtils.mkdir_p(absolute_path(ARGV[2])) require file out = nil Mandy::Job.jobs.each_with_index do |job, i| out = File.join(output_folder, "#{i+1}-#{job.name.downcase.gsub(/\W/, '-')}") puts "Running #{job.name}..." `cat #{input} | mandy-map #{file} "#{job.name}" | sort | mandy-reduce #{file} "#{job.name}" > #{out}` input = out end puts out
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mandy-0.4.3 | bin/mandy-local |
mandy-0.4.2 | bin/mandy-local |