trafficbroker-mandy 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/bin/mandy-hadoop +4 -0
  2. data/lib/mandy.rb +3 -0
  3. data/lib/task.rb +11 -0
  4. metadata +2 -3
@@ -21,6 +21,10 @@ OptionParser.new do |opts|
21
21
  options.cmdenv = config
22
22
  end
23
23
 
24
+ opts.on("-j", '--json {"key":"1 value"}', "Pass JSON encoded parameters to jobs") do |config|
25
+ options.cmdenv = "json=#{config}"
26
+ end
27
+
24
28
  opts.on_tail("-h", "--help", "Show this message") do
25
29
  puts opts
26
30
  exit
@@ -20,6 +20,9 @@
20
20
  ruby-hbase
21
21
  ).each {|file| require File.join(File.dirname(__FILE__), file) }
22
22
 
23
+ require "rubygems"
24
+ require "json"
25
+
23
26
  module Mandy
24
27
  class << self
25
28
  def stores
@@ -1,5 +1,6 @@
1
1
  module Mandy
2
2
  class Task
3
+ JSON_PAYLOAD_KEY = "json"
3
4
  KEY_VALUE_SEPERATOR = "\t" unless defined?(KEY_VALUE_SEPERATOR)
4
5
 
5
6
  def initialize(input=STDIN, output=STDOUT)
@@ -22,8 +23,18 @@ module Mandy
22
23
  private
23
24
 
24
25
  def parameter(name)
26
+ return find_json_param(name) if json_provided?
25
27
  ENV[name.to_s]
26
28
  end
29
+
30
+ def find_json_param(name)
31
+ @json_args ||= JSON.parse(ENV[JSON_PAYLOAD_KEY])
32
+ @json_args[name.to_s]
33
+ end
34
+
35
+ def json_provided?
36
+ !ENV[JSON_PAYLOAD_KEY].nil?
37
+ end
27
38
 
28
39
  def serialize(value)
29
40
  value = ArraySerializer.new(value) if value.is_a?(Array)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trafficbroker-mandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Kent
@@ -64,7 +64,6 @@ files:
64
64
  - lib/test_runner.rb
65
65
  has_rdoc: false
66
66
  homepage: http://github.com/trafficbroker/mandy
67
- licenses:
68
67
  post_install_message:
69
68
  rdoc_options: []
70
69
 
@@ -85,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
84
  requirements: []
86
85
 
87
86
  rubyforge_project:
88
- rubygems_version: 1.3.5
87
+ rubygems_version: 1.2.0
89
88
  signing_key:
90
89
  specification_version: 2
91
90
  summary: Map/Reduce