Sha256: cacfbb2a041c11416805d18866801cb2e9eb5dd66da60824dc80d475fd8b50ce
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
require File.join(File.dirname(__FILE__), 'http_enabled') require File.join(File.dirname(__FILE__), 'api_auth') module SimpleWorker class Base < SimpleWorker::ApiAuth include SimpleWorker::HttpEnabled def initialize(access_key, secret_key) super(access_key, secret_key) end # Options: # - :callback_url def upload(filename, class_name, options={}) mystring = nil file = File.open(filename, "r") do |f| mystring = f.read end options = {"code"=>mystring, "class_name"=>class_name} response = run_http(@access_key, @secret_key, :post, "code/put", nil, options) puts "response=" + response return ActiveSupport::JSON.decode(response) end def queue(class_name, data={}) params = nil if !data.is_a?(Array) data = [data] end hash_to_send = {} hash_to_send["data"] = data hash_to_send["class_name"] = class_name puts 'hash_to_send=' + hash_to_send.inspect response = run_http(@access_key, @secret_key, :put, "queue/add", hash_to_send, params) puts "response=" + response return ActiveSupport::JSON.decode(response) end def status(task_id) data = {"task_id"=>task_id} #puts run_http(@access_key, @secret_key, :post, "queue/status", nil, {"task_id"=>@task_id}) response = run_http(@access_key, @secret_key, :get, "queue/status", nil, data) puts "response=" + response return ActiveSupport::JSON.decode(response) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_worker-0.0.2 | lib/simple_worker.rb |