simple_worker 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_worker.rb +1 -0
- metadata +1 -4
- data/lib/queue.rb +0 -33
- data/lib/status.rb +0 -22
- data/lib/uploader.rb +0 -28
data/lib/simple_worker.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
@@ -24,10 +24,7 @@ extra_rdoc_files:
|
|
24
24
|
files:
|
25
25
|
- lib/api_auth.rb
|
26
26
|
- lib/http_enabled.rb
|
27
|
-
- lib/queue.rb
|
28
27
|
- lib/simple_worker.rb
|
29
|
-
- lib/status.rb
|
30
|
-
- lib/uploader.rb
|
31
28
|
- lib/worker.rb
|
32
29
|
- README.markdown
|
33
30
|
has_rdoc: true
|
data/lib/queue.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'http_enabled'
|
2
|
-
require 'api_auth'
|
3
|
-
|
4
|
-
module SimpleWorker
|
5
|
-
class Queue < SimpleWorker::ApiAuth
|
6
|
-
|
7
|
-
extend SimpleWorker::HttpEnabled
|
8
|
-
|
9
|
-
def initialize(access_key, secret_key, class_name)
|
10
|
-
super(access_key, secret_key)
|
11
|
-
@class_name = class_name
|
12
|
-
end
|
13
|
-
|
14
|
-
def add(class_name, data={})
|
15
|
-
|
16
|
-
params = nil
|
17
|
-
if !data.is_a?(Array)
|
18
|
-
data = [data]
|
19
|
-
end
|
20
|
-
hash_to_send = {}
|
21
|
-
hash_to_send["data"] = data
|
22
|
-
hash_to_send["class_name"] = class_name
|
23
|
-
puts 'hash_to_send=' + hash_to_send.inspect
|
24
|
-
res = run_http(access_key, secret_key, :put, "queue/add", hash_to_send, params)
|
25
|
-
puts "response=" + res
|
26
|
-
return ActiveSupport::JSON.decode(res)
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
end
|
data/lib/status.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'http_enabled'
|
2
|
-
require 'api_auth'
|
3
|
-
|
4
|
-
module SimpleWorker
|
5
|
-
class Status < SimpleWorker::ApiAuth
|
6
|
-
|
7
|
-
extend SimpleWorker::HttpEnabled
|
8
|
-
|
9
|
-
def initialize(access_key, secret_key, class_name)
|
10
|
-
super(access_key, secret_key)
|
11
|
-
@class_name = class_name
|
12
|
-
end
|
13
|
-
|
14
|
-
def check(task_id)
|
15
|
-
data = {"task_id"=>task_id}
|
16
|
-
#puts run_http(@access_key, @secret_key, :post, "queue/status", nil, {"task_id"=>@task_id})
|
17
|
-
puts "response=" + run_http(@access_key, @secret_key, :get, "queue/status", nil, data)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
end
|
data/lib/uploader.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'http_enabled'
|
2
|
-
require 'api_auth'
|
3
|
-
|
4
|
-
module SimpleWorker
|
5
|
-
class Uploader < SimpleWorker::ApiAuth
|
6
|
-
|
7
|
-
extend SimpleWorker::HttpEnabled
|
8
|
-
|
9
|
-
def initialize(access_key, secret_key)
|
10
|
-
super(access_key, secret_key)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Options:
|
14
|
-
# - :callback_url
|
15
|
-
def put(filename, class_name, data={})
|
16
|
-
mystring = nil
|
17
|
-
file = File.open(filename, "r") do |f|
|
18
|
-
mystring = f.read
|
19
|
-
end
|
20
|
-
data = {"code"=>mystring, "class_name"=>class_name}
|
21
|
-
puts "response=" + run_http(@access_key, @secret_key, :post, "code/put", nil, data)
|
22
|
-
#puts "response=" + run_http(access_key, secret_key, :post, "queue/add", nil, data)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|