#!/usr/bin/env ruby require 'rubygems' require 'yajl' require 'beanstalk-client' command = ARGV[0] case command when "deploy" options = ARGV[1..-1] options = Hash[options.map {|o| o.scan(/--(.+)=(.+)/).flatten }] @queue = Beanstalk::Connection.new('localhost:11300', 'checks') filename = options["from"] file = File.new(filename) parser = Yajl::Parser.new batch = parser.parse(file) batch_id = batch["batch"]["id"] batch["checks"].each do |check| job = check.merge({"batch_id" => batch_id}) @queue.yput(job) end puts "Deployed batch #{batch_id}" end